﻿/* ===== VARIABLES ===== */
:root {
    /* Brand Colors */
    --primary: #3A767A;
    --primary-600: #2f6164;
    --primary-700: #254a4d;
    --primary-light: rgba(58,118,122,.10);
    --primary-dark: #1f4a4e;
    --primary-bg: rgba(58, 118, 122, 0.08);
    --primary-gradient: linear-gradient(135deg, #3A767A 0%, #254a4d 100%);
    --secondary: #3FAC72;
    --secondary-600: #2f945f;
    --secondary-light: rgba(63,172,114,.10);
    --secondary-gradient: linear-gradient(135deg, #3FAC72 0%, #267a4e 100%);
    --tertiary: #E04852;
    --tertiary-600: #c63f48;
    --tertiary-light: rgba(224,72,82,.10);
    --tertiary-gradient: linear-gradient(135deg, #E04852 0%, #c63f48 100%);
    /* UI Colors */
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --surface-dark: #1e293b;
    --surface-darker: #0f172a;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --text-on-dark: #f1f5f9;
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.08);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.12);
    /* Spacing */
    --sidebar-width: 280px;
    --sidebar-collapsed: 80px;
    --header-height: 70px;
    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface-2);
}

::-webkit-scrollbar-thumb {
    background: var(--text-light);
    border-radius: 4px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--primary);
    }

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--surface-darker) 0%, var(--surface-dark) 100%);
    color: var(--text-on-dark);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

    /* Desktop Collapsed State */
    .sidebar.collapsed {
        width: var(--sidebar-collapsed);
    }

/* Mobile Sidebar - Hidden by default */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        width: 85% !important;
        max-width: 320px;
        box-shadow: none;
        transition: transform 0.3s ease;
    }

        .sidebar.mobile-open {
            transform: translateX(0);
            box-shadow: var(--shadow-lg);
        }

        /* Reset collapsed styles on mobile */
        .sidebar.collapsed {
            width: 85% !important;
            max-width: 320px;
        }

            .sidebar.collapsed .logo-text,
            .sidebar.collapsed .nav-group-label,
            .sidebar.collapsed .nav-text,
            .sidebar.collapsed .sidebar-footer {
                display: block;
            }

            .sidebar.collapsed .nav-icon {
                margin-right: 1rem;
                font-size: 1.25rem;
            }

            .sidebar.collapsed .nav-link {
                justify-content: flex-start;
                padding: 0.875rem 1.5rem;
            }

            .sidebar.collapsed .sidebar-toggle i {
                transform: rotate(0deg);
            }

            /* Hide tooltips on mobile */
            .sidebar.collapsed .nav-tooltip {
                display: none;
            }
}

/* Sidebar Header */
.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-header {
    padding: 0 1rem;
    justify-content: center;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo {
    height: 32px;
    width: auto;
    transition: var(--transition);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .sidebar-logo {
    display: none;
}

.sidebar-toggle {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

    .sidebar-toggle:hover {
        background: rgba(255,255,255,0.2);
    }

.sidebar.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem 0;
    -webkit-overflow-scrolling: touch;
}

.nav-group {
    margin-bottom: 1.5rem;
}

.nav-group-label {
    padding: 0 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.4);
}

.sidebar.collapsed .nav-group-label {
    display: none;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    position: relative;
    margin-bottom: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
}

    .nav-link:hover {
        background: rgba(255,255,255,0.05);
        color: white;
    }

    .nav-link.active {
        background: rgba(58, 118, 122, 0.2);
        color: white;
        border-left: 3px solid var(--primary);
    }

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.875rem;
}

.sidebar.collapsed .nav-text {
    display: none;
}

.nav-icon {
    width: 20px;
    font-size: 1.1rem;
    text-align: center;
}

.nav-tooltip {
    display: none;
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface-darker);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.875rem;
    white-space: nowrap;
    z-index: 1001;
    margin-left: 10px;
    box-shadow: var(--shadow-md);
    pointer-events: none;
}

.sidebar.collapsed .nav-item:hover .nav-tooltip {
    display: block;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.05);
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    text-align: center;
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-footer {
    display: none;
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

    .sidebar-overlay.active {
        display: block;
    }

/* ===== HEADER ===== */
.main-header {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--header-height);
    background: var(--surface);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
    z-index: 900;
    box-shadow: var(--shadow-sm);
}

.sidebar.collapsed ~ .main-header {
    left: var(--sidebar-collapsed);
}

@media (max-width: 1024px) {
    .main-header,
    .sidebar.collapsed ~ .main-header {
        left: 0 !important;
        width: 100%;
        padding: 0 1rem;
    }
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Mobile Toggle Button */
.mobile-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

    .mobile-toggle:hover {
        background: var(--surface-2);
    }

@media (max-width: 1024px) {
    .mobile-toggle {
        display: flex;
    }
}

.page-title {
    display: flex;
    flex-direction: column;
}

    .page-title span:first-child {
        font-size: 1.25rem;
        font-weight: 600;
        color: var(--text);
    }

.page-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .page-subtitle {
        display: none;
    }
}

/* Header Right */
.header-right {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Notifications */
.notification-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

    .notification-btn:hover {
        background: var(--surface-2);
    }

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--tertiary);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface);
}

.notification-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 380px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    display: none;
    z-index: 1000;
}

    .notification-panel.active {
        display: block;
    }

@media (max-width: 1024px) {
    .notification-panel {
        position: fixed;
        top: var(--header-height);
        right: 1rem;
        width: 90vw;
        max-width: 380px;
    }
}

@media (max-width: 768px) {
    .notification-panel {
        width: calc(100vw - 2rem);
        right: 1rem;
    }
}

/* Profile Dropdown */
.profile-dropdown {
    position: relative;
}

.profile-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

    .profile-toggle:hover {
        background: var(--surface-2);
    }

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
}

    .user-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 50%;
    }

.user-info {
    display: flex;
    flex-direction: column;
}

@media (max-width: 768px) {
    .user-info {
        display: none;
    }
}

.username {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.user-role {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.dropdown-chevron {
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

@media (max-width: 768px) {
    .dropdown-chevron {
        display: none;
    }
}

.profile-dropdown.active .dropdown-chevron {
    transform: rotate(180deg);
}

.profile-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 240px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    display: none;
    z-index: 1000;
}

.profile-dropdown.active .profile-menu {
    display: block;
}

@media (max-width: 1024px) {
    .profile-menu {
        position: fixed;
        top: var(--header-height);
        right: 1rem;
        width: 90vw;
        max-width: 280px;
    }
}

.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text);
    text-decoration: none;
    transition: var(--transition);
}

    .profile-menu-item:hover {
        background: var(--surface-2);
    }

.profile-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 2rem;
    min-height: calc(100vh - var(--header-height));
    transition: var(--transition);
    background: #f8fafc;
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed);
}

@media (max-width: 1024px) {
    .main-content,
    .sidebar.collapsed ~ .main-content {
        margin-left: 0 !important;
        padding: 1rem;
    }
}

/* ===== CONNECTION BANNER ===== */
.connection-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    z-index: 1100;
}

    .connection-banner.connected {
        background: var(--secondary);
        color: white;
    }

    .connection-banner.disconnected {
        background: var(--tertiary);
        color: white;
    }

    .connection-banner.slow {
        background: #f59e0b;
        color: white;
    }

    .connection-banner.hidden {
        display: none;
    }

/* ===== UTILITY CLASSES ===== */
.hidden {
    display: none !important;
}

.relative {
    position: relative;
}

/* ===== RESPONSIVE FIXES ===== */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

        .sidebar.mobile-open {
            transform: translateX(0);
        }

    .main-header {
        width: 100%;
        left: 0;
    }

    .main-content {
        width: 100%;
    }

    .topbar-actions {
        gap: 0.5rem;
    }

    .action-btn {
        width: 36px;
        height: 36px;
    }

    /* Show search only on larger screens */
    .search-container {
        display: none;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }

    .header-right {
        gap: 0.5rem;
    }

    .profile-toggle {
        padding: 0.25rem;
    }

    .notification-panel,
    .profile-menu {
        top: calc(var(--header-height) + 5px);
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 0.75rem;
    }

    .header-left {
        gap: 0.5rem;
    }

    .page-title span:first-child {
        font-size: 1rem;
    }

    .notification-panel,
    .profile-menu {
        width: calc(100vw - 2rem);
        right: 1rem;
    }
}
/* DataTables Custom Styles */
.dataTables_wrapper {
    position: relative;
    min-height: 100px;
}

.dataTables_processing {
    display: none !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    background: rgba(255, 255, 255, 0.9) !important;
    padding: 15px 25px !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
    z-index: 1000 !important;
    margin: 0 !important;
    text-align: center !important;
}

/* Show processing only when needed */
.dataTables_wrapper.processing .dataTables_processing {
    display: block !important;
}

/* Table visibility */
table.dataTable {
    width: 100% !important;
    visibility: visible !important;
    opacity: 1 !important;
}

    table.dataTable.hidden {
        display: none !important;
    }

/* Loading skeleton */
.skeleton-loader {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
    height: 20px;
    margin: 5px 0;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Ensure table cells are visible */
table.dataTable td,
table.dataTable th {
    padding: 12px !important;
    vertical-align: middle !important;
}

/* Fix for any stuck overlays */
.dataTables_wrapper::after {
    display: none !important;
}