/* ============================================================
   APS Truck & Trailer Repair LTD - Theme
   Dark navy sidebar + blue primary + light slate background
   ============================================================ */
:root {
    --aps-sidebar: #fff;
    --aps-sidebar-hover: #1e293b;
    --aps-primary: #2563eb;
    --aps-primary-dark: #1d4ed8;
    --aps-bg: #f1f5f9;
    --aps-card: #ffffff;
    --aps-border: #e2e8f0;
    --aps-text: #1e293b;
    --aps-muted: #64748b;
    --sidebar-width: 240px;
}

* { box-sizing: border-box; }

body {
    background: var(--aps-bg);
    font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
    color: var(--aps-text);
    font-size: 14px;
}

/* ---------------- Sidebar ---------------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--aps-sidebar);
    color: #cbd5e1;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
}
.sidebar-brand {
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-brand .brand-logo {
    width: 44px; height: 44px;
    background: #fff;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}
.sidebar-brand .brand-logo svg { width: 38px; height: 38px; }
.sidebar-brand .brand-text { line-height: 1.15; }
.sidebar-brand .brand-text strong {
    color: #fff; font-size: 19px; letter-spacing: 1px; display: block;
    font-family: Georgia, 'Times New Roman', serif;
}
.sidebar-brand .brand-text small {
    color: #94a3b8; font-size: 8.5px; letter-spacing: .6px; text-transform: uppercase;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 10px; }
.sidebar-nav .nav-link {
    color: #000;
    padding: 10px 14px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    margin-bottom: 3px;
    transition: all .15s;
}
.sidebar-nav .nav-link i { font-size: 16px; width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: var(--aps-sidebar-hover); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--aps-primary); color: #fff; }
.sidebar-nav .nav-sub { padding-left: 30px; }
.sidebar-nav .nav-sub .nav-link { font-size: 13px; padding: 8px 14px; }
.sidebar-footer { padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-footer .nav-link { color: #cbd5e1; padding: 10px 14px; border-radius: 8px; display: flex; gap: 12px; align-items: center; }
.sidebar-footer .nav-link:hover { background: var(--aps-sidebar-hover); color: #fff; }

/* ---------------- Main / Topbar ---------------- */
.main-wrapper { margin-left: var(--sidebar-width); min-height: 100vh; transition: margin .25s ease; }
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--aps-border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 1030;
}
.topbar h1 { font-size: 21px; font-weight: 700; margin: 0; }
.topbar .search-box { max-width: 420px; flex: 1; }
.topbar .search-box .form-control {
    background: #f8fafc;
    border: 1px solid var(--aps-border);
    border-radius: 8px;
    font-size: 13.5px;
}
.notif-bell { position: relative; color: var(--aps-muted); font-size: 19px; }
.notif-bell .badge {
    position: absolute; top: -6px; right: -8px;
    background: #ef4444; font-size: 10px;
}
.user-chip { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.user-chip .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--aps-primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px;
    overflow: hidden;
}
.user-chip .avatar img { width: 100%; height: 100%; object-fit: cover; }

.page-content { padding: 24px; }

/* ---------------- Cards ---------------- */
.card { border: 1px solid var(--aps-border); border-radius: 12px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--aps-border);
    border-radius: 12px 12px 0 0 !important;
    font-weight: 600;
    padding: 14px 18px;
    display: flex; align-items: center; gap: 8px;
}
.card-header i { color: var(--aps-primary); }

