:root {
    /* Premium Color Palette */
    --bg-main: #0f172a;        /* Slate 900 */
    --bg-sidebar: #0b1120;     /* Slate 950 */
    --bg-card: rgba(30, 41, 59, 0.7); /* Slate 800 with opacity */
    
    --primary: #3b82f6;        /* Blue 500 */
    --primary-hover: #2563eb;  /* Blue 600 */
    --accent: #f59e0b;         /* Amber/Gold 500 */
    --accent-hover: #d97706;   
    
    --success: #10b981;        /* Emerald 500 */
    --danger: #ef4444;         /* Red 500 */
    --whatsapp: #25D366;
    
    --text-primary: #f8fafc;   /* Slate 50 */
    --text-secondary: #94a3b8; /* Slate 400 */
    
    --border-color: rgba(148, 163, 184, 0.1);
    --glass-border: rgba(255, 255, 255, 0.05);
    --card-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', 'Cairo', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(245, 158, 11, 0.05) 0%, transparent 50%);
}

/* Glassmorphism */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
}

/* Layout */
.dashboard-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

/* Authentication Overlay */
.login-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-main);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
}
.login-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.login-card {
    width: 400px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    border-color: rgba(59, 130, 246, 0.3);
}
.text-center { text-align: center; }
.mx-auto { margin-left: auto; margin-right: auto; }
.gap-0 { gap: 0 !important; }
.mr-2 { margin-right: 10px; }

.admin-only {
    display: none !important;
}

.brand {
    padding: 25px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.brand-text h2 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.brand-text span {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.nav-section {
    padding: 10px 25px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 1px;
    font-weight: 700;
    margin-top: 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 25px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
    border-right: 3px solid transparent;
}

.nav-link i {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.nav-link:hover, .nav-link.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    border-right-color: var(--primary);
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.15) 0%, transparent 100%);
}

.sidebar-widget {
    margin: 20px;
    padding: 15px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
}

.widget-icon {
    color: var(--success);
    font-size: 24px;
}

.widget-info h4 {
    font-size: 13px;
    color: var(--success);
    margin-bottom: 2px;
}

.widget-info p {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Topbar */
.topbar {
    height: 70px;
    padding: 0 30px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar-search {
    display: flex;
    align-items: center;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 15px;
    width: 300px;
    transition: var(--transition);
}

.topbar-search:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.topbar-search i {
    color: var(--text-secondary);
    margin-left: 10px;
}

.topbar-search input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    outline: none;
    width: 100%;
    font-size: 14px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(30, 41, 59, 0.8);
    padding: 6px 15px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    font-size: 13px;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--danger);
    box-shadow: 0 0 8px var(--danger);
}

.status-pill.ready .status-dot {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}

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

.avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

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

.user-name {
    font-size: 13px;
    font-weight: 700;
}

.user-role {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Content Wrapper */
.content-wrapper {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.tab-pane {
    display: none;
    animation: fadeUp 0.4s ease-out forwards;
}

.tab-pane.active {
    display: block;
}

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

/* Page Headers */
.page-header {
    margin-bottom: 30px;
}

.page-title {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 5px;
    background: linear-gradient(to left, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 15px;
}

/* Grid Layouts */
.grid-layout {
    display: grid;
    gap: 25px;
}

.bulk-search-grid {
    grid-template-columns: 350px 1fr;
}

.quote-grid {
    grid-template-columns: 400px 1fr;
}

/* Cards */
.card {
    display: flex;
    flex-direction: column;
    border-radius: var(--border-radius);
}

.card-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.3);
}

.card-header h3 {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header h3 i {
    color: var(--primary);
}

.card-body {
    padding: 25px;
    flex: 1;
}

.card-footer {
    padding: 15px 25px;
    border-top: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.3);
    display: flex;
    justify-content: flex-end;
}

.border-accent {
    border-top: 3px solid var(--accent);
}

/* Forms & Inputs */
.form-row {
    display: flex;
    gap: 15px;
}

.w-50 { width: 50%; }
.w-100 { width: 100%; }
.mt-3 { margin-top: 15px; }
.mt-4 { margin-top: 25px; }
.mb-3 { margin-bottom: 15px; }
.mb-4 { margin-bottom: 25px; }
.ml-2 { margin-right: 10px; } /* RTL so margin-left logic is right */
.p-0 { padding: 0; }
.gap-20 { display: flex; flex-direction: column; gap: 20px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    right: 15px;
    color: var(--text-secondary);
    z-index: 2;
}

.premium-input {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 40px 12px 15px; /* RTL right padding for icon */
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
    outline: none;
}

.premium-textarea {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: monospace;
    resize: none;
    transition: var(--transition);
    outline: none;
    line-height: 1.6;
}

.premium-input:focus, .premium-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    background: rgba(15, 23, 42, 0.9);
}

.help-text {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.btn-lg {
    padding: 14px 24px;
    font-size: 15px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(59, 130, 246, 0.4);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #0ea5e9; /* a nicer green/blue transition */
    transform: translateY(-2px);
}

.btn-whatsapp {
    background: var(--whatsapp);
    color: white;
}

.btn-whatsapp:hover {
    background: #1ebc5a;
    transform: translateY(-2px);
}

.btn-outline-danger {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}

.btn-outline-danger:hover {
    background: var(--danger);
    color: white;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

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

.icon-btn.tooltip {
    position: relative;
}
.icon-btn.tooltip::after {
    content: attr(data-tip);
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: 0.2s;
}
.icon-btn.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
    top: -40px;
}

.text-danger { color: var(--danger); }
.text-whatsapp { color: var(--whatsapp); }
.text-info { color: #0dcaf0; }
.text-primary { color: var(--primary); }

/* Badges */
.badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}
.badge-success { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.badge-danger { background: rgba(239, 68, 68, 0.2); color: var(--danger); }

/* Tables */
.table-container {
    overflow-x: auto;
    max-height: 500px;
}

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

.premium-table th {
    background: rgba(15, 23, 42, 0.8);
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    padding: 15px 20px;
    text-align: right;
    position: sticky;
    top: 0;
    z-index: 10;
}

.premium-table td {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    vertical-align: middle;
}

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

.premium-table tbody tr:hover:not(.empty-state) {
    background: rgba(255, 255, 255, 0.02);
}

.empty-box {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.empty-box i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.3;
}

/* Invoice Specific */
.invoice-card {
    display: flex;
    flex-direction: column;
}

.invoice-header {
    background: linear-gradient(90deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.9));
}

.invoice-actions {
    display: flex;
    gap: 10px;
}

.invoice-body {
    flex: 1;
    min-height: 400px;
    overflow-y: auto;
}

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

.invoice-table th {
    padding: 12px 20px;
    text-align: right;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    font-size: 13px;
}

.invoice-table td {
    padding: 15px 20px;
    border-bottom: 1px dashed var(--border-color);
}

.invoice-footer {
    padding: 20px 25px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--primary);
}

.invoice-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 20px;
    font-weight: 800;
}

.total-value {
    color: var(--accent);
    font-size: 28px;
}

/* Admin / Upload */
.admin-container {
    max-width: 800px;
    margin: 0 auto;
}

.upload-card {
    text-align: center;
    padding: 40px;
}

.upload-icon {
    font-size: 64px;
    color: var(--primary);
    margin-bottom: 20px;
    text-shadow: 0 10px 30px rgba(59, 130, 246, 0.5);
}

.upload-card h2 {
    margin-bottom: 15px;
}

.upload-card p {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.hidden-input { display: none; }

.upload-wrapper {
    border: 2px dashed var(--border-color);
    padding: 40px;
    border-radius: 16px;
    background: rgba(0,0,0,0.2);
    transition: var(--transition);
}

.upload-wrapper:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.progress-section {
    background: rgba(15, 23, 42, 0.8);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.progress-section.hidden {
    display: none;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 14px;
}

.progress-track {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), #0ea5e9);
    transition: width 0.3s ease;
}

.log-viewer {
    max-height: 120px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: right;
    padding: 10px;
    background: rgba(0,0,0,0.3);
    border-radius: 6px;
}

.stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.stat-box {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 60px;
    height: 60px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.stat-content h5 {
    color: var(--text-secondary);
    font-weight: 600;
}

.stat-content h2 {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
}

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

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    padding: 30px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    animation: fadeUp 0.3s ease-out;
}

.modal-header {
    text-align: center;
    margin-bottom: 25px;
}

.modal-header h3 {
    color: var(--primary);
    font-size: 20px;
    margin-bottom: 5px;
}

.modal-header p {
    color: var(--text-secondary);
    font-size: 13px;
}

.modal-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-btn {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: right;
}

.modal-btn i {
    font-size: 20px;
    width: 25px;
    text-align: center;
}

.modal-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.modal-btn.pdf-btn i { color: var(--danger); }
.modal-btn.text-btn i { color: var(--success); }

.modal-close {
    margin-top: 20px;
    width: 100%;
    padding: 12px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 600;
}

.modal-close:hover {
    color: var(--danger);
}

/* Print Layout & Professional PDF */
.print-layout {
    display: none;
    background: #fff;
    color: #1e293b;
    padding: 40px;
    font-family: 'Cairo', sans-serif;
    direction: rtl;
}

@media print {
    body * { visibility: hidden; }
    .print-layout, .print-layout * { visibility: visible; }
    .print-layout {
        display: block;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        min-height: 100vh;
        margin: 0;
        padding: 40px 50px;
        box-sizing: border-box;
    }
    
    .print-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 3px solid #3b82f6;
        padding-bottom: 20px;
        margin-bottom: 30px;
    }
    
    .print-logo-area h2 {
        font-size: 32px;
        color: #1e293b;
        margin-bottom: 5px;
        font-weight: 800;
    }
    .print-logo-area p {
        color: #64748b;
        font-size: 14px;
    }
    
    .print-invoice-title {
        text-align: left;
    }
    .print-invoice-title h1 {
        font-size: 28px;
        color: #3b82f6;
        margin-bottom: 5px;
    }
    
    .print-info-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        background: #f8fafc;
        padding: 20px;
        border-radius: 10px;
        margin-bottom: 30px;
        border: 1px solid #e2e8f0;
    }
    
    .info-item {
        display: flex;
        flex-direction: column;
    }
    .info-item span.label {
        font-size: 12px;
        color: #64748b;
        margin-bottom: 4px;
        text-transform: uppercase;
    }
    .info-item span.value {
        font-size: 16px;
        font-weight: 700;
        color: #0f172a;
    }

    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 40px;
    }
    .print-table th {
        background: #3b82f6 !important;
        color: #fff !important;
        padding: 15px;
        text-align: right;
        font-size: 14px;
        -webkit-print-color-adjust: exact;
    }
    .print-table td {
        padding: 15px;
        border-bottom: 1px solid #e2e8f0;
        font-size: 14px;
        color: #334155;
    }
    .print-table tbody tr:nth-child(even) td {
        background: #f8fafc !important;
        -webkit-print-color-adjust: exact;
    }
    
    .print-footer-section {
        display: flex;
        justify-content: flex-end;
    }
    
    .print-total-box {
        background: #f1f5f9;
        padding: 20px 40px;
        border-radius: 10px;
        text-align: left;
        border: 1px solid #cbd5e1;
        -webkit-print-color-adjust: exact;
    }
    
    .print-total-box h3 {
        font-size: 16px;
        color: #64748b;
        margin-bottom: 10px;
    }
    
    .print-total-box .print-total-val {
        font-size: 32px;
        font-weight: 800;
        color: #0f172a;
    }
}
