@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('../fonts/cairo-300.ttf') format('truetype');
}
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/cairo-400.ttf') format('truetype');
}
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/cairo-500.ttf') format('truetype');
}
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/cairo-600.ttf') format('truetype');
}
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/cairo-700.ttf') format('truetype');
}
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('../fonts/cairo-800.ttf') format('truetype');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('../fonts/outfit-300.ttf') format('truetype');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/outfit-400.ttf') format('truetype');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/outfit-500.ttf') format('truetype');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/outfit-600.ttf') format('truetype');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/outfit-700.ttf') format('truetype');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('../fonts/outfit-800.ttf') format('truetype');
}

:root {
    --bg-base: #F8F5F0;
    --bg-card: #FFFFFF;
    --bg-sidebar: #2D1E1B;
    --bg-sidebar-active: #422D28;
    --color-primary: #C05621; /* Terracotta / Copper */
    --color-primary-hover: #9C3D12;
    --color-primary-light: #FEEBC8;
    --color-text: #2D3748;
    --color-text-muted: #718096;
    --color-border: #E2E8F0;
    --color-success: #2F855A;
    --color-success-light: #C6F6D5;
    --color-warning: #DD6B20;
    --color-warning-light: #FEEBC8;
    --color-danger: #C53030;
    --color-danger-light: #FED7D7;
    --font-arabic: 'Cairo', sans-serif;
    --font-english: 'Outfit', sans-serif;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --sidebar-width: 260px;
    --header-height: 70px;
}

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

body {
    font-family: var(--font-arabic);
    background-color: var(--bg-base);
    color: var(--color-text);
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
    background: #CBD5E0;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #A0AEC0;
}

/* Master Layout */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    color: #F7FAFC;
    height: 100vh;
    position: fixed;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: flex-column;
    z-index: 100;
    transition: all 0.3s ease;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    flex-direction: column;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: #FFF;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 10px;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-menu li {
    margin-bottom: 5px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: #E2E8F0;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    gap: 12px;
}

.sidebar-menu a:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #FFF;
}

.sidebar-menu li.active a {
    background-color: var(--color-primary);
    color: #FFF;
    font-weight: 600;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.05);
    font-size: 12px;
    color: #A0AEC0;
    text-align: center;
}

/* Main Content Area */
.main-wrapper {
    flex-grow: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: calc(100% - var(--sidebar-width));
}

/* Header */
.main-header {
    height: var(--header-height);
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: var(--shadow-sm);
}

.header-title h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info {
    text-align: left;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

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

.btn-logout {
    padding: 8px 15px;
    background-color: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-danger);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-logout:hover {
    background-color: var(--color-danger-light);
    border-color: var(--color-danger-light);
}

/* Main Body */
.main-content {
    padding: 30px;
    flex-grow: 1;
}

/* Dashboard Summary Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.metric-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--color-text);
    font-family: var(--font-english);
    line-height: 1;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background-color: var(--color-primary);
}

.metric-card.success::before { background-color: var(--color-success); }
.metric-card.warning::before { background-color: var(--color-warning); }
.metric-card.danger::before { background-color: var(--color-danger); }

/* Common Panels & Cards */
.card-panel {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    margin-bottom: 30px;
    overflow: hidden;
}

.panel-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
}

.panel-body {
    padding: 30px;
}

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

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

.table-custom th {
    background-color: #F7FAFC;
    padding: 15px 20px;
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text-muted);
    border-bottom: 2px solid var(--color-border);
}

.table-custom td {
    padding: 15px 20px;
    font-size: 14px;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
}

.table-custom tbody tr:hover {
    background-color: #FDFBF7;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
}

.badge-new, .badge-draft { background-color: #E2E8F0; color: #4A5568; }
.badge-in_progress, .badge-partially_paid { background-color: var(--color-warning-light); color: var(--color-warning); }
.badge-completed, .badge-paid, .badge-issued { background-color: var(--color-success-light); color: var(--color-success); }
.badge-cancelled, .badge-closed { background-color: var(--color-danger-light); color: var(--color-danger); }

/* Forms */
.form-group {
    margin-bottom: 20px;
}

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

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-arabic);
    background-color: #FFF;
    color: var(--color-text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(192, 86, 33, 0.15);
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-family: var(--font-arabic);
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    border: none;
    gap: 8px;
}

.btn-primary {
    background-color: var(--color-primary);
    color: #FFF;
}
.btn-primary:hover {
    background-color: var(--color-primary-hover);
}

.btn-secondary {
    background-color: #E2E8F0;
    color: #4A5568;
}
.btn-secondary:hover {
    background-color: #CBD5E0;
}

.btn-danger {
    background-color: var(--color-danger);
    color: #FFF;
}
.btn-danger:hover {
    background-color: #9B2C2C;
}

.btn-success {
    background-color: var(--color-success);
    color: #FFF;
}
.btn-success:hover {
    background-color: #22543D;
}

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

.btn-icon {
    padding: 8px;
    border-radius: 50%;
}

/* Flex utilities */
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap-10 { display: flex; gap: 10px; }
.flex-gap-20 { display: flex; gap: 20px; }

/* Alert Messages */
.alert {
    padding: 15px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 600;
}
.alert-success { background-color: var(--color-success-light); color: var(--color-success); border-right: 4px solid var(--color-success); }
.alert-danger { background-color: var(--color-danger-light); color: var(--color-danger); border-right: 4px solid var(--color-danger); }

/* Login Page Layout */
.login-body {
    background: radial-gradient(circle at 10% 20%, rgba(192, 86, 33, 0.05) 0%, rgba(45, 30, 27, 0.05) 90%), #F8F5F0;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border);
    padding: 40px;
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background-color: var(--color-primary);
}

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

.login-logo img {
    max-height: 80px;
    margin-bottom: 15px;
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 800;
    color: var(--bg-sidebar);
}

/* Receipt Print Canvas CSS Rules - Must fit exactly on 1 page */
@media print {
    body {
        background-color: #FFF;
        color: #000;
        font-size: 12px;
        margin: 0;
        padding: 0;
    }
    
    .sidebar, .main-header, .btn, .no-print {
        display: none !important;
    }
    
    .main-wrapper {
        margin: 0 !important;
        width: 100% !important;
    }

    .main-content {
        padding: 0 !important;
    }

    .print-canvas {
        width: 210mm; /* A4 width */
        height: 297mm; /* A4 height */
        padding: 15mm;
        box-sizing: border-box;
        page-break-after: avoid;
        page-break-inside: avoid;
    }
    
    .table-custom th {
        background-color: #F3F4F6 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

.print-canvas {
    background-color: #FFF;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 40px;
    max-width: 800px;
    margin: 0 auto;
    border: 1px solid var(--color-border);
}

.print-header {
    border-bottom: 2px solid var(--color-primary);
    padding-bottom: 20px;
    margin-bottom: 25px;
}

.print-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 25px;
}

.print-meta-card {
    background-color: #F8F9FA;
    border-radius: var(--radius-sm);
    padding: 15px;
    border: 1px solid var(--color-border);
}

.print-meta-item {
    font-size: 13px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
}

.print-meta-item span:first-child {
    font-weight: 700;
    color: var(--color-text-muted);
}

.print-meta-item span:last-child {
    color: var(--color-text);
}

/* Reception Diagram */
.car-diagram-container {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 15px;
    text-align: center;
    margin: 20px 0;
}

.car-diagram-svg {
    max-width: 100%;
    height: auto;
    max-height: 180px;
}

/* Signatures section */
.print-signatures {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 50px;
    text-align: center;
}

.signature-box {
    border-top: 1px dashed var(--color-text-muted);
    padding-top: 10px;
    font-size: 12px;
    font-weight: 600;
}

/* Layout for print canvas total summary */
.invoice-totals {
    width: 300px;
    margin-right: auto;
    margin-left: 0;
    margin-top: 20px;
}

.invoice-totals-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--color-border);
}

.invoice-totals-row.grand-total {
    border-bottom: none;
    font-size: 18px;
    font-weight: 800;
    color: var(--color-primary);
}

/* =====================================================
   Export & Print Layout Styles
   ===================================================== */
.export-buttons {
    display: flex;
    gap: 8px;
    margin-right: auto;
}
.btn-export {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--color-border);
    background-color: var(--bg-card);
    color: var(--color-text);
    transition: all 0.2s ease;
    text-decoration: none;
}
.btn-export:hover {
    background-color: var(--bg-base);
    border-color: var(--color-primary);
    color: var(--color-primary);
}
.btn-export.btn-excel:hover {
    color: var(--color-success);
    border-color: var(--color-success);
}
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

@media print {
    body.printing-active {
        background-color: #ffffff !important;
        color: #000000 !important;
    }
    body.printing-active * {
        visibility: hidden;
    }
    body.printing-active .print-target,
    body.printing-active .print-target * {
        visibility: visible;
    }
    body.printing-active .print-target {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    body.printing-active .export-buttons {
        display: none !important;
    }
    body.printing-active .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }
}

/* Premium Export Buttons & Dashboard Cards */
.btn-export-premium {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 700;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #D2C4B7;
    background: linear-gradient(180deg, #FFFFFF 0%, #F5EFE9 100%);
    color: #4A3B32;
    box-shadow: 0 2px 4px rgba(45,30,27,0.05);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
}
.btn-export-premium:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(192,86,33,0.15);
    border-color: var(--color-primary);
    color: var(--color-primary);
}
.btn-export-premium.btn-excel-premium:hover {
    box-shadow: 0 4px 8px rgba(47,133,90,0.15);
    border-color: var(--color-success);
    color: var(--color-success);
}
.btn-export-premium i {
    font-size: 14px;
}

/* Reports Menu Cards */
.report-menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
    margin-top: 20px;
}
.report-menu-card {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    padding: 25px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.report-menu-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background-color: var(--color-border);
    transition: all 0.3s ease;
}
.report-menu-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: #D2C4B7;
}
.report-menu-card:hover::before {
    background-color: var(--color-primary);
    width: 6px;
}
.report-card-icon {
    font-size: 32px;
    color: var(--color-primary);
    margin-bottom: 15px;
}
.report-card-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--bg-sidebar);
    margin-bottom: 10px;
}
.report-card-desc {
    font-size: 13px;
    color: var(--color-text-muted);
    line-height: 1.6;
    margin-bottom: 20px;
    flex-grow: 1;
}
.report-card-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--color-border);
    padding-top: 15px;
    margin-top: auto;
}
.report-card-link {
    color: var(--color-primary);
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s ease;
}
.report-card-link:hover {
    color: var(--color-primary-hover);
}
.report-card-stat {
    font-family: var(--font-english);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    background-color: var(--bg-base);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
}