/* ============================================================
   FireGuard Pro — style.css  (Mobile-first)
   ============================================================ */

:root {
    --fg-red:       #dc3545;
    --fg-red-dark:  #b02a37;
    --fg-sidebar-w: 240px;
    --fg-nav-h:     52px;
    --fg-bg:        #f0f2f5;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--fg-bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: #212529;
    overflow-x: hidden;
}

/* ============================================================
   TOP NAVBAR
   ============================================================ */
.top-navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--fg-nav-h);
    background: #b02a37;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 1050;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.navbar-brand-text {
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    white-space: nowrap;
}
.navbar-brand-sub {
    font-size: .7rem;
    color: rgba(255,255,255,.7);
    display: none;
}
@media (min-width: 576px) {
    .navbar-brand-sub { display: inline; }
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: var(--fg-nav-h);
    left: 0;
    width: var(--fg-sidebar-w);
    height: calc(100vh - var(--fg-nav-h));
    background: #1a1a2e;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
    scrollbar-width: thin;
    scrollbar-color: #444 transparent;
    /* Mobile: hidden by default */
    transform: translateX(-100%);
}
.sidebar.open { transform: translateX(0); }

/* Desktop: always visible */
@media (min-width: 992px) {
    .sidebar { transform: translateX(0); }
    .sidebar.force-hide { transform: translateX(-100%); }
}

.sidebar-section-label {
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #6c757d;
    padding: .6rem 1rem .2rem;
    text-transform: uppercase;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem 1rem;
    color: #b0b8c1;
    text-decoration: none;
    border-radius: 6px;
    margin: 1px 6px;
    font-size: .875rem;
    transition: background .15s, color .15s;
}
.sidebar-link:hover { background: rgba(220,53,69,.2); color: #fff; }
.sidebar-link.active { background: var(--fg-red); color: #fff; font-weight: 600; }
.sidebar-link i { font-size: 1rem; width: 1.2rem; flex-shrink: 0; }
.sidebar-footer { margin-top: auto; padding: .75rem 1rem; border-top: 1px solid #2d2d44; }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1039;
}
.sidebar-overlay.show { display: block; }

/* ============================================================
   MAIN WRAPPER
   ============================================================ */
.main-wrapper {
    margin-top: var(--fg-nav-h);
    min-height: calc(100vh - var(--fg-nav-h));
    padding: 0;
    /* Mobile: full width */
    margin-left: 0;
    transition: margin-left .25s ease;
}
/* Desktop: offset sidebar */
@media (min-width: 992px) {
    .main-wrapper { margin-left: var(--fg-sidebar-w); }
    .main-wrapper.sidebar-hidden { margin-left: 0; }
}

/* ============================================================
   CARDS
   ============================================================ */
.card { border-radius: 10px; border: none; }
.card-header { border-radius: 10px 10px 0 0 !important; font-size: .875rem; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
    border-radius: 12px;
    transition: transform .2s, box-shadow .2s;
    cursor: default;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.1) !important; }
.stat-icon { font-size: 1.6rem; }
.stat-number { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .7px; color: #6c757d; margin-top: .2rem; }

/* ============================================================
   TABLES — Mobile scrollable
   ============================================================ */
.table-responsive { -webkit-overflow-scrolling: touch; }
.table th {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    white-space: nowrap;
    background: #f8f9fa;
}
.table td { vertical-align: middle; font-size: .855rem; }
.table-hover tbody tr:hover { background-color: rgba(220,53,69,.04); }

/* Mobile table: hide less important columns */
@media (max-width: 575px) {
    .table .d-none-xs { display: none !important; }
}

/* ============================================================
   FORMS
   ============================================================ */
.form-control:focus, .form-select:focus {
    border-color: var(--fg-red);
    box-shadow: 0 0 0 .2rem rgba(220,53,69,.2);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-danger { background-color: var(--fg-red); border-color: var(--fg-red); }
.btn-danger:hover { background-color: var(--fg-red-dark); border-color: var(--fg-red-dark); }
.btn-check:checked + .btn-outline-success { background: #198754; color: #fff; }
.btn-check:checked + .btn-outline-danger  { background: #dc3545; color: #fff; }
.btn-check:checked + .btn-outline-warning { background: #ffc107; color: #000; }

/* ============================================================
   BADGES
   ============================================================ */
.badge { font-size: .68rem; font-weight: 600; padding: .3em .55em; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert { border-radius: 8px; font-size: .875rem; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-content { border-radius: 12px; border: none; box-shadow: 0 16px 48px rgba(0,0,0,.2); }
.modal-header { border-radius: 12px 12px 0 0 !important; }

/* ============================================================
   DATATABLES — Mobile friendly
   ============================================================ */
div.dataTables_wrapper { overflow-x: auto; }
div.dataTables_wrapper div.dataTables_filter input {
    border-radius: 6px; border: 1px solid #ced4da;
    padding: .25rem .5rem; font-size: .8rem;
}
div.dataTables_wrapper div.dataTables_length select { border-radius: 6px; font-size: .8rem; }
div.dataTables_wrapper div.dataTables_info { font-size: .8rem; }

/* Mobile DataTables: smaller */
@media (max-width: 768px) {
    div.dataTables_wrapper .dataTables_length,
    div.dataTables_wrapper .dataTables_filter { float: none; text-align: left; margin-bottom: 8px; }
    div.dataTables_wrapper .dataTables_filter input { width: 100%; display: block; }
}

/* ============================================================
   LOCATION CARDS (checker)
   ============================================================ */
.location-card { transition: box-shadow .15s; }
.location-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12) !important; }
.location-card .card-body { padding: 12px; }

/* ============================================================
   INSPECTION FORM — Radio as buttons
   ============================================================ */
.btn-check + .btn { font-size: .8rem; padding: .35rem .75rem; }

/* ============================================================
   PRINT QR
   ============================================================ */
@media print {
    .no-print, .sidebar, .top-navbar, .sidebar-overlay { display: none !important; }
    .main-wrapper { margin: 0 !important; }
    body { background: white !important; }
    .table-danger td { background-color: #f8d7da !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .table-warning td { background-color: #fff3cd !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    @page { margin: 1cm; }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* ============================================================
   UTILITIES
   ============================================================ */
.min-w-0 { min-width: 0; }
.text-red { color: var(--fg-red) !important; }
.cursor-pointer { cursor: pointer; }

/* ============================================================
   DASHBOARD — Stat Card Clickable
   ============================================================ */
.stat-card.position-relative {
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card.position-relative:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 24px rgba(220,53,69,.18) !important;
}
.stat-card .stretched-link::after {
    border-radius: 12px;
}

/* ============================================================
   DASHBOARD — Berkala Card
   ============================================================ */
#berkalaCard {
    transition: box-shadow .2s;
}
#berkalaCard:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,.12) !important;
}
#berkalaCard .card-body { user-select: none; }
#berkalaDetail { user-select: auto; }

/* ============================================================
   QR SCANNER
   ============================================================ */
#qrReader video {
    border-radius: 8px !important;
}
#qrReader {
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}
/* Override html5-qrcode default styles */
#qrReader img { display: none; }
#qrReader__header_message { display: none !important; }
#qrReader__status_span {
    font-size: .75rem !important;
    color: #666 !important;
}
#qrReader__camera_selection {
    display: none !important; /* kita handle sendiri */
}