/* ---------------- Stat cards ---------------- */
.stat-card { padding: 18px; display: flex; flex-direction: column; gap: 4px; }
.stat-card .stat-top { display: flex; align-items: center; gap: 14px; }
.stat-icon {
    width: 48px; height: 48px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: #fff; flex-shrink: 0;
}
.stat-icon.blue   { background: var(--aps-primary); }
.stat-icon.orange { background: #f59e0b; }
.stat-icon.green  { background: #22c55e; }
.stat-icon.purple { background: #8b5cf6; }
.stat-icon.red    { background: #ef4444; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--aps-muted); font-size: 13px; }
.stat-link { font-size: 12.5px; color: var(--aps-primary); text-decoration: none; margin-top: 6px; font-weight: 500; }
.stat-link:hover { text-decoration: underline; }

/* ---------------- Status badges ---------------- */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-open      { background: #fee2e2; color: #dc2626; }
.badge-progress  { background: #dbeafe; color: #2563eb; }
.badge-waiting   { background: #fef3c7; color: #d97706; }
.badge-completed { background: #dcfce7; color: #16a34a; }
.badge-hold      { background: #e2e8f0; color: #475569; }
.badge-paid      { background: #dcfce7; color: #16a34a; }
.badge-unpaid    { background: #fee2e2; color: #dc2626; }
.badge-partial   { background: #fef3c7; color: #d97706; }

/* ---------------- Tables ---------------- */
.table { font-size: 13.5px; }
.table thead th {
    background: #f8fafc;
    color: var(--aps-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .4px;
    font-weight: 600;
    border-bottom: 1px solid var(--aps-border);
    padding: 11px 14px;
    white-space: nowrap;
}
.table tbody td { padding: 12px 14px; vertical-align: middle; border-color: #f1f5f9; }
.table-hover tbody tr:hover { background: #f8fafc; }

.btn-icon {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 7px; border: 1px solid var(--aps-border);
    background: #fff; color: var(--aps-muted);
    transition: all .15s;
}
.btn-icon:hover { color: var(--aps-primary); border-color: var(--aps-primary); }
.btn-icon.danger:hover { color: #ef4444; border-color: #ef4444; }

/* ---------------- Forms ---------------- */
.form-label { font-weight: 500; font-size: 13px; color: #334155; }
.form-label .req { color: #ef4444; }
.form-control, .form-select {
    border: 1px solid var(--aps-border);
    border-radius: 8px;
    font-size: 13.5px;
    padding: 8px 12px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--aps-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.btn-primary { background: var(--aps-primary); border-color: var(--aps-primary); border-radius: 8px; font-weight: 500; }
.btn-primary:hover { background: var(--aps-primary-dark); border-color: var(--aps-primary-dark); }
.btn-outline-secondary { border-radius: 8px; }

/* ---------------- Work order form ---------------- */
.section-card { margin-bottom: 20px; }
.wo-table td { padding: 8px 10px; }
.wo-table .form-control, .wo-table .form-select { font-size: 13px; padding: 6px 10px; }
.summary-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 14px; }
.summary-row.total {
    border-top: 2px solid var(--aps-border);
    margin-top: 6px; padding-top: 14px;
    font-weight: 700; font-size: 17px;
}
.summary-row.total .amount { color: var(--aps-primary); font-size: 22px; }

/* ---------------- Signature ---------------- */
.signature-wrap {
    border: 2px dashed var(--aps-border);
    border-radius: 10px;
    background: #fff;
    position: relative;
}
#signaturePad { width: 100%; height: 200px; display: block; border-radius: 10px; touch-action: none; }
.signature-hint {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    color: #cbd5e1; font-size: 14px; pointer-events: none;
}

/* ---------------- Photo upload ---------------- */
.upload-drop {
    border: 2px dashed var(--aps-border);
    border-radius: 10px;
    padding: 22px;
    text-align: center;
    color: var(--aps-muted);
    font-size: 12.5px;
    cursor: pointer;
    transition: all .15s;
    background: #f8fafc;
}
.upload-drop:hover { border-color: var(--aps-primary); color: var(--aps-primary); }
.photo-thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.photo-thumb { position: relative; width: 72px; height: 72px; border-radius: 8px; overflow: hidden; border: 1px solid var(--aps-border); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb .remove {
    position: absolute; top: 2px; right: 2px;
    width: 18px; height: 18px; border-radius: 50%;
    background: #ef4444; color: #fff; border: 0;
    font-size: 10px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
}

/* ---------------- Login ---------------- */
.login-page {
    min-height: 100vh;
    background: var(--aps-sidebar);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.login-card {
    background: #fff; border-radius: 16px;
    max-width: 420px; width: 100%;
    padding: 36px;
    box-shadow: 0 20px 50px rgba(0,0,0,.35);
}

/* ---------------- Quick actions ---------------- */
.quick-action {
    border: 1px solid var(--aps-border);
    border-radius: 10px;
    padding: 16px 10px;
    text-align: center;
    text-decoration: none;
    display: block;
    color: var(--aps-text);
    font-size: 12.5px;
    font-weight: 500;
    transition: all .15s;
    background: #fff;
}
.quick-action i { display: block; font-size: 21px; margin-bottom: 8px; }
.quick-action:hover { border-color: var(--aps-primary); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(37,99,235,.12); color: var(--aps-text); }

/* ---------------- Responsive ---------------- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .sidebar-backdrop {
        position: fixed; inset: 0;
        background: rgba(0,0,0,.45);
        z-index: 1035; display: none;
    }
    .sidebar-backdrop.show { display: block; }
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
