/* ==========================================================================
   Easyplex Downloader: Premium Dark Glassmorphism Styling System
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Color Palette */
    --bg-main: #060814;
    --bg-card: rgba(13, 17, 39, 0.5);
    --bg-sidebar: rgba(8, 10, 26, 0.7);
    --border-glass: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(139, 92, 246, 0.2);
    
    /* Neon Colors */
    --primary: #8b5cf6;       /* Violet / Neon Purple */
    --primary-glow: rgba(139, 92, 246, 0.5);
    --secondary: #6366f1;     /* Indigo */
    --secondary-glow: rgba(99, 102, 241, 0.5);
    
    --success: #10b981;       /* Emerald Green */
    --success-glow: rgba(16, 185, 129, 0.3);
    --warning: #f59e0b;       /* Amber */
    --warning-glow: rgba(245, 158, 11, 0.3);
    --danger: #ef4444;        /* Rose Red */
    --danger-glow: rgba(239, 68, 68, 0.3);
    
    /* Text Colors */
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dark: #6b7280;
    
    /* Glassmorphism Specs */
    --blur: 20px;
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 40%);
    /* NOTE: background-attachment: fixed removed — it conflicts with overflow-x: hidden
       and creates a new stacking context that breaks fixed/sticky positioned children */
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.2);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.4);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    color: #a78bfa;
}

/* ==========================================================================
   Layout Scaffolding
   ========================================================================== */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100vw;
    overflow-x: hidden; /* moved from body to prevent stacking context issues */
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    backdrop-filter: blur(var(--blur));
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
}

.brand-wrapper {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-glass);
}

.brand-logo-img {
    height: 38px;
    object-fit: contain;
}

.brand-name {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #fff 30%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    list-style: none;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
    overflow-y: auto;
}

.nav-item-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
}

.nav-item-link:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
    transform: translateX(4px);
}

.nav-item-link.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(99, 102, 241, 0.15) 100%);
    border-left: 3px solid var(--primary);
    box-shadow: inset 0 0 15px rgba(139, 92, 246, 0.08);
}

.nav-item-link svg {
    width: 20px;
    height: 20px;
    transition: var(--transition);
}

.nav-item-link.active svg {
    color: var(--primary);
    filter: drop-shadow(0 0 5px var(--primary-glow));
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-glass);
}

.btn-logout {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-radius: var(--radius-md);
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 4px 15px var(--danger-glow);
}

/* Main Panel Styling */
.main-panel {
    margin-left: 260px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top Header Styling */
.top-header {
    height: 70px;
    background: rgba(6, 8, 20, 0.5);
    backdrop-filter: blur(var(--blur));
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.admin-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 50px;
}

.profile-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
}

.profile-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
}

/* Content Area */
.content-wrapper {
    padding: 32px;
    flex-grow: 1;
}

/* ==========================================================================
   UI Components: Cards, Tables, Forms
   ========================================================================= */

/* Premium Glass Card */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(var(--blur));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.glass-card:hover {
    border-color: rgba(139, 92, 246, 0.15);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -150%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        to right,
        transparent,
        rgba(255, 255, 255, 0.03),
        transparent
    );
    transform: skewX(-25deg);
    transition: 0.75s;
    pointer-events: none; /* prevent decorative shimmer from blocking clicks */
    z-index: 0;
}

.glass-card:hover::before {
    left: 150%;
}

.glass-card > * {
    position: relative;
    z-index: 1; /* ensure card content is always above the ::before shimmer */
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 12px;
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

@media (max-width: 1024px) {
    .grid-3, .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 70px;
    }
    .sidebar .brand-name, .sidebar .profile-name, .sidebar .nav-item-link span {
        display: none;
    }
    .main-panel {
        margin-left: 70px;
    }
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* Widgets / Stats Card */
.stat-widget {
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    color: var(--primary);
    transition: var(--transition);
}

.stat-widget:hover .stat-icon {
    transform: scale(1.1) rotate(5deg);
    border-color: var(--primary-glow);
}

.stat-icon.primary { color: var(--primary); background: rgba(139, 92, 246, 0.06); }
.stat-icon.secondary { color: var(--secondary); background: rgba(99, 102, 241, 0.06); }
.stat-icon.success { color: var(--success); background: rgba(16, 185, 129, 0.06); }
.stat-icon.danger { color: var(--danger); background: rgba(239, 68, 68, 0.06); }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ==========================================================================
   Premium Form Controls
   ========================================================================== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 0.95rem;
    color: #fff;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    transition: var(--transition);
    outline: none;
}

.form-control option {
    background-color: #0d1127;
    color: #fff;
}

.form-control::placeholder {
    color: var(--text-dark);
}

.form-control:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.04);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.15);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* Toggle Switches */
.switch-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.switch-label {
    display: flex;
    flex-direction: column;
}

.switch-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
}

.switch-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.08);
    transition: .3s;
    border-radius: 34px;
    border: 1px solid var(--border-glass);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-muted);
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: rgba(139, 92, 246, 0.2);
    border-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(22px);
    background-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    outline: none;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

/* File Upload input */
.file-upload-wrapper {
    position: relative;
    border: 2px dashed var(--border-glass);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.file-upload-wrapper:hover {
    border-color: var(--primary-glow);
    background: rgba(255, 255, 255, 0.01);
}

.file-upload-input {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-upload-icon {
    font-size: 1.75rem;
    color: var(--primary);
    margin-bottom: 8px;
}

.file-upload-text {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Tab Navigation System
   ========================================================================== */
.tabs-navigation {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 10px;
}

.tab-btn {
    padding: 10px 20px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.tab-btn:hover {
    color: #fff;
}

.tab-btn.active {
    color: var(--primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -11px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

/* ==========================================================================
   Beautiful Responsive Data Tables
   ========================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.premium-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.premium-table th {
    padding: 16px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-glass);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
}

.premium-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-glass);
    color: var(--text-main);
    transition: var(--transition);
}

.premium-table tbody tr {
    transition: var(--transition);
}

.premium-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.015);
    color: #fff;
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-pending {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

.badge-resolved {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

.badge-active {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success);
    color: #6ee7b7;
}

.badge-inactive {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: #fca5a5;
}

/* ==========================================================================
   Authentication Login Screen
   ========================================================================== */
.auth-wrapper {
    min-height: 100vh;
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.08) 0%, transparent 50%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    backdrop-filter: blur(var(--blur));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-logo {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo-img {
    height: 60px;
    margin-bottom: 12px;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    text-align: center;
    margin-bottom: 6px;
}

.auth-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 32px;
}

/* Alerts System */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: shake 0.4s ease;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.alert-success {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

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

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Action controls styling */
.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-glass);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    color: #fff;
}

.btn-icon.success:hover {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success);
    color: var(--success);
}

.btn-icon.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 2.5rem;
    color: var(--primary-glow);
    margin-bottom: 12px;
}

/* ==========================================================================
   Premium Light Mode Glassmorphism Style Variables & Overrides
   ========================================================================== */
[data-theme="light"] {
    /* Color Palette - Light Mode */
    --bg-main: #f5f7fb;
    --bg-card: rgba(255, 255, 255, 0.45);
    --bg-sidebar: rgba(243, 244, 246, 0.85);
    --border-glass: rgba(0, 0, 0, 0.08);
    --border-glow: rgba(139, 92, 246, 0.15);
    
    /* Text Colors - Light Mode */
    --text-main: #1f2937;
    --text-muted: #4b5563;
    --text-dark: #8c96a3;
}

[data-theme="light"] body {
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.02) 0%, transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(139, 92, 246, 0.03) 0%, transparent 40%);
}

[data-theme="light"] .top-header {
    background: rgba(255, 255, 255, 0.5);
}

[data-theme="light"] .admin-profile {
    background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .card-title,
[data-theme="light"] .stat-value,
[data-theme="light"] .form-control {
    color: #1f2937 !important;
}

[data-theme="light"] .form-control {
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .form-control:focus {
    background: rgba(0, 0, 0, 0.03);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.08);
}

[data-theme="light"] .switch-group {
    background: rgba(0, 0, 0, 0.01);
}

[data-theme="light"] .switch-title {
    color: #1f2937;
}

[data-theme="light"] .slider {
    background-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .btn-secondary {
    background: rgba(0, 0, 0, 0.04);
    color: #1f2937;
}

[data-theme="light"] .btn-secondary:hover {
    background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .tab-btn:hover {
    color: #1f2937;
}

[data-theme="light"] .tab-btn.active {
    color: var(--primary);
}

[data-theme="light"] .api-row,
[data-theme="light"] .endpoint-item,
[data-theme="light"] .edit-box,
[data-theme="light"] .empty {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .bar-track {
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] table.premium-table tbody tr:hover td {
    background: rgba(0, 0, 0, 0.015);
    color: #000;
}

/* Dynamic Selector: Convert all inline styles having white text to dark-gray/black in light mode */
[data-theme="light"] [style*="color: #fff"], 
[data-theme="light"] [style*="color:#fff"],
[data-theme="light"] [style*="color: #ffffff"], 
[data-theme="light"] [style*="color:#ffffff"] {
    color: #1f2937 !important;
}

/* Sidebar Active Highlighting in light mode */
[data-theme="light"] .nav-item-link.active {
    color: var(--primary) !important;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(99, 102, 241, 0.08) 100%) !important;
    border-left: 3px solid var(--primary);
}

/* Brand logo text gradient in light mode */
[data-theme="light"] .brand-name {
    background: linear-gradient(135deg, #1f2937 30%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Dropdown Option List styling in light mode */
[data-theme="light"] .form-control option {
    background-color: #ffffff;
    color: #1f2937;
}

