:root {
    --titlebar-height: 40px;
    --primary-glass: rgba(9, 9, 11, 0.95);
    --border-color: rgba(139, 92, 246, 0.2);
}

* {
    box-sizing: border-box;
}

html {
    background: #09090b;
    visibility: hidden;
    scrollbar-gutter: stable;
}

html.electron {
    margin: 0;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
}

html.electron .navbar,
html.electron .top-bar,
html.electron .panel-header {
    top: var(--titlebar-height) !important;
}

html.electron .player-wrapper {
    top: var(--titlebar-height);
    height: calc(100% - var(--titlebar-height));
}

html.electron .panel-content {
    margin-top: 2rem;
}

html.electron .calendar-wrapper {
    margin-top: 4rem;
}

html.electron .back-btn {
    top: 55px !important;
}

#back-link {
    margin-top: 55px !important;
}

#titlebar {
    width: calc(100vw - 12px);    display: none;

    height: var(--titlebar-height);
    background: var(--primary-glass);
    color: white;
    align-items: center;
    justify-content: space-between;
    padding-left: 12px;
    padding-right: 0;

    -webkit-app-region: drag;
    user-select: none;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999999;

    font-family: "Inter", system-ui, sans-serif;
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.title-left {
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

#titlebar .app-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.25);
    padding: 2px;
}

#titlebar .app-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.app-title {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: -0.1px;
}

.title-drag-area {
    flex-grow: 1;
    height: 100%;
}

.title-right {
    display: flex;
    height: 100%;
    align-items: center;
    -webkit-app-region: no-drag;
}

.user-box {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
    cursor: default;
}

.user-box:hover {
    background: rgba(255, 255, 255, 0.05);
}

.user-box img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.user-box span {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.9;
    color: #e4e4e7;
}

.window-controls {
    display: flex;
    height: 100%;
}

.control-btn {
    border: none;
    background: transparent;
    color: #a1a1aa;
    width: 46px;
    height: 100%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    outline: none;
}

.control-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.control-btn.min:hover {
    background: rgba(255, 255, 255, 0.1);
}

.control-btn.max:hover {
    background: rgba(255, 255, 255, 0.1);
}

.control-btn.close:hover {
    background: #e81123;
    color: white;
}

.control-btn:active {
    background: rgba(255, 255, 255, 0.15);
}

.control-btn.close:active {
    background: #bf0f1d;
}

html.electron::-webkit-scrollbar {
    width: 12px;
    position: absolute;
    z-index: 0;
}

html.electron::-webkit-scrollbar-track {
    background: #09090b;
    margin-top: var(--titlebar-height);
    border-left: 1px solid rgba(255, 255, 255, 0.05);
}

html.electron::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 6px;
    border: 2px solid #09090b;
    background-clip: content-box;
}

html.electron::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.5);
    border: 2px solid #09090b;
}

body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

.hidden {
    display: none;
}

html.electron #room-view {
    height: calc(100vh - var(--titlebar-height));
    margin-top: var(--titlebar-height);
    overflow: hidden;
}

html.electron #room-view .room-layout {
    height: 100%;
}

#titlebar-user-box {
    position: relative;
    z-index: 1000000;
}

#titlebar-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 240px;
    background: rgba(18, 18, 21, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);

    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000001;

    transform-origin: top right;
    animation: titlebarDropdownSlide 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

#titlebar-dropdown.active {
    display: flex;
}

@keyframes titlebarDropdownSlide {
    from { opacity: 0; transform: scale(0.95) translateY(-5px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

#titlebar-dropdown .dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: rgba(139, 92, 246, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#titlebar-dropdown .dropdown-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #8b5cf6;
}

#titlebar-dropdown .dropdown-user-info {
    display: flex;
    flex-direction: column;
}

#titlebar-dropdown .dropdown-username {
    font-size: 14px;
    font-weight: 600;
    color: white;
}

#titlebar-dropdown .dropdown-status {
    font-size: 11px;
    color: #22c55e;
    font-weight: 500;
}

#titlebar-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: #a1a1aa;
    text-decoration: none;
    font-size: 13px;
    transition: all 0.2s;
    background: transparent;
    border: none;
    width: 100%;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

#titlebar-dropdown .dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    padding-left: 20px;
}

#titlebar-dropdown .dropdown-item svg {
    color: inherit;
    transition: transform 0.2s;
}

#titlebar-dropdown .dropdown-item:hover svg {
    color: #8b5cf6;
}

#titlebar-dropdown .dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 4px 0;
}

#titlebar-dropdown .logout-item {
    color: #ef4444;
}

#titlebar-dropdown .logout-item:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
}

#titlebar-dropdown .logout-item:hover svg {
    color: #f87171;
}

html.electron::-webkit-scrollbar {
    width: 12px;
}

html.electron::-webkit-scrollbar-track {
    margin-top: var(--titlebar-height);
}

#titlebar .control-btn {
    width: 46px !important;
    height: 100% !important;
    color: #a1a1aa;
    transition: all 0.2s;
}

#titlebar .control-btn svg {
    width: auto !important;
    height: auto !important;
    max-width: 14px;
    max-height: 14px;
    pointer-events: none;
}

#titlebar .app-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    max-width: none;
}

/* Nuevo estilo para la parte derecha */
.title-right {
    display: flex;
    height: 100%;
    align-items: center;
    -webkit-app-region: no-drag;
    gap: 0; /* Quitamos gap general para controlar mejor los botones */
}

/* Botones de acción (Settings, etc) */
.title-action-btn {
    width: 40px; /* Un poco más estrechos que los controles de ventana */
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #a1a1aa;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
}

.title-action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.title-action-btn svg {
    width: 16px;
    height: 16px;
}

/* Contenedor del Avatar */
.title-avatar-link {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 0 10px; /* Espacio a los lados */
    cursor: pointer;
    transition: background 0.2s;
    /* Quitamos el borde por defecto de los links */
    text-decoration: none;
}

.title-avatar-link:hover {
    background: rgba(255, 255, 255, 0.08);
}

.title-avatar-link img {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(139, 92, 246, 0.4); /* Borde morado sutil */
}

/* Separador visual antes de los controles de ventana */
.title-sep {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 4px;
}