/* ===== روافد ERP - الأنماط الرئيسية ===== */
:root {
    --primary:   #1a3a6b;
    --primary-light: #2e5ba8;
    --accent:    #d4af37;
    --success:   #00a854;
    --warning:   #f39c12;
    --danger:    #e74c3c;
    --info:      #2980b9;
    --sidebar-w: 260px;
    --sidebar-bg:#0f2447;
    --body-bg:   #f0f4f8;
    --card-bg:   #ffffff;
    --text-main: #1a2940;
    --text-muted:#6b7a99;
    --border:    #dde3f0;
    --radius:    12px;
    --shadow:    0 4px 20px rgba(26,58,107,.08);
}

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

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--body-bg);
    color: var(--text-main);
    font-size: 15px;
}

/* ── Wrapper ── */
.wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
#sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; right: 0;
    height: 100vh;
    z-index: 1000;
    transition: width .3s ease;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    background: rgba(255,255,255,.05);
}
.sidebar-header img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    padding: 2px;
    flex-shrink: 0;
}

.logo-icon {
    width: 42px; height: 42px;
    background: var(--accent);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: var(--primary);
    font-size: 20px;
    flex-shrink: 0;
}

.sidebar-header h5 {
    color: #fff;
    font-weight: 800;
    font-size: 18px;
    margin: 0;
}
.sidebar-header h5 span { color: var(--accent); }

.sidebar-menu {
    list-style: none;
    padding: 16px 12px;
    flex: 1;
    overflow-y: auto;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: rgba(255,255,255,.7);
    text-decoration: none;
    border-radius: 10px;
    transition: all .2s;
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 4px;
}

.sidebar-menu li a i { font-size: 18px; width: 22px; }
.sidebar-menu li a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-menu li.active a {
    background: var(--primary-light);
    color: #fff;
    box-shadow: 0 4px 12px rgba(46,91,168,.4);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,.08);
}

.user-info {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 12px;
}

.user-avatar { font-size: 32px; color: var(--accent); }
.user-name { color: #fff; font-weight: 700; font-size: 14px; }
.user-role { color: rgba(255,255,255,.5); font-size: 12px; }

.logout-btn {
    display: flex; align-items: center; gap: 8px;
    color: rgba(255,255,255,.6);
    text-decoration: none;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all .2s;
}
.logout-btn:hover { background: rgba(231,76,60,.2); color: #e74c3c; }

/* ── Content ── */
#content {
    margin-right: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin .3s ease;
}

/* ── Top Navbar ── */
.top-navbar {
    background: var(--card-bg);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

#sidebarToggle {
    background: none; border: none;
    font-size: 22px; color: var(--primary);
    cursor: pointer; display: none;
}

.page-title {
    font-weight: 800;
    font-size: 18px;
    color: var(--primary);
    flex: 1;
}

.navbar-date {
    color: var(--text-muted);
    font-size: 13px;
    display: flex; align-items: center; gap: 6px;
}

/* ── Main Content ── */
.main-content { padding: 24px; flex: 1; }

/* ── KPI Cards ── */
.kpi-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform .2s, box-shadow .2s;
    position: relative;
    overflow: hidden;
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 4px; height: 100%;
    background: var(--kpi-color, var(--primary));
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 8px 30px rgba(26,58,107,.12); }

.kpi-icon {
    width: 56px; height: 56px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    color: #fff;
    background: var(--kpi-color, var(--primary));
    flex-shrink: 0;
}

.kpi-info { flex: 1; }
.kpi-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
    margin-bottom: 4px;
}
.kpi-label { color: var(--text-muted); font-size: 13px; font-weight: 500; }

/* ── Section Card ── */
.section-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 24px;
}

.section-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}

.section-card-header h6 {
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    margin: 0;
    display: flex; align-items: center; gap: 8px;
}

.section-card-body { padding: 20px; }

/* ── Tables ── */
.table { font-size: 14px; margin: 0; }
.table thead th {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    border: none;
    padding: 12px 14px;
    white-space: nowrap;
}
.table tbody tr:hover { background: #f5f8ff; }
.table td { padding: 11px 14px; vertical-align: middle; border-color: var(--border); }

/* ── Badges ── */
.badge-status {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex; align-items: center; gap: 5px;
}
.badge-ok    { background:#e6f9ef; color:#00a854; }
.badge-warn  { background:#fff4e0; color:#f39c12; }
.badge-danger{ background:#fde8e8; color:#e74c3c; }
.badge-closed{ background:#eee;    color:#666; }

/* ── Expiry coloring ── */
.exp-ok    { color: #00a854; font-weight: 600; }
.exp-warn  { color: #f39c12; font-weight: 600; }
.exp-danger{ color: #e74c3c; font-weight: 700; }

/* ── Forms ── */
.form-label { font-weight: 600; font-size: 13px; color: var(--text-main); margin-bottom: 5px; }
.form-control, .form-select {
    border-radius: 8px;
    border: 1.5px solid var(--border);
    font-family: 'Tajawal', sans-serif;
    font-size: 14px;
    transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(46,91,168,.12);
}

/* ── Buttons ── */
.btn { border-radius: 8px; font-family: 'Tajawal', sans-serif; font-weight: 600; font-size: 14px; }
.btn-primary  { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }

/* ── Modal ── */
.modal-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    border-radius: var(--radius) var(--radius) 0 0;
}
.modal-header .btn-close { filter: invert(1); }
.modal-title { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }

/* ── Login Page ── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, #0a1e3d 60%, #1a3a6b 100%);
    display: flex; align-items: center; justify-content: center;
}
.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%; max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    text-align: center;
}
.login-logo {
    width: 72px; height: 72px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 20px;
    font-size: 32px; color: #fff;
}
.login-card h3 { font-weight: 800; color: var(--primary); margin-bottom: 6px; }
.login-card p  { color: var(--text-muted); margin-bottom: 30px; font-size: 14px; }

/* ── Alerts Section ── */
.alert-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 8px;
    font-size: 14px;
}
.alert-item-warn   { background: #fff8e8; border: 1px solid #fde68a; }
.alert-item-danger { background: #fde8e8; border: 1px solid #fca5a5; }
.alert-item-icon { font-size: 20px; }
.alert-item-text { flex: 1; }
.alert-item-days { font-weight: 700; font-size: 13px; }

/* ── Financial summary ── */
.fin-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.fin-row:last-child { border-bottom: none; }
.fin-label { color: var(--text-muted); }
.fin-value { font-weight: 700; font-size: 16px; }
.fin-value.positive { color: var(--success); }
.fin-value.negative { color: var(--danger); }
.fin-value.neutral  { color: var(--primary); }

/* ── Responsive ── */
@media (max-width: 768px) {
    #sidebar { width: 0; right: -260px; }
    #sidebar.open { width: var(--sidebar-w); right: 0; }
    #content { margin-right: 0; }
    #sidebarToggle { display: block; }
    .kpi-value { font-size: 22px; }
}

/* ── DataTables custom ── */
.dataTables_wrapper .dataTables_filter input {
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    font-family: 'Tajawal', sans-serif;
}
.dataTables_wrapper .dataTables_length select {
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: 'Tajawal', sans-serif;
}
div.dataTables_wrapper div.dataTables_info { color: var(--text-muted); font-size: 13px; }

/* ── Progress bar for payments ── */
.pay-progress { height: 8px; border-radius: 4px; background: #e9ecef; overflow: hidden; margin-top: 4px; }
.pay-progress-bar { height: 100%; border-radius: 4px; transition: width .4s ease; }

/* ── Page header ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h4 { font-weight: 800; color: var(--primary); margin: 0; }
.page-header .btn-group-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c0cad9; border-radius: 3px; }

/* ── Menu Section Labels ── */
.menu-section {
    color: rgba(255,255,255,.3);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 14px 16px 4px;
    list-style: none;
}

/* ── Voucher Print ── */
@media print {
    #sidebar, .top-navbar, .no-print { display: none !important; }
    #content { margin: 0 !important; }
    .main-content { padding: 0 !important; }
    .voucher-print { max-width: 100% !important; }
}

.voucher-print {
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    border: 2px solid #1a3a6b;
    border-radius: 12px;
    padding: 32px;
}
.voucher-header {
    text-align: center;
    border-bottom: 3px double #1a3a6b;
    padding-bottom: 20px;
    margin-bottom: 24px;
}
.voucher-header h2 { color: #1a3a6b; font-weight: 800; font-size: 22px; margin: 0; }
.voucher-header p  { color: #555; margin: 4px 0 0; font-size: 14px; }
.voucher-title-bar {
    background: #1a3a6b;
    color: #fff;
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 24px;
}
.voucher-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}
.voucher-info-item {
    display: flex;
    gap: 8px;
    font-size: 14px;
}
.voucher-info-label { color: #6b7a99; font-weight: 600; white-space: nowrap; }
.voucher-info-value { color: #1a2940; font-weight: 500; }
.voucher-table th { background: #1a3a6b !important; color: #fff !important; }
.voucher-total-box {
    background: #f0f4f8;
    border: 2px solid #1a3a6b;
    border-radius: 10px;
    padding: 16px 24px;
    margin-top: 20px;
}
.voucher-total-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 15px;
    border-bottom: 1px dashed #dde3f0;
}
.voucher-total-row:last-child { border-bottom: none; font-size: 18px; font-weight: 800; color: #1a3a6b; }
.voucher-sign-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-top: 40px;
    text-align: center;
}
.sign-box { border-top: 1px solid #999; padding-top: 8px; color: #6b7a99; font-size: 13px; }
.badge-draft    { background:#e8f4fd;color:#2980b9; }
.badge-issued   { background:#e6f9ef;color:#00a854; }
.badge-cancelled{ background:#fde8e8;color:#e74c3c; }

/* ── Print Styles ── */
@media print {
    #sidebar, .top-navbar, .no-print,
    .btn, .page-header button, .page-header a { display: none !important; }
    #content { margin: 0 !important; }
    .main-content { padding: 10px !important; }
    .section-card { box-shadow: none !important; border: 1px solid #ccc !important; }
    .table { font-size: 11px !important; }
    body { background: #fff !important; }
}

/* ── Search bar in navbar ── */
.top-navbar form input {
    font-family: 'Tajawal', sans-serif;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
}
.top-navbar form input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(46,91,168,.1);
    outline: none;
}

/* ── Alert badge in sidebar ── */
.sidebar-menu li a .badge {
    margin-right: auto;
    margin-left: 4px;
    font-size: 10px;
}
