/* Admin Panel - Premium Glassmorphism Design */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --gradient-primary: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    --gradient-accent: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #fff;
    overflow-x: hidden;
}

/* Glassmorphism Container */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--glass-shadow);
    will-change: backdrop-filter, transform; /* Performance: help browser composite */
    transform: translateZ(0); /* Force GPU acceleration */
}

/* Layout */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    position: fixed;
    height: 100vh;
    padding: 30px 15px;
    z-index: 1000;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    text-align: center;
    margin-bottom: 35px;
    padding: 0 10px 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
    margin-bottom: 5px;
}

.sidebar-header p {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.nav-menu {
    list-style: none;
    flex-grow: 1;
}

.nav-item {
    margin-bottom: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 18px;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 0.95rem;
    position: relative;
    overflow: hidden;
}

.nav-link i {
    width: 24px;
    font-size: 1.1rem;
    margin-right: 12px;
    transition: transform 0.3s ease;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    padding-left: 22px;
}

.nav-link:hover i {
    transform: scale(1.2);
}

.nav-link.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(168, 85, 247, 0.2));
    color: #fff;
    border: 1px solid rgba(99, 102, 241, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    height: 60%;
    width: 4px;
    background: #6366f1;
    border-radius: 0 4px 4px 0;
    box-shadow: 0 0 10px #6366f1;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 30px;
}

/* Top Header */
.top-header {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    padding: 15px 25px;
    border-radius: 15px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--glass-border);
    position: relative;
}

.mobile-toggle {
    display: none;
    background: var(--gradient-primary);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
}

.header-left h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-left p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.admin-profile {
    display: flex;
    align-items: center;
    gap: 15px;
}

.admin-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
}

.admin-info h4 {
    font-size: 1rem;
    font-weight: 600;
}

.admin-info p {
    font-size: 0.8rem;
    color: var(--accent);
}

.btn-logout {
    background: var(--danger);
    color: #fff;
    border: none;
    padding: 10px 25px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-logout:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(239, 68, 68, 0.4);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    padding: 20px;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.25);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    font-size: 1.4rem;
}

.stat-icon.users { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.stat-icon.shares { background: linear-gradient(135deg, #06b6d4, #10b981); }
.stat-icon.storage { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.stat-icon.active { background: linear-gradient(135deg, #10b981, #06b6d4); }

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 3px;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    font-weight: 500;
}

.stat-change {
    margin-top: 10px;
    font-size: 0.85rem;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* Charts Section */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
    margin-bottom: 30px;
}

.chart-card {
    padding: 25px;
}

.chart-card h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.9);
}

.chart-container {
    position: relative;
    height: 300px;
}

/* Tables */
.table-container {
    padding: 15px;
    overflow-x: auto;
    width: 100%;
}

.table-scroll {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

/* Custom Scrollbar for Glassmorphism */
.table-scroll::-webkit-scrollbar {
    width: 6px;
}
.table-scroll::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}
.table-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}
.table-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.table-header h3 {
    font-size: 1.3rem;
}

.search-box {
    position: relative;
}

.search-box input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    padding: 10px 40px 10px 20px;
    border-radius: 10px;
    color: #fff;
    width: 300px;
}

.search-box input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

th {
    background: rgba(99, 102, 241, 0.2);
    font-weight: 600;
    color: var(--accent);
}

tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.status-badge {
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-badge.active { background: var(--success); }
.status-badge.blocked { background: var(--danger); }
.status-badge.pending { background: var(--warning); }

.action-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.action-btn {
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(5px);
}

.action-btn i {
    font-size: 1.1rem;
}

.action-btn.edit { background: rgba(99, 102, 241, 0.2); color: #6366f1; border-color: rgba(99, 102, 241, 0.3); }
.action-btn.delete { background: rgba(239, 68, 68, 0.2); color: #ef4444; border-color: rgba(239, 68, 68, 0.3); }
.action-btn.view { background: rgba(0, 255, 136, 0.15); color: #00ff88; border-color: rgba(0, 255, 136, 0.2); }
.action-btn.admin-toggle { background: rgba(168, 85, 247, 0.2); color: #a855f7; border-color: rgba(168, 85, 247, 0.3); }
.action-btn.premium-toggle { background: rgba(255, 255, 255, 0.05); color: rgba(255, 255, 255, 0.4); border-color: rgba(255, 255, 255, 0.1); }
.action-btn.premium-toggle.active { background: rgba(234, 179, 8, 0.2); color: #eab308; border-color: rgba(234, 179, 8, 0.3); }
.action-btn.premium-toggle.active:hover { background: #eab308; color: #1a1a2e; }

.action-btn:hover {
    transform: translateY(-3px) scale(1.1);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

.action-btn.edit:hover { background: #6366f1; color: #fff; }
.action-btn.delete:hover { background: #ef4444; color: #fff; }
.action-btn.view:hover { background: #00ff88; color: #1a1a2e; }

/* Settings Form */
.settings-section {
    padding: 30px;
}

.settings-section h3 {
    font-size: 1.3rem;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--glass-border);
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.form-control {
    width: 100%;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: #fff;
    font-size: 1rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.form-check input[type="checkbox"] {
    width: 25px;
    height: 25px;
    accent-color: var(--primary);
}

.btn-save {
    background: var(--gradient-primary);
    color: #fff;
    border: none;
    padding: 15px 40px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
}

.btn-save:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.5);
}

form[action="save_settings.php"] {
    text-align: center;
}

/* Settings Page */
.settings-wrapper {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    margin-bottom: 30px;
}

.settings-section.full-width {
    grid-column: 1 / -1;
}

.settings-section {
    display: flex;
    flex-direction: column;
    padding: 30px;
    height: 100%;
}

.settings-section h3 {
    font-size: 1.3rem;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--glass-border);
    color: var(--accent);
}

.settings-section .form-group {
    margin-bottom: 20px;
}

.settings-section .form-group:last-child {
    margin-bottom: 0;
}

/* Logs */
.log-entry {
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-bottom: 15px;
    border-left: 4px solid var(--primary);
}

.log-entry.warning { border-left-color: var(--warning); }
.log-entry.error { border-left-color: var(--danger); }
.log-entry.success { border-left-color: var(--success); }

.log-time {
    color: var(--accent);
    font-size: 0.85rem;
    margin-bottom: 5px;
}

.log-message {
    font-weight: 500;
}

.log-ip {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    margin-top: 5px;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
        padding: 20px 10px;
    }
    
    .sidebar-header h2 { font-size: 1.2rem; }
    .sidebar-header p { display: none; }
    
    .nav-link span { display: none; }
    .nav-link i { margin: 0; font-size: 1.5rem; }
    
    .main-content { margin-left: 80px; }
    
    .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { 
        transform: translateX(-100%); 
        width: 260px;
    }
    
    .sidebar.active {
        transform: translateX(0);
        box-shadow: 0 0 50px rgba(0,0,0,0.8);
    }

    .mobile-toggle {
        display: flex;
    }

    .main-content { 
        margin-left: 0 !important; 
        padding: 15px;
    }

    .top-header { 
        flex-direction: column; 
        align-items: flex-start;
        gap: 15px;
        padding: 15px;
    }
    
    .header-left {
        width: 100%;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 10px;
    }

    .stats-grid { grid-template-columns: 1fr; }
    
    .settings-wrapper { grid-template-columns: 1fr; }

    .btn-save {
        width: 100%;
        margin-top: 10px;
    }

    .search-box {
        width: 100%;
    }

    .search-box input {
        width: 100%;
    }
    
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .table-container {
        padding: 10px;
        margin: 0 -10px;
        width: calc(100% + 20px);
        border-radius: 0;
    }

    table {
        min-width: 600px; /* Force horizontal scroll for data density */
    }
}

@media (max-width: 480px) {
    .header-left h1 {
        font-size: 1.4rem;
    }

    .admin-profile {
        gap: 8px;
    }

    .admin-info {
        display: none;
    }
    
    .btn-logout {
        padding: 8px 15px;
        font-size: 0.85rem;
    }

    .stat-card {
        padding: 20px;
    }

    .stat-value {
        font-size: 2rem;
    }
}

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

.fade-in {
    animation: fadeIn 0.5s ease forwards;
    will-change: opacity, transform;
}

/* PERFORMANCE: New Keyframes moved from JS */
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Toast Styles moved from JS */
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    color: white;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    z-index: 10000;
}

.toast-success { background: #10b981; }
.toast-error { background: #ef4444; }

/* Performance hint for long content */
.stats-grid, table, .table-container {
    content-visibility: auto;
    contain-intrinsic-size: 0 400px;
}


/* Tooltips */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: var(--primary);
    color: #fff;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    z-index: 1000;
}

/* Loading Spinner */
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
/* Tier Cards in Settings */
.tier-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 10px;
}

.tier-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.tier-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.tier-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tier-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.tier-card.free .tier-icon { background: rgba(255, 255, 255, 0.1); color: #fff; }
.tier-card.basic .tier-icon { background: rgba(0, 217, 255, 0.1); color: #00d9ff; }
.tier-card.premium .tier-icon { background: rgba(240, 194, 77, 0.1); color: #f0c24d; }

.tier-card h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.tier-card.free h4 { color: #fff; }
.tier-card.basic h4 { color: #00d9ff; }
.tier-card.premium h4 { color: #f0c24d; }

.tier-card .form-group {
    margin-bottom: 15px;
}

.tier-card .form-group:last-child {
    margin-bottom: 0;
}

.tier-card label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
}

.tier-card .form-control {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.05);
}

.tier-card .form-control:focus {
    background: rgba(0, 0, 0, 0.3);
}

@media (max-width: 1200px) {
    .tier-cards-container {
        grid-template-columns: 1fr;
    }
}
