/* مسار — لوحة تحكم المدير */

* { box-sizing: border-box; }

:root {
    --bg: #F3F6F7;
    --ink: #14282E;
    --muted: #5B7077;
    --faint: #8CA0A7;
    --petrol: #103F4E;
    --primary: #1B6379;
    --border: #E2E9EB;
    --border-soft: #DCE4E7;
    --row-divider: #EEF3F4;
    --thead-bg: #F8FAFB;
    --tile: #E4EEF1;
    --green-ink: #1D6B41;
    --green-bg: #E5F3EA;
    --green-border: #CBE7D6;
    --amber-ink: #9A5B0B;
    --amber-bg: #FBF2E3;
    --amber-border: #F0DDB8;
    --danger: #B0392F;
    --danger-border: #EAD2CF;
}

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--petrol); }

.shell { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--petrol);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { padding: 0 10px 20px; }
.brand-name { font-size: 22px; font-weight: 700; color: #FFFFFF; }
.brand-sub { font-size: 11.5px; color: #A7C4CE; margin-top: 2px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    color: #A7C4CE;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { color: #FFFFFF; background: rgba(255, 255, 255, 0.08); }
.nav-item.active { color: #FFFFFF; font-weight: 600; background: rgba(255, 255, 255, 0.14); }

.sidebar-spacer { flex: 1; }

.sidebar-footer { border-top: 1px solid rgba(255, 255, 255, 0.12); padding-top: 14px; display: flex; flex-direction: column; gap: 4px; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-size: 13px; font-weight: 600; color: #FFFFFF; }
.user-avatar { width: 32px; height: 32px; border-radius: 16px; background: rgba(255, 255, 255, 0.14); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logout-btn {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 8px 12px;
    background: none; border: none; cursor: pointer;
    font-family: inherit; font-size: 13px; font-weight: 500; color: #F4C7C2;
    border-radius: 10px;
}
.logout-btn:hover { background: rgba(255, 255, 255, 0.08); }

/* ===== Content ===== */
.content { flex: 1; min-width: 0; padding: 28px; display: flex; flex-direction: column; gap: 14px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 700; }
.page-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.page-head-side { font-size: 13px; font-weight: 600; color: var(--muted); }
.head-with-back { display: flex; align-items: center; gap: 12px; }

.flash {
    background: var(--green-bg);
    border: 1px solid var(--green-border);
    color: var(--green-ink);
    border-radius: 12px;
    padding: 11px 14px;
    font-size: 13px;
    font-weight: 500;
}
.errors {
    background: #FAEAE8;
    border: 1px solid var(--danger-border);
    color: var(--danger);
    border-radius: 12px;
    padding: 11px 14px;
    font-size: 13px;
    font-weight: 500;
}
.errors ul { margin: 0; padding-inline-start: 18px; }

/* ===== Cards & tables ===== */
.card { background: #FFFFFF; border: 1px solid var(--border); border-radius: 14px; }
.card-pad { padding: 12px 14px; }
.card-title { padding: 13px 16px 11px; font-size: 13.5px; font-weight: 700; border-bottom: 1px solid var(--border); }
/* A card that folds away from its title: open by default, closed with a click on the title. */
details.collapsible > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; list-style: none; user-select: none; }
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary:hover { color: var(--primary); }
details.collapsible .collapse-chev { flex-shrink: 0; color: var(--faint); transition: transform 0.15s ease; }
details.collapsible:not([open]) > summary { border-bottom: none; }
details.collapsible:not([open]) .collapse-chev { transform: rotate(90deg); }

.table-wrap { overflow-x: auto; border-radius: 14px; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
    text-align: right;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--faint);
    background: var(--thead-bg);
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.data td { padding: 12px 18px; border-bottom: 1px solid var(--row-divider); font-size: 13px; color: var(--muted); white-space: nowrap; }
table.data tr:last-child td { border-bottom: none; }
table.data td.strong { color: var(--ink); font-weight: 600; font-size: 13.5px; }
table.data td.ink { color: var(--ink); }
/* every heading sits over the middle of its column (the trips list) */
table.data.centered th, table.data.centered td { text-align: center; }
table.data.centered td > .photo-thumb { margin-inline: auto; }
table.data.centered td > .sk { margin-inline: auto; }
table.data.centered td > div, table.data.centered .sk-actions { justify-content: center; }

.cell-entity { display: flex; align-items: center; gap: 11px; }
.icon-tile { width: 40px; height: 40px; border-radius: 11px; background: var(--tile); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--primary); }
.avatar-initial { width: 40px; height: 40px; border-radius: 20px; background: var(--tile); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 15px; font-weight: 700; color: var(--primary); }

.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--thead-bg); font-size: 12.5px; color: var(--muted); }

/* ===== Badges & chips ===== */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.badge.green { color: var(--green-ink); background: var(--green-bg); border: 1px solid var(--green-border); }
.badge.amber { color: var(--amber-ink); background: var(--amber-bg); border: 1px solid var(--amber-border); }
.badge.neutral { color: var(--muted); background: #EEF2F3; border: 1px solid var(--border-soft); }

.chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
    display: inline-flex; align-items: center;
    height: 36px; padding: 0 16px;
    border-radius: 999px;
    background: #FFFFFF; border: 1px solid var(--border-soft);
    color: var(--muted); font-size: 13px; font-weight: 500;
}
.chip:hover { color: var(--ink); }
.chip.active { background: var(--petrol); border-color: var(--petrol); color: #FFFFFF; font-weight: 600; }

/* ===== Forms & buttons ===== */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.input, .select {
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border-soft);
    background: #FFFFFF;
    padding: 0 12px;
    font-family: inherit;
    font-size: 13px;
    color: var(--ink);
    min-width: 0;
}
.select { min-width: 180px; }
.select.compact { height: 34px; min-width: 112px; padding: 0 10px; }
.select.is-missing { border-color: var(--amber-border); background: var(--amber-bg); color: var(--amber-ink); }
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27, 99, 121, 0.12); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 16px;
    border-radius: 11px; border: none; cursor: pointer;
    font-family: inherit; font-size: 13.5px; font-weight: 700;
}
.btn-primary { background: var(--primary); color: #FFFFFF; box-shadow: 0 3px 10px rgba(27, 99, 121, 0.25); }
.btn-primary:hover { background: var(--petrol); }
.btn-ghost { background: #FFFFFF; color: var(--muted); border: 1px solid var(--border-soft); }
.btn-ghost:hover { color: var(--ink); }
.btn-lg { height: 44px; }

.icon-btn {
    width: 34px; height: 34px;
    border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    background: #FFFFFF; cursor: pointer; border: 1px solid var(--border-soft);
    color: var(--muted);
    padding: 0;
}
.icon-btn.danger { border-color: var(--danger-border); color: var(--danger); }
.icon-btn.danger:hover { background: #FAEAE8; }
.icon-btn.square-back { width: 38px; height: 38px; border-radius: 11px; color: var(--ink); }

.link-sm { font-size: 13px; font-weight: 600; }
.note-line { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--faint); }
.empty-state { padding: 26px 16px; text-align: center; font-size: 13px; color: var(--faint); }

/* ===== KPI tiles ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1280px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: #FFFFFF; border: 1px solid var(--border); border-radius: 14px; padding: 15px 18px; display: flex; flex-direction: column; gap: 5px; }
.kpi-label { font-size: 12.5px; color: var(--muted); }
.kpi-value { display: flex; align-items: baseline; gap: 5px; }
.kpi-number { font-size: 26px; font-weight: 600; color: var(--ink); }
.kpi-unit { font-size: 13px; color: var(--muted); }
.kpi-sub { font-size: 11px; color: var(--faint); }

.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* ===== Dialog ===== */
dialog.modal {
    border: none;
    border-radius: 16px;
    padding: 0;
    width: min(440px, calc(100vw - 32px));
    box-shadow: 0 20px 60px rgba(16, 63, 78, 0.25);
}
dialog.modal::backdrop { background: rgba(16, 63, 78, 0.45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 0; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; gap: 10px; margin-top: 4px; }
.modal-actions .btn { flex: 1; }

/* ===== Trip meter photo ===== */
.photo-thumb {
    display: block;
    width: 40px; height: 40px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--tile);
    cursor: pointer;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb:hover { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27, 99, 121, 0.15); }

dialog.photo-modal {
    border: none;
    padding: 0;
    background: transparent;
    max-width: none;
    overflow: visible;
}
dialog.photo-modal::backdrop { background: rgba(16, 40, 46, 0.62); }
dialog.photo-modal img {
    display: block;
    max-width: min(92vw, 900px);
    max-height: 82vh;
    border-radius: 14px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
}
.photo-modal-close {
    position: absolute;
    top: -14px;
    inset-inline-start: -14px;
    width: 34px; height: 34px;
    border: none;
    border-radius: 17px;
    background: #FFFFFF;
    color: var(--ink);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.photo-modal-close:hover { color: var(--primary); }

dialog.confirm-modal {
    border: none;
    border-radius: 16px;
    padding: 22px 22px 18px;
    width: min(92vw, 420px);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
    color: var(--ink);
}
dialog.confirm-modal::backdrop { background: rgba(16, 40, 46, 0.62); }
.confirm-modal-text { margin: 0 0 18px; font-size: 14.5px; font-weight: 600; line-height: 1.7; }
.confirm-modal-actions { display: flex; gap: 10px; }
.btn-danger { background: var(--danger); color: #FFFFFF; }
.btn-danger:hover { background: #962F26; }

/* ===== Login ===== */
.login-page { min-height: 100vh; background: var(--petrol); display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: #FFFFFF; border-radius: 18px; width: 400px; max-width: 100%; padding: 30px 28px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28); }
.login-brand { text-align: center; margin-bottom: 6px; }
.login-brand .brand-name { color: var(--ink); font-size: 26px; }
.login-brand .brand-sub { color: var(--muted); font-size: 13px; }
.login-card .input { height: 48px; border-radius: 12px; font-size: 14px; }
.login-card .btn { height: 50px; border-radius: 13px; font-size: 15px; }

/* ===== Pagination ===== */
.pager { display: flex; align-items: center; gap: 6px; }
.pager a, .pager span {
    min-width: 30px; height: 30px; padding: 0 8px;
    border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12.5px; font-weight: 500;
    border: 1px solid var(--border-soft); background: #FFFFFF; color: var(--muted);
}
.pager .current { background: var(--primary); border-color: var(--primary); color: #FFFFFF; font-weight: 600; }
.pager .disabled { opacity: 0.45; }

/* ===== Chart ===== */
.chart-svg { display: block; width: 100%; }

/* ===== Custom dropdown ===== */
.dd { position: relative; min-width: 200px; }
.dd-toggle {
    width: 100%; height: 40px;
    border-radius: 10px; border: 1px solid var(--border-soft);
    background: #FFFFFF; padding: 0 12px;
    display: flex; align-items: center; gap: 8px;
    cursor: pointer; font-family: inherit; font-size: 13px; color: var(--ink);
}
.dd-toggle:hover { border-color: #B9CBD1; }
.dd-icon { color: var(--muted); display: inline-flex; flex-shrink: 0; }
.dd-label { flex: 1; text-align: start; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-chev { color: var(--faint); display: inline-flex; flex-shrink: 0; }
.dd-menu {
    position: absolute; top: calc(100% + 6px); inset-inline-start: 0;
    min-width: 100%; max-height: 280px; overflow-y: auto;
    background: #FFFFFF; border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 14px 40px rgba(16, 63, 78, 0.14);
    padding: 6px; z-index: 40;
    display: flex; flex-direction: column; gap: 2px;
}
.dd-menu[hidden] { display: none; }
.dd-item {
    border: none; background: none; cursor: pointer;
    font-family: inherit; font-size: 13px; color: var(--ink);
    text-align: start; padding: 9px 12px; border-radius: 8px; white-space: nowrap;
}
.dd-item:hover { background: var(--bg); }
.dd-item.on { background: var(--tile); color: var(--primary); font-weight: 600; }

/* ===== Skeleton loaders (shimmer) ===== */
:root { --sk-base: #DCE4E7; --sk-shine: #F3F6F7; }

/* One highlight sweeps across the whole viewport (fixed background), right → left like the page. */
.sk {
    display: block;
    height: 12px;
    border-radius: 6px;
    background-color: var(--sk-base);
    background-image: linear-gradient(100deg, var(--sk-base) 44%, var(--sk-shine) 50%, var(--sk-base) 56%);
    background-size: 220vw 100%;
    background-repeat: no-repeat;
    background-attachment: fixed;
    animation: sk-sweep 1.5s linear infinite;
}
@keyframes sk-sweep {
    from { background-position: 10vw 0; }
    to { background-position: -110vw 0; }
}
@media (prefers-reduced-motion: reduce) { .sk { animation: none; background-image: none; } }

.sk-cell { display: flex; align-items: center; height: 20px; }
.sk-line { display: flex; align-items: center; }
.sk-pager { width: 30px; height: 30px; border-radius: 8px; }
.sk-badge { width: 31px; height: 28px; border-radius: 999px; }
.sk-tile { width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0; }
.sk-circle { width: 40px; height: 40px; border-radius: 20px; flex-shrink: 0; }
.sk-input { height: 40px; border-radius: 10px; }
.sk-select { display: block; width: 112px; height: 34px; border-radius: 10px; }
.sk-btn { height: 44px; border-radius: 11px; }
.sk-chip { height: 36px; border-radius: 999px; }
.sk-icon-btn { width: 34px; height: 34px; border-radius: 9px; }
.sk-back { width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0; }
.sk-actions { display: flex; align-items: center; gap: 6px; }
.sk-stack { display: flex; flex-direction: column; gap: 8px; }

.sk-page { display: flex; flex-direction: column; gap: 14px; pointer-events: none; user-select: none; }
main.content.is-loading > :not(.sk-page) { display: none !important; }

@media (max-width: 900px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; }
    .brand { padding: 0 10px; }
    .sidebar-spacer { display: none; }
    .sidebar-footer { border-top: none; padding-top: 0; flex-direction: row; margin-inline-start: auto; }
    .content { padding: 16px; }
    .kpi-grid, .two-col { grid-template-columns: 1fr; }
}
