/**
 * App Layout & Header Styles
 */

/* ========================================
   APP LAYOUT
   ======================================== */

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.app-header {
    height: 64px;
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-md);
    gap: var(--spacing-md);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    z-index: var(--z-sticky);
}

.header-left,
.header-center,
.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.header-left {
    flex: 1;
}

.header-center {
    flex: 0 0 auto;
}

.header-right {
    flex: 1;
    justify-content: flex-end;
}

.app-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    margin: 0;
    white-space: nowrap;
}

/* Connection Status */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* User Menu */
.user-menu {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--spacing-xs);
    z-index: var(--z-dropdown);
}

.dropdown-item {
    display: block;
    padding: var(--spacing-sm);
    color: var(--color-text-primary);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--color-bg-tertiary);
}

/* ========================================
   SIDEBAR
   ======================================== */

.app-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.app-sidebar {
    width: 240px;
    background: var(--color-bg-secondary);
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    flex-shrink: 0;
    transition: transform var(--transition-base);
}

.sidebar-nav {
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--color-text-secondary);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    font-weight: var(--font-weight-medium);
    height: 48px;
}

.nav-item:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-bright) 100%);
    color: white;
}

.nav-item-highlight {
    background: var(--color-success);
    color: var(--color-text-inverse);
}

.nav-item-highlight:hover {
    background: var(--color-success-dark);
    color: var(--color-text-inverse);
}

.nav-item svg {
    flex-shrink: 0;
}

/* ========================================
   MAIN CONTENT
   ======================================== */

.app-main {
    flex: 1;
    overflow-y: auto;
    background: var(--color-bg-primary);
    padding: var(--spacing-md);
}

#view-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ========================================
   AUTH SCREEN
   ======================================== */

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    background: linear-gradient(135deg, var(--color-bg-primary) 0%, var(--color-bg-secondary) 100%);
}

.auth-card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: var(--spacing-xl);
    max-width: 480px;
    width: 100%;
}

.auth-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.auth-header h1 {
    font-size: var(--font-size-2xl);
    margin-bottom: var(--spacing-xs);
    background: linear-gradient(135deg, var(--color-accent-bright) 0%, var(--color-accent-hover) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-header p {
    color: var(--color-text-tertiary);
    font-size: var(--font-size-sm);
}

.auth-form h2 {
    margin-bottom: var(--spacing-md);
    text-align: center;
}

.auth-switch {
    text-align: center;
    margin-top: var(--spacing-md);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

.auth-switch a {
    color: var(--color-accent-bright);
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Auth Error Message Styles */
.auth-error-message {
    display: none;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: rgba(239, 83, 80, 0.15);
    border: 1px solid var(--color-danger);
    border-radius: 8px;
    color: var(--color-danger);
    font-size: 14px;
    line-height: 1.5;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   LOADING OVERLAY
   ======================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 15, 30, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(8px);
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .app-sidebar {
        position: fixed;
        top: 64px;
        left: 0;
        bottom: 0;
        z-index: var(--z-fixed);
        transform: translateX(-100%);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .app-title {
        font-size: var(--font-size-base);
    }

    #license-badge {
        display: none;
    }

    .header-center {
        position: static;
        /* Remove absolute positioning to flow naturally */
        transform: none;
    }

    .app-title {
        display: none;
        /* Hide title on mobile to save space */
    }

    /* Move badge to the right if needed, or keep in center */
    .header-right {
        gap: var(--spacing-xs);
    }
}

@media (max-width: 480px) {

    /* 20% more compact header */
    .app-header {
        height: 52px;
        padding: 0 6px;
        gap: 4px;
    }

    /* Force hide title on small mobile */
    .app-title {
        display: none !important;
    }

    /* Compact header sections */
    .header-left {
        flex: 0 0 auto;
    }

    .header-center {
        flex: 1;
        justify-content: flex-start;
        margin-left: 6px;
    }

    .header-right {
        flex: 0 0 auto;
        gap: 2px;
    }

    /* 20% smaller buttons in header */
    .header-right .btn-sm {
        padding: 0 6px;
        height: 32px;
    }

    #menu-toggle {
        padding: 6px;
        height: 36px;
        width: 36px;
    }

    /* Sidebar 20% more compact */
    .app-sidebar {
        top: 52px;
        width: 200px;
    }

    .sidebar-nav {
        padding: 8px;
        gap: 2px;
    }

    .nav-item {
        padding: 8px 10px;
        height: 40px;
        font-size: 0.85rem;
    }

    .nav-item svg {
        width: 18px;
        height: 18px;
    }

    /* 20% smaller main content */
    .app-main {
        padding: 8px;
        padding-bottom: 50px;
    }

    .auth-card {
        padding: 12px;
    }

    /* Smaller badges */
    .badge {
        padding: 2px 6px;
        font-size: 0.7rem;
    }
}