:root {
    --sidebar-width: 260px;
    --header-height: 64px;
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --sidebar-bg: #1e1b4b;
    --sidebar-text: #c7d2fe;
    --sidebar-active: #4f46e5;
    --body-bg: #f1f5f9;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --transition: 0.2s ease;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--body-bg);
    color: #1e293b;
    margin: 0;
    min-height: 100vh;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform var(--transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand i {
    font-size: 1.5rem;
    color: #a5b4fc;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 0.5rem;
    margin-bottom: 0.25rem;
    transition: background var(--transition), color var(--transition);
    font-size: 0.9375rem;
}

.sidebar-nav .nav-link:hover:not(.disabled) {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
}

.sidebar-nav .nav-link.disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
}

.sidebar-nav .nav-link i {
    font-size: 1.125rem;
    width: 1.25rem;
    text-align: center;
}

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-footer .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #fca5a5;
    text-decoration: none;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    transition: background var(--transition);
}

.sidebar-footer .nav-link:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fecaca;
}

/* ============================================================
   Main Content
   ============================================================ */
.main-content {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content-full {
    min-height: 100vh;
}

.top-header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    z-index: 1030;
    box-shadow: var(--card-shadow);
}

.header-title h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: #1e293b;
}

.header-user {
    margin-right: auto;
}

.user-dropdown {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    border: 1px solid #e2e8f0;
}

.sidebar-toggle {
    font-size: 1.5rem;
    color: #475569;
    padding: 0.25rem;
}

.content-wrapper {
    padding: 1.5rem;
    flex: 1;
}

/* ============================================================
   Login Page
   ============================================================ */
.login-page {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4f46e5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 1.5rem;
}

.login-card {
    background: #fff;
    border-radius: 1rem;
    padding: 2.5rem 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.75rem;
    color: #fff;
}

.login-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: #1e293b;
}

.login-header p {
    font-size: 0.875rem;
}

.input-group-text {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #64748b;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.15);
}

.btn-login {
    background: var(--primary-color);
    border-color: var(--primary-color);
    padding: 0.75rem;
    font-weight: 600;
    font-size: 0.9375rem;
    transition: background var(--transition);
}

.btn-login:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* ============================================================
   Dashboard Cards
   ============================================================ */
.welcome-card {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    border-radius: 1rem;
    padding: 2rem;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.3);
}

.welcome-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.welcome-content p {
    color: rgba(255, 255, 255, 0.85);
}

.welcome-icon {
    font-size: 4rem;
    opacity: 0.3;
}

.stat-card {
    background: #fff;
    border-radius: 0.75rem;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--card-shadow);
    transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-label {
    display: block;
    font-size: 0.8125rem;
    color: #64748b;
    margin-bottom: 0.125rem;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
}

.stat-meta {
    display: block;
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 0.125rem;
}

.panel-card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: var(--card-shadow);
}

.panel-card .card-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 1.25rem;
    border-radius: 0.75rem 0.75rem 0 0;
}

.panel-card .card-title {
    font-size: 1rem;
    font-weight: 600;
}

.session-table td {
    padding: 0.625rem 0;
    vertical-align: middle;
}

/* ============================================================
   Data Tables
   ============================================================ */
.data-table {
    font-size: 0.875rem;
}

.data-table thead th {
    background: #f8fafc;
    color: #64748b;
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.75rem 1.25rem;
    white-space: nowrap;
}

.data-table tbody td {
    padding: 0.875rem 1.25rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.activity-user {
    display: inline-flex;
    align-items: center;
    font-weight: 500;
}

.ip-code {
    font-size: 0.8125rem;
    color: #64748b;
    background: #f1f5f9;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
}

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state i {
    font-size: 2.5rem;
    color: #cbd5e1;
    margin-bottom: 0.75rem;
    display: block;
}

.empty-state p {
    font-weight: 500;
    color: #64748b;
    margin-bottom: 0.25rem;
}

/* ============================================================
   CRUD Pages
   ============================================================ */
.page-actions {
    display: flex;
    flex-direction: column;
}

.table-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 0.375rem;
}

.table-thumb-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #f1f5f9;
    border-radius: 0.375rem;
    color: #94a3b8;
}

.preview-image {
    max-width: 120px;
    max-height: 120px;
    object-fit: cover;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
}

.text-truncate-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-section {
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
}

.settings-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.settings-section-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 1rem;
}

.ad-type-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1rem;
}

/* ============================================================
   Utilities
   ============================================================ */
.alert {
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

.badge {
    font-weight: 500;
    font-size: 0.75rem;
}

/* Purple color utilities for stat cards */
.bg-purple-subtle {
    background-color: #ede9fe;
}

.text-purple {
    color: #7c3aed;
}

/* Sidebar footer: contextual link colors */
.sidebar-footer .nav-link.text-warning {
    color: #fbbf24;
}

.sidebar-footer .nav-link.text-warning:hover {
    background: rgba(251, 191, 36, 0.15);
    color: #fde68a;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-right: 0;
    }

    .welcome-card {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .welcome-icon {
        font-size: 3rem;
    }
}

@media (max-width: 575.98px) {
    .content-wrapper {
        padding: 1rem;
    }

    .login-card {
        padding: 2rem 1.5rem;
    }
}
