/* CSS Custom Properties */
:root {
    --primary-color: #00d4ff;
    --secondary-color: #ff0080;
    --accent-color: #00ff88;
    --background-dark: #0a0a0f;
    --background-card: rgba(255, 255, 255, 0.05);
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-glow: 0 0 30px rgba(0, 212, 255, 0.3);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.3);
    --gradient-primary: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    --gradient-accent: linear-gradient(135deg, var(--accent-color), var(--primary-color));
    --blur-bg: blur(20px);
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--background-dark);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(0, 212, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 0, 128, 0.1) 0%, transparent 50%);
}

/* Page Management */
.page {
    display: none;
    min-height: 100vh;
}

.page.active {
    display: block;
}

/* Login Page Styles */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.login-card {
    background: var(--background-card);
    backdrop-filter: var(--blur-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 3rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-primary);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.input-group i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
    z-index: 2;
}

.input-group input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
}

.login-btn {
    width: 100%;
    padding: 1rem;
    background: var(--gradient-primary);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.login-btn:active {
    transform: translateY(0);
}

.login-footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.login-footer p {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Admin Panel Layout */
#adminPanel {
    display: flex;
    min-height: 100vh;
    transition: all 0.3s ease;
}

/* Sidebar Styles */
.sidebar {
    background: var(--background-card);
    backdrop-filter: var(--blur-bg);
    border-right: 1px solid var(--border-color);
    padding: 2rem 0;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    transition: all 0.3s ease;
    width: var(--sidebar-width);
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-text {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-20px);
}

.sidebar.collapsed .sidebar-header h2 {
    opacity: 0;
    visibility: hidden;
}

.sidebar.collapsed .nav-link {
    /*justify-content: center;
    padding: 1rem;*/
    position: relative;
}

/* Show tooltip on hover for collapsed nav items */
.sidebar.collapsed .nav-link:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--background-card);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    white-space: nowrap;
    z-index: 1000;
    margin-left: 0.5rem;
    font-size: 0.9rem;
    backdrop-filter: var(--blur-bg);
    box-shadow: var(--shadow-card);
}

.sidebar.collapsed .logout-btn {
    justify-content: center;
    padding: 0.8rem;
}

.sidebar.collapsed .logout-btn .sidebar-text {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    padding: 0 1rem;
    justify-content: center;
}

.sidebar-header {
    padding: 0 2rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h2 {
    font-size: 1.2rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.8rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Keep toggle button visible even when collapsed */
.sidebar.collapsed .sidebar-toggle {
    position: absolute;
    top: 2rem;
    right: 1rem;
    left: auto;
}

.nav-menu {
    list-style: none;
    padding: 0;
}

.nav-menu li {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 2rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
    white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-color);
    background: rgba(0, 212, 255, 0.1);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--gradient-primary);
}

.nav-link i {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar-text {
    transition: all 0.3s ease;
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.sidebar-footer {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    right: 2rem;
}

.sidebar.collapsed .sidebar-footer {
    left: 1rem;
    right: 1rem;
}

.logout-btn {
    width: 100%;
    padding: 0.8rem;
    background: rgba(255, 0, 128, 0.1);
    border: 1px solid rgba(255, 0, 128, 0.3);
    border-radius: 8px;
    color: var(--secondary-color);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    white-space: nowrap;
}

.logout-btn:hover {
    background: rgba(255, 0, 128, 0.2);
    border-color: var(--secondary-color);
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    background: linear-gradient(135deg, 
        rgba(0, 0, 0, 0) 0%, 
        rgba(0, 212, 255, 0.02) 50%, 
        rgba(255, 0, 128, 0.02) 100%);
        min-height: 100vh;
    width: 0; /* This forces flex to calculate the width properly */
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--background-card);
    backdrop-filter: var(--blur-bg);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.mobile-sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 300;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

/* Content Sections */
.content-section {
    display: none;
    padding: 2rem;
}

.content-section.active {
    display: block;
}

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: var(--background-card);
    backdrop-filter: var(--blur-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-card);
    border-color: var(--primary-color);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.stat-info h3 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Dashboard Charts */
.dashboard-charts {
    display: grid;
    gap: 2rem;
}

.chart-card {
    background: var(--background-card);
    backdrop-filter: var(--blur-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    min-height: 300px;
}

.chart-card h3 {
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.chart-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-secondary);
    font-size: 3rem;
}

.chart-placeholder p {
    margin-top: 1rem;
    font-size: 1rem;
}

/* Section Header */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 400;
}

.add-btn {
    padding: 0.8rem 1.5rem;
    background: var(--gradient-accent);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

/* Search Container */
.search-container {
    margin-bottom: 2rem;
}

.search-box {
    position: relative;
    max-width: 400px;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
    z-index: 2;
}

.search-box input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 3rem;
    background: var(--background-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.2);
}

/* Responsive Tables */
.table-responsive {
    background: var(--background-card);
    backdrop-filter: var(--blur-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.data-table th {
    background: rgba(0, 212, 255, 0.1);
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    position: relative;
}

.data-table th:hover {
    background: rgba(0, 212, 255, 0.15);
}

.data-table th i {
    margin-left: 0.5rem;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.data-table th:hover i {
    opacity: 1;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.data-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.action-btn {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    margin-right: 0.5rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.edit-btn {
    background: rgba(0, 212, 255, 0.2);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.edit-btn:hover {
    background: var(--primary-color);
    color: white;
}

.delete-btn {
    background: rgba(255, 0, 128, 0.2);
    color: var(--secondary-color);
    border: 1px solid var(--secondary-color);
}

.delete-btn:hover {
    background: var(--secondary-color);
    color: white;
}

/* Status Badges */
.status-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    white-space: nowrap;
}

.status-badge.active {
    background: rgba(0, 255, 136, 0.2);
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
}

.status-badge.inactive {
    background: rgba(255, 0, 128, 0.2);
    color: var(--secondary-color);
    border: 1px solid var(--secondary-color);
}

.role-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    white-space: nowrap;
}

.role-badge.admin {
    background: rgba(255, 0, 128, 0.2);
    color: var(--secondary-color);
    border: 1px solid var(--secondary-color);
}

.role-badge.editor {
    background: rgba(0, 212, 255, 0.2);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.role-badge.user {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--background-card);
    backdrop-filter: var(--blur-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.modal form {
    padding: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.2);
}

/* Custom Select Styling */
.form-group select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300d4ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    background-size: 1rem;
    padding-right: 3rem;
    cursor: pointer;
}

.form-group select:hover {
    border-color: var(--primary-color);
}

.form-group select option {
    background: var(--background-dark);
    color: var(--text-primary);
    padding: 0.5rem;
    border: none;
}

.form-group select option:hover,
.form-group select option:focus,
.form-group select option:checked {
    background: var(--primary-color);
    color: white;
}

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 0.5rem;
    accent-color: var(--primary-color);
}

.form-group small {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 0.5rem;
    display: block;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.cancel-btn {
    padding: 0.8rem 1.5rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.cancel-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.save-btn {
    padding: 0.8rem 1.5rem;
    background: var(--gradient-primary);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
}

.sidebar-overlay.active {
    display: block;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    #adminPanel {
        position: relative;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 999;
        transition: transform 0.3s ease;
        transform: translateX(0);
    }
    
    .sidebar.mobile-open {
        transform: translateX(280px);
    }
        
    .sidebar.collapsed {
        width: 280px; /* Reset width on mobile */
    }
    
    .mobile-sidebar-toggle {
        display: block;
    }
    
    .header {
        padding: 1rem;
    }
    
    .header h1 {
        font-size: 1.4rem;
    }
    
    .content-section {
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .search-box {
        max-width: 100%;
    }
    
    .table-responsive {
        margin: 0 -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .data-table {
        min-width: 600px;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.8rem 0.5rem;
        font-size: 0.9rem;
    }
    
    .action-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.7rem;
        margin-right: 0.3rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .modal form {
        padding: 1.5rem;
    }
    
    .modal-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 2rem;
        margin: 1rem;
    }
    
    .stat-card {
        padding: 1.5rem;
        flex-direction: column;
        text-align: center;
    }
    
    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .stat-info h3 {
        font-size: 1.5rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.6rem 0.4rem;
        font-size: 0.8rem;
    }
    
    .action-btn {
        padding: 0.2rem 0.4rem;
        font-size: 0.6rem;
        margin-right: 0.2rem;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--gradient-primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Custom Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.slide-in {
    animation: slideIn 0.3s ease;
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* Loading States */
.loading {
    opacity: 0.5;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--primary-color);
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}