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

:root {
    --bg-dark: #090a0f;
    --bg-card: rgba(16, 20, 35, 0.65);
    --bg-card-hover: rgba(22, 28, 48, 0.8);
    --border-glass: rgba(255, 255, 255, 0.07);
    --border-glass-active: rgba(139, 92, 246, 0.4);
    
    --primary: #8b5cf6;
    --primary-glow: rgba(139, 92, 246, 0.3);
    --primary-grad: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    
    --secondary: #3b82f6;
    --secondary-grad: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.2);
    
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.2);
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dark: #1f2937;
    
    --sidebar-width: 260px;
    --transition-speed: 0.3s;
    
    --font-en: 'Outfit', sans-serif;
    --font-ar: 'Cairo', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-ar), var(--font-en);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.08) 0%, transparent 40%);
    background-attachment: fixed;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Glassmorphism utility */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: all var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-panel:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

/* Authentication Layout */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 450px;
    padding: 40px 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(139,92,246,0.15) 0%, transparent 50%);
    z-index: -1;
    pointer-events: none;
}

.auth-logo {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 30px;
    background: var(--primary-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
}

/* Form inputs */
.form-group {
    margin-bottom: 20px;
    text-align: right;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: #fff;
    font-size: 15px;
    outline: none;
    font-family: inherit;
    transition: all 0.2s ease;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
    background: rgba(255, 255, 255, 0.08);
}

.form-checkbox {
    accent-color: var(--primary);
    margin-left: 8px;
    vertical-align: middle;
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 24px;
    background: var(--primary-grad);
    border: none;
    border-radius: 8px;
    color: #white;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--primary-glow);
    font-family: inherit;
    text-decoration: none;
}

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

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: var(--text-main);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background: var(--danger);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
    box-shadow: 0 4px 10px var(--danger-glow);
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(239, 68, 68, 0.4);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 6px;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    right: 0; /* RTL alignment by default */
    z-index: 100;
    padding: 24px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-glass);
    border-radius: 0;
}

.sidebar-brand {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 40px;
    background: var(--primary-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
    flex-shrink: 0;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-link.active {
    color: #white;
    background: var(--primary-grad);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border-glass);
    padding-top: 20px;
    flex-shrink: 0;
}

/* Main Content Area */
.main-content {
    margin-right: var(--sidebar-width); /* Push content to left since sidebar is on right in RTL */
    flex-grow: 1;
    padding: 40px;
    min-height: 100vh;
    transition: all var(--transition-speed) ease;
}

/* Header */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 35px;
}

.page-title {
    font-size: 26px;
    font-weight: 700;
    color: #fff;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary-grad);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #white;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

/* Grid & Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 35px;
}

.stat-card {
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-grad);
    opacity: 0.7;
}

.stat-card.blue::after {
    background: var(--secondary-grad);
}

.stat-card.green::after {
    background: var(--success);
}

.stat-card.orange::after {
    background: var(--warning);
}

.stat-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: block;
}

.stat-val {
    font-size: 28px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 4px;
    font-family: var(--font-en);
}

.stat-sub {
    font-size: 12px;
    color: var(--text-muted);
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 35px;
}

@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    padding: 24px;
    min-height: 350px;
}

.chart-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    margin-top: 15px;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

.custom-table th {
    padding: 16px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 14px;
    border-bottom: 1px solid var(--border-glass);
    background: rgba(255, 255, 255, 0.02);
}

.custom-table td {
    padding: 16px;
    color: #e5e7eb;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.custom-table tbody tr {
    transition: all 0.2s ease;
}

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

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

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

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

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    font-weight: 600;
    font-size: 14px;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

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

/* Filters Bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 20px;
    margin-bottom: 30px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
    min-width: 150px;
}

/* Actions cell alignment */
.actions-cell {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
}

/* Custom Pagination styles */
.pagination-container {
    margin-top: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 14px;
}

.pagination-links {
    display: flex;
    gap: 5px;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.pagination-link:hover, .pagination-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.pagination-link.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* API Token container inside License management */
.token-container {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    padding: 10px 14px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 300px;
    gap: 10px;
}

.token-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #6366f1;
}

.btn-copy {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

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

/* =========================================================
   Mobile: Off-canvas sidebar drawer
   ========================================================= */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 199;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* Mobile hamburger button — hidden on desktop */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-main);
    transition: background 0.2s;
    margin-left: 12px;
    flex-shrink: 0;
}

.mobile-menu-btn:hover {
    background: rgba(255, 255, 255, 0.14);
}

@media (max-width: 768px) {
    /* Show the hamburger button */
    .mobile-menu-btn {
        display: flex;
    }

    /* Sidebar becomes a fixed off-canvas panel */
    .sidebar {
        position: fixed;
        top: 0;
        right: -280px; /* hidden off-screen to the right */
        width: 280px;
        height: 100vh;
        height: 100dvh;
        z-index: 200;
        transition: right 0.32s cubic-bezier(0.4, 0, 0.2, 1);
        border-left: 1px solid var(--border-glass);
        border-radius: 0;
        overflow-y: auto;
        padding-bottom: 80px; /* Extra padding to ensure scrolling past browser bars on mobile */
    }

    /* Class added by JS when open */
    .sidebar.sidebar-open {
        right: 0;
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
    }

    /* Content fills full width */
    .main-content {
        margin-right: 0;
        padding: 20px;
    }

    .dashboard-container {
        flex-direction: column;
    }

    .dashboard-header {
        flex-wrap: wrap;
        gap: 12px;
    }

    .page-title {
        font-size: 20px;
    }
}


/* Glassmorphism Modal overlay and card styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(4, 5, 9, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    width: 90%;
    max-width: 850px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 30px;
    border-radius: 16px;
    background: rgba(16, 20, 35, 0.95);
    border: 1px solid var(--border-glass-active);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    transform: scale(0.9);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
}

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

/* =========================================================
   Sticky table column – keeps the action button pinned
   to the right (RTL) while the rest of the row scrolls.
   Apply .sticky-col to <th> and <td> of the target column.
   ========================================================= */
.sticky-col {
    position: sticky;
    right: 0;
    background: rgba(16, 20, 35, 0.97);
    z-index: 2;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.4);
}

thead .sticky-col {
    background: rgba(12, 15, 28, 0.98);
    z-index: 3;
}

/* Remove shadow on desktop – not needed */
@media (min-width: 769px) {
    .sticky-col {
        box-shadow: none;
    }
}
