/* ============================================
   Drone Dashboard - Dashboard Layout
   ============================================ */

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-darkest);
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(124,77,255,0.08) 0%, transparent 70%);
    top: -200px;
    right: -200px;
}
.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,64,129,0.06) 0%, transparent 70%);
    bottom: -150px;
    left: -150px;
}
.login-card {
    background: rgba(22, 22, 37, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(124, 77, 255, 0.15);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    width: 420px;
    max-width: 90%;
    text-align: center;
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.5s ease;
    box-shadow: 0 8px 32px rgba(124, 77, 255, 0.1);
}
.login-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-lg);
    background: var(--accent-primary-dim);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--accent-primary);
    box-shadow: 0 0 30px rgba(124, 77, 255, 0.2);
}
.login-card h1 {
    font-size: var(--font-size-2xl);
    margin-bottom: var(--space-sm);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.login-card p {
    color: var(--text-muted);
    margin-bottom: var(--space-md);
    font-size: var(--font-size-md);
}
.login-btn {
    width: 100%;
    padding: 14px;
    font-size: var(--font-size-base);
}
.login-footer {
    margin-top: var(--space-xl);
    font-size: var(--font-size-sm);
    color: var(--text-dimmed);
}

/* Dashboard Shell */
.dashboard {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-dark);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: var(--z-sidebar);
    transition: width var(--transition-normal), transform var(--transition-normal);
    overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .sidebar-brand-text { display: none; }
.sidebar.collapsed .sidebar-link { justify-content: center; padding: 10px; }
.sidebar.collapsed .sidebar-link i { margin: 0; }

.sidebar-brand {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    border-bottom: 1px solid var(--border-dark);
    height: var(--header-height); box-sizing: border-box;
    flex-shrink: 0;
}
.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: var(--accent-primary-dim);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    font-size: 1rem;
    flex-shrink: 0;
}
.sidebar-brand-text { font-weight: 700; font-size: var(--font-size-lg); white-space: nowrap; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-sm) 0;
}
.sidebar-section-title {
    padding: 12px 16px 4px;
    font-size: var(--font-size-xs);
    color: var(--text-dimmed);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    white-space: nowrap;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 10px 16px;
    color: var(--text-muted);
    font-size: var(--font-size-md);
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    white-space: nowrap;
}
.sidebar-link:hover { color: var(--text-primary); background: rgba(255,255,255,0.03); }
.sidebar-link.active {
    color: var(--accent-primary);
    background: var(--accent-primary-dim);
    border-right: 3px solid var(--accent-primary);
}
.sidebar-link i { width: 20px; text-align: center; font-size: 0.95rem; flex-shrink: 0; }
.sidebar-label { white-space: nowrap; }

.sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border-dark);
    flex-shrink: 0;
}
.sidebar-collapse-btn {
    width: 100%;
    padding: 8px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }

/* Main Area */
.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
}
.sidebar.collapsed ~ .main-area { margin-left: var(--sidebar-collapsed); }

/* Header */
.header {
    height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg);
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}
.mobile-menu-btn {
    display: none;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: var(--radius-md);
}
.mobile-menu-btn:hover { background: rgba(255,255,255,0.05); }

/* Server Selector */
.server-selector {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}
.server-selector-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px 14px;
    background: var(--bg-medium);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.server-selector-btn:hover { border-color: var(--border-medium); }
.server-selector-btn img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}
.server-selector-btn .server-name { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-selector-btn .chevron { font-size: 0.7rem; color: var(--text-muted); margin-left: 4px; }
.server-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 280px;
    background: var(--bg-dark);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    display: none;
    max-height: 400px;
    overflow-y: auto;
}
.server-dropdown.show { display: block; animation: fadeInDown 0.15s ease; }
.server-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px 16px;
    cursor: pointer;
    transition: background var(--transition-fast);
    color: var(--text-secondary);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: var(--font-size-md);
}
.server-dropdown-item:hover { background: var(--bg-medium); }
.server-dropdown-item.active { background: var(--accent-primary-dim); color: var(--accent-primary); }
.server-dropdown-item img { width: 32px; height: 32px; border-radius: 50%; }
.server-dropdown-item .server-info { flex: 1; }
.server-dropdown-item .server-info .name { font-weight: 500; }
.server-dropdown-item .server-info .member-count { font-size: var(--font-size-xs); color: var(--text-muted); }

/* Header Right */
.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* User Menu */
.user-menu {
    position: relative;
    display: flex;
    align-items: center;
}
.user-menu-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 4px 12px 4px 4px;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-primary);
}
.user-menu-btn:hover { background: rgba(255,255,255,0.05); border-color: var(--border-dark); }
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border-medium);
}
.user-name { font-size: var(--font-size-md); font-weight: 500; }
.user-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 180px;
    background: var(--bg-dark);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    display: none;
    overflow: hidden;
}
.user-dropdown.show { display: block; animation: fadeInDown 0.15s ease; }

/* Page Container */
.page-container {
    flex: 1;
    padding: 16px 20px;
    max-width: var(--content-max-width);
    width: 100%;
    margin: 0 auto;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: var(--space-md);
}
.page-header h2 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}
.page-header h2 i { color: var(--accent-primary); }
.page-header-actions { display: flex; align-items: center; gap: var(--space-sm); }

/* Page sections */
.section { margin-bottom: var(--space-xl); }
.section-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}
.section-title i { color: var(--accent-primary); font-size: 0.9em; }

/* Chart Containers */
.chart-container {
    position: relative;
    width: 100%;
    height: 300px;
    background: var(--bg-card);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
}
.chart-container canvas { width: 100% !important; height: 100% !important; }
.chart-container .chart-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: var(--space-sm);
}
.chart-container .chart-placeholder i { font-size: 2rem; opacity: 0.3; }

