/* public/assets/css/style.css */
:root {
    --accent-1: #6366f1;
    --accent-2: #8b5cf6;
    --accent-3: #ec4899;
    --grad: linear-gradient(90deg, var(--accent-1), var(--accent-2));
    --bg: #f4f5f7;
    --card-bg: #ffffff;
    --text: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --radius-lg: 20px;
    --radius-md: 16px;
    --radius-sm: 10px;
    --shadow-card: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --success-bg: #dcfce7;
    --success-text: #15803d;
    --warning-bg: #fef9c3;
    --warning-text: #854d0e;
    --danger-bg: #fee2e2;
    --danger-text: #b91c1c;
}

* { box-sizing: border-box; }
body { font-family: system-ui, sans-serif; margin: 0; background: var(--bg); color: var(--text); }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 15px; margin: 20px 0 10px; color: var(--text-muted); }

/* ---- Auth page ---- */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.auth-form { background: var(--card-bg); padding: 32px; border-radius: var(--radius-lg); box-shadow: var(--shadow-card); width: 100%; max-width: 340px; }
.auth-logo { display: block; margin: 0 auto 16px; width: 144px; height: 144px; object-fit: contain; }
.auth-form h1 { text-align: center; margin-bottom: 20px; }
.auth-form label { display: block; margin-bottom: 12px; font-size: 14px; font-weight: 600; color: var(--text-muted); }
.auth-form input { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 15px; font-family: inherit; }
.auth-form button { width: 100%; padding: 12px; background: var(--grad); color: #fff; border: none; border-radius: var(--radius-sm); cursor: pointer; font-size: 15px; font-weight: 600; margin-top: 8px; }
.error, .field-error { color: var(--danger-text); font-size: 14px; }
.text-link { color: var(--accent-1); text-decoration: underline; font-size: 14px; cursor: pointer; }
.field-success { color: var(--success-text); font-size: 14px; }

/* ---- App shell (mobile-first: header + collapsible nav) ---- */
.app-layout { display: flex; min-height: 100vh; flex-direction: column; }
.app-header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--grad); color: #fff; position: sticky; top: 0; z-index: 20; }
.app-header .app-logo { width: 32px; height: 32px; border-radius: 8px; object-fit: contain; background: #fff; padding: 3px; flex-shrink: 0; }
.app-header .app-title { font-weight: 700; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hamburger-btn { background: rgba(255,255,255,.18); border: none; border-radius: 8px; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; color: #fff; cursor: pointer; flex-shrink: 0; padding: 0; }
.hamburger-btn svg { width: 20px; height: 20px; }

.app-sidebar { display: none; flex-direction: column; background: var(--card-bg); box-shadow: var(--shadow-card); padding: 8px 0; position: fixed; top: 56px; left: 0; right: 0; z-index: 25; max-height: calc(100vh - 56px); overflow-y: auto; }
.app-sidebar.nav-open { display: flex; }
.app-sidebar a { display: flex; align-items: center; gap: 10px; color: var(--text); padding: 12px 16px; text-decoration: none; font-size: 14px; font-weight: 500; border-left: 3px solid transparent; }
.app-sidebar a svg { width: 18px; height: 18px; flex-shrink: 0; }
.app-sidebar a.active { color: var(--accent-1); background: #eef2ff; border-left-color: var(--accent-1); font-weight: 600; }
.app-sidebar a.logout { color: var(--text-muted); margin-top: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.sidebar-blocks-nav { display: none; }

.app-content { flex: 1; padding: 16px; width: 100%; }

@media (min-width: 768px) {
    .app-layout { flex-direction: row; }
    .app-header { display: none; }
    .app-sidebar { display: flex !important; width: 240px; flex-shrink: 0; min-height: 100vh; border-radius: 0; position: sticky; top: 0; align-self: flex-start; max-height: 100vh; overflow-y: auto; }
    .app-content { padding: 32px; }
    .sidebar-blocks-nav { display: flex; flex-direction: column; border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; max-height: 40vh; overflow-y: auto; }
    .sidebar-blocks-nav a { color: var(--text-muted); padding: 8px 16px; text-decoration: none; font-size: 13px; }
    .sidebar-blocks-nav a:hover { color: var(--accent-1); }
}

/* ---- Icon default size ----
   Our inline SVGs (Icons.php) never set width/height themselves — sizing is
   meant to come from CSS. This is the fallback for icons used bare (block
   headings, table photo links) that aren't inside a .btn/.app-sidebar
   a/.hamburger-btn (those set a more specific size below and win on
   specificity). Without this, a sizeless inline <svg> defaults to the
   browser's replaced-element size of 300x150px. */
svg { width: 18px; height: 18px; vertical-align: -3px; flex-shrink: 0; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; background: var(--grad); color: #fff; border: none; border-radius: var(--radius-sm); cursor: pointer; text-decoration: none; font-size: 14px; font-weight: 600; }
.btn-icon { width: 36px; height: 36px; flex-shrink: 0; padding: 0; justify-content: center; background: var(--border); color: var(--text-muted); }
.btn-danger { background: var(--danger-text); }
.btn-success { background: var(--success-text); }
.btn-icon.btn-danger { background: var(--danger-text); color: #fff; }
.btn-icon.btn-success { background: var(--success-text); color: #fff; }
.btn-icon.is-active { background: var(--warning-bg); color: var(--warning-text); }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:disabled, .btn-icon:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Cards ---- */
.card { background: var(--card-bg); border-radius: var(--radius-md); box-shadow: var(--shadow-card); padding: 16px; margin-bottom: 12px; }
.question-card { background: var(--card-bg); border-radius: var(--radius-md); box-shadow: var(--shadow-card); padding: 16px; margin-bottom: 12px; }
.question-card.is-not-applicable { background: #efefef; }
.question-card.is-not-applicable > b { color: #c9ced7; }
.question-card.is-not-applicable .segmented { opacity: .5; pointer-events: none; }
.requirement-desc { margin-top: 4px; color: var(--text); font-size: 14px; }
.question-field-divider { border: none; border-top: 1px solid var(--border); margin: 8px 0; }

/* ---- Stat cards (dashboards) ---- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 16px 0; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card { background: var(--card-bg); border-radius: var(--radius-md); box-shadow: var(--shadow-card); padding: 16px; text-align: center; }
.stat-card .stat-value { font-size: 26px; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-done { background: var(--success-bg); color: var(--success-text); }
.badge-partial { background: var(--warning-bg); color: var(--warning-text); }
.badge-notdone { background: var(--danger-bg); color: var(--danger-text); }
.badge-neutral { background: var(--bg); color: var(--text-muted); }

/* ---- Segmented answer control ---- */
.segmented { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.segmented label { position: relative; flex: 1 1 100px; text-align: center; padding: 10px 8px; border-radius: var(--radius-sm); background: var(--bg); color: var(--text-muted); font-size: 13px; cursor: pointer; border: 1.5px solid transparent; }
.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented label:has(input[value="done"]:checked) { background: var(--success-bg); color: var(--success-text); font-weight: 600; border-color: var(--success-text); }
.segmented label:has(input[value="partial"]:checked) { background: var(--warning-bg); color: var(--warning-text); font-weight: 600; border-color: var(--warning-text); }
.segmented label:has(input[value="notdone"]:checked) { background: var(--danger-bg); color: var(--danger-text); font-weight: 600; border-color: var(--danger-text); }

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 32px 16px; }
.empty-state img { width: 96px; height: 96px; object-fit: contain; margin-bottom: 16px; }
.empty-state .empty-title { font-weight: 700; color: var(--text); font-size: 15px; margin-bottom: 6px; }
.empty-state .empty-subtitle { color: var(--text-muted); font-size: 13px; }

/* ---- Tables ---- */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--card-bg); border-radius: var(--radius-md); overflow: hidden; }
th, td { border-bottom: 1px solid var(--border); padding: 10px 12px; text-align: left; font-size: 14px; }
th { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }

/* ---- Misc form elements used across admin pages ----
   These are plain sibling inputs with no wrapping container on several forms
   (auditor_company_edit.php, enterprise_edit.php, auditors.php, ...) - the
   browser's default inline-block flow wraps them onto their own line at
   narrow widths with zero gap between rows, so they visually stick together.
   margin-bottom fixes that regardless of how many end up sharing a row. */
input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="email"], select, textarea {
    padding: 8px 10px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; font-size: 14px; margin-bottom: 8px;
}

/* ---- Block sections (audit_fill.php, audit_view.php, employee/audit_view.php) ---- */
.block-section { border-radius: var(--radius-lg); padding: 16px; margin-bottom: 24px; }
.block-heading { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; color: var(--text); border-bottom: 2px solid rgba(0,0,0,.12); padding-bottom: 8px; margin: 0 0 12px; }
.block-icon-done { color: var(--success-text); }
.block-progress { font-size: 12px; font-weight: 400; color: var(--text-muted); margin-left: auto; white-space: nowrap; }
.block-heading.is-sticky { position: sticky; top: 60px; z-index: 10; }

@media (min-width: 768px) {
    .block-heading.is-sticky { top: 0; }
}

/* ---- Jump-to-block header menu (mobile header only, same breakpoint as the main hamburger) ---- */
.blocks-nav { display: none; flex-direction: column; position: absolute; top: 100%; right: 16px; background: var(--card-bg); box-shadow: var(--shadow-card); border-radius: var(--radius-md); padding: 8px 0; max-height: 60vh; overflow-y: auto; z-index: 25; min-width: 200px; }
.blocks-nav.nav-open { display: flex; }
.blocks-nav a { color: var(--text); padding: 10px 16px; text-decoration: none; font-size: 14px; }
.blocks-nav a:hover { background: var(--bg); }

/* ---- Checklist editor: critical-question indicator ---- */
.question-number { font-weight: 700; }
.question-number.critical { background: var(--danger-text); color: #fff; border-radius: var(--radius-sm); padding: 2px 8px; }

/* ---- Floating save button + autosave toast (audit_fill.php) ---- */
.floating-save { position: fixed; right: 16px; bottom: 16px; z-index: 30; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.floating-save-btn { width: 52px; height: 52px; border-radius: 50%; background: var(--grad); color: #fff; border: none; box-shadow: var(--shadow-card); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.floating-save-btn svg { width: 24px; height: 24px; }
.save-toast { padding: 8px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; box-shadow: var(--shadow-card); opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s; pointer-events: none; }
.save-toast.visible { opacity: 1; transform: translateY(0); }
.save-toast.success { background: var(--success-bg); color: var(--success-text); }
.save-toast.error { background: var(--danger-bg); color: var(--danger-text); }

/* ---- Floating scroll-to-top button (audit_fill.php, audit_view.php) ---- */
.floating-scroll-top { position: fixed; right: 16px; bottom: 84px; z-index: 30; display: none; }
.floating-scroll-top.is-visible { display: block; }
.floating-scroll-top--alone { bottom: 16px; }

/* ---- Floating add button (checklist_edit.php) ---- */
.floating-add-btn { position: fixed; right: 16px; bottom: 16px; z-index: 30; }

/* ---- Rose chart (audit_view.php - completed audit view, auditor and employee) ---- */
.rose-chart-section { display: flex; flex-direction: column; align-items: center; gap: 16px; margin-bottom: 24px; }
.rose-chart-wrap { position: relative; }
.rose-chart-wrap svg { width: 280px; height: 280px; }
.rose-sector { transition: transform .15s ease-out, fill .15s ease-out, filter .15s ease-out; cursor: pointer; }
.rose-sector.is-active { transform: scale(1.06); filter: drop-shadow(0 3px 6px rgba(0,0,0,.3)); }
.rose-chart-ring { fill: none; stroke: #ddd; stroke-width: 1; stroke-dasharray: 3,3; }
.rose-chart-tooltip { position: absolute; display: none; pointer-events: none; background: rgba(30,30,30,.92); color: #fff; padding: 8px 12px; border-radius: 8px; font-size: 13px; line-height: 1.4; white-space: nowrap; z-index: 10; box-shadow: 0 4px 12px rgba(0,0,0,.25); }
.rose-chart-legend { display: flex; flex-direction: column; gap: 6px; }
.rose-chart-legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.rose-chart-swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; border: 1px solid rgba(0,0,0,.08); display: inline-block; }
.rose-chart-legend-link { background: none; border: none; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.rose-chart-legend-link:hover { text-decoration: underline; }

@media (min-width: 768px) {
    .rose-chart-section { flex-direction: row; align-items: center; justify-content: center; gap: 32px; }
}

.attachment-filename { display: inline-block; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }

.icon-offline-risk svg { color: var(--danger-text); cursor: pointer; }
.icon-offline-risk-tooltip { position: fixed; display: none; background: rgba(30,30,30,.92); color: #fff; padding: 8px 12px; border-radius: 8px; font-size: 13px; line-height: 1.4; max-width: 320px; z-index: 20; box-shadow: 0 4px 12px rgba(0,0,0,.25); }

/* ---- Settings page (settings.php) ---- */
.settings-section { max-width: 480px; }
.settings-field { margin-bottom: 20px; }
.settings-hint { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

/* ---- Modal overlay (settings.php quality help popup, audit_fill.php completion notice) ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; align-items: center; justify-content: center; }
.modal-box { background: var(--card-bg); border-radius: var(--radius-sm); padding: 24px; max-width: 480px; width: 90%; max-height: 80vh; overflow-y: auto; position: relative; box-shadow: var(--shadow-card); }
.modal-close-btn { position: absolute; top: 12px; right: 12px; }

/* ---- Modal icon badge (a large pictogram centered above a modal's text) ---- */
.modal-icon-badge { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.modal-icon-badge svg { width: 28px; height: 28px; }
.modal-icon-badge--warning { background: var(--warning-bg); color: var(--warning-text); }

/* ---- Offline mode (audit_fill.php): network status bar, parallel-access
   banner, and the "not yet uploaded" badge on locally-queued media ---- */
.network-status-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; font-weight: 600; }
.network-status-bar.offline { background: var(--danger-bg); color: var(--danger-text); }
.network-status-bar.pending { background: var(--warning-bg); color: var(--warning-text); }
.parallel-access-banner { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; background: var(--warning-bg); color: var(--warning-text); font-size: 13px; }
.parallel-access-banner svg { width: 20px; height: 20px; flex-shrink: 0; }
.media-thumb-pending { opacity: .6; }
.media-thumb-pending-badge { display: block; font-size: 10px; text-align: center; color: var(--warning-text); }

/* ---- Auditor multiselect (audit_start.php: which contractor auditors may
   conduct this audit) ---- */
.auditor-multiselect { border: 1.5px solid var(--border); border-radius: var(--radius-sm); width: 400px; max-width: 100%; background: var(--card-bg); }
.auditor-multiselect-summary { padding: 10px 12px; cursor: pointer; font-size: 14px; font-family: inherit; list-style: none; }
.auditor-multiselect-summary::-webkit-details-marker { display: none; }
.auditor-multiselect-panel { border-top: 1.5px solid var(--border); padding: 8px 12px; max-height: 240px; overflow-y: auto; }
.auditor-multiselect-group { margin-bottom: 10px; }
.auditor-multiselect-group-title { font-weight: 700; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 4px; }
.auditor-multiselect-option { display: block; font-weight: 400; font-size: 14px; padding: 4px 0; cursor: pointer; }
.auditor-multiselect-option input { margin-right: 6px; }

/* ---- Assigned-auditors line (audit_view.php / audit_fill.php, main auditor only) ---- */
.assigned-auditors-line { font-size: 14px; color: var(--text-muted); margin-bottom: 16px; }