/* Filter Bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}
.filter-bar .form-input,
.filter-bar .form-select { width: auto; min-width: 150px; }

/* Module header (for toggle + description) */
.module-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-md);
}
.module-header-info { flex: 1; }
.module-header-info h3 { margin-bottom: var(--space-xs); }
.module-header-info p { color: var(--text-muted); font-size: var(--font-size-md); }

/* Config Panel */
.config-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-lg);
    padding: 12px;
    margin-bottom: 10px;
}
.config-panel-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-dark);
}

/* Quick Actions */
.quick-actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; }
.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 100px;
}
.quick-action-btn:hover { border-color: var(--accent-primary); color: var(--accent-primary); transform: translateY(-2px); box-shadow: 0 4px 15px rgba(124, 77, 255, 0.15); }
.quick-action-btn i { font-size: 1.2rem; }

/* Mobile sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: calc(var(--z-sidebar) - 1);
}

/* Date range picker */
.date-range {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}
.date-range .form-input { width: 150px; }
.date-range .separator { color: var(--text-muted); }

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .sidebar.mobile-open + .sidebar-overlay { display: block; }
    .main-area { margin-left: 0 !important; }
    .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }
    .header { padding: 0 var(--space-md); }
    .page-container { padding: var(--space-md); }
    .page-header { flex-direction: column; align-items: flex-start; }
    .user-name { display: none; }
    .server-selector-btn .server-name { max-width: 120px; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar .form-input,
    .filter-bar .form-select { width: 100%; min-width: auto; }
}

/* === Sidebar Favorites === */
.sidebar-favorites { border-bottom: 1px solid rgba(124,77,255,0.15); padding-bottom: 0.5rem; margin-bottom: 0.25rem; }
.sidebar-fav-link { border-left: 2px solid rgba(124,77,255,0.3) !important; }
.sidebar-fav-star { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 0.7rem; color: rgba(255,255,255,0.2); cursor: pointer; opacity: 0; transition: opacity 0.2s, color 0.2s; z-index: 2; }
.sidebar-link { position: relative; }
.sidebar-link:hover .sidebar-fav-star { opacity: 1; }
.sidebar-fav-star:hover { color: #7c4dff !important; }
.sidebar-fav-star.favorited { color: #7c4dff !important; opacity: 1; }

/* ============================================
   Mobile-Friendly Enhancements
   ============================================ */

/* Touch-friendly: minimum 44px tap targets */
@media (max-width: 768px) {
    /* Sidebar */
    .sidebar-link { padding: 14px 16px; font-size: 15px; min-height: 44px; }
    .sidebar-section-title { padding: 14px 16px 6px; }
    .sidebar-fav-star { opacity: 1; font-size: 0.85rem; right: 12px; }
    .sidebar-brand { padding: 12px 16px; }
    .sidebar-footer { padding: 8px 12px; }
    .sidebar-collapse-btn { display: none; }

    /* Header */
    .header { height: 52px; }
    .mobile-menu-btn { width: 44px; height: 44px; font-size: 1.3rem; }
    .server-selector-btn { padding: 6px 10px; font-size: 13px; }
    .server-selector-btn img { width: 22px; height: 22px; }
    .server-selector-btn .chevron { display: none; }
    .server-dropdown { left: -10px; right: -10px; min-width: 0; width: calc(100vw - 20px); max-width: 360px; }
    .server-dropdown-item { padding: 12px 16px; min-height: 44px; }
    .user-menu-btn { padding: 4px; }
    .user-avatar { width: 28px; height: 28px; }
    .user-dropdown { right: -8px; min-width: 160px; }
    .user-dropdown button,
    .user-dropdown a { min-height: 44px; padding: 12px 16px; }

    /* Page content */
    .page-container { padding: 12px; }
    .page-header { gap: 8px; margin-bottom: 14px; }
    .page-header h2 { font-size: 1.15rem; }
    .page-header-actions { width: 100%; }
    .page-header-actions .btn { flex: 1; justify-content: center; }

    /* Sections */
    .section { margin-bottom: 16px; }
    .section-title { font-size: 15px; margin-bottom: 10px; }

    /* Config panels */
    .config-panel { padding: 12px; }
    .module-header { flex-direction: column; padding: 12px; }

    /* Quick actions - scrollable row */
    .quick-actions { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
    .quick-action-btn { min-width: 80px; padding: 12px; flex-shrink: 0; }

    /* Filter bar */
    .filter-bar { padding: 10px; gap: 8px; }

    /* Date range stacked */
    .date-range { flex-direction: column; align-items: stretch; }
    .date-range .form-input { width: 100%; }
    .date-range .separator { display: none; }

    /* Chart containers */
    .chart-container { height: 220px; padding: 8px; }

    /* Login page */
    .login-card { padding: 24px 20px; }
    .login-logo { width: 64px; height: 64px; font-size: 1.5rem; }
    .login-card h1 { font-size: 1.3rem; }
    .login-btn { padding: 16px; font-size: 16px; min-height: 52px; }
}

/* Small phones */
@media (max-width: 480px) {
    .page-container { padding: 8px; }
    .page-header h2 { font-size: 1rem; }
    .server-selector-btn .server-name { max-width: 90px; font-size: 12px; }
    .quick-action-btn { min-width: 70px; font-size: 12px; }
    .quick-action-btn i { font-size: 1rem; }
}

/* Landscape phone */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar { max-height: 100vh; }
    .sidebar-nav { padding-bottom: 60px; }
    .login-page { min-height: auto; padding: 20px; }
    .login-card { padding: 20px 16px; }
}
