/* SafeWork Zone — Main Stylesheet */
/* Dark navy + safety orange, mobile-first, DM Sans */

:root {
  --navy: #0f1a2e;
  --navy-light: #1a2d4a;
  --navy-mid: #243650;
  --orange: #e8722a;
  --orange-hover: #d4631e;
  --orange-light: #fdf0e6;
  --green: #22a55b;
  --green-bg: #eafaf1;
  --red: #dc3545;
  --red-bg: #fdebed;
  --amber: #e6a817;
  --amber-bg: #fef9e7;
  --text: #1a1a2e;
  --text-light: #64748b;
  --text-muted: #94a3b8;
  --bg: #f0f2f5;
  --white: #ffffff;
  --border: #dde1e7;
  --border-light: #e8ecf1;
  --shadow-sm: 0 1px 3px rgba(15,26,46,0.08);
  --shadow: 0 2px 8px rgba(15,26,46,0.1);
  --shadow-lg: 0 8px 24px rgba(15,26,46,0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.2s ease;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.55; min-height: 100vh; }

/* ── NAV ── */
.nav { background: var(--navy); position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 12px rgba(15,26,46,0.3); }
.nav-inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; height: 56px; justify-content: space-between; }
.nav-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--white); font-weight: 700; font-size: 1.05rem; }
.nav-logo { font-size: 1.4rem; }
.nav-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.nav-toggle { display: flex; flex-direction: column; gap: 4px; background: none; border: none; cursor: pointer; padding: 8px; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--white); border-radius: 2px; transition: var(--transition); }
.nav-toggle.open span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }
.nav-menu { display: none; position: absolute; top: 56px; left: 0; right: 0; background: var(--navy-light); padding: 8px 0; box-shadow: var(--shadow-lg); }
.nav-menu.open { display: block; }
.nav-link { display: block; padding: 12px 20px; color: rgba(255,255,255,0.75); text-decoration: none; font-weight: 500; font-size: 0.95rem; transition: var(--transition); }
.nav-link:hover, .nav-link.active { color: var(--white); background: rgba(255,255,255,0.06); }
.nav-link.active { border-left: 3px solid var(--orange); padding-left: 17px; }
.nav-link-logout { color: rgba(255,255,255,0.45); }
.nav-spacer { display: none; }

@media (min-width: 768px) {
  .nav-toggle { display: none; }
  .nav-menu { display: flex !important; position: static; background: none; box-shadow: none; padding: 0; align-items: center; gap: 2px; }
  .nav-link { padding: 8px 14px; border-radius: var(--radius-sm); border-left: none !important; padding-left: 14px !important; font-size: 0.875rem; }
  .nav-link.active { background: rgba(255,255,255,0.1); }
  .nav-spacer { display: block; flex: 1; }
  .nav-link-settings, .nav-link-logout { font-size: 0.82rem; }
}

/* ── MAIN ── */
.main-app { max-width: 1200px; margin: 0 auto; padding: 20px 16px 80px; }
.main-auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }

/* ── PAGE HEADER ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--navy); }
.page-header .subtitle { font-size: 0.9rem; color: var(--text-light); margin-top: 2px; }

/* ── CARDS ── */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border-light); overflow: hidden; transition: box-shadow var(--transition); }
.card:hover { box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; justify-content: space-between; }
.card-header h2 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 20px; }
.card-footer { padding: 16px 20px; border-top: 1px solid var(--border-light); background: #fafbfc; }

/* ── STAT CARDS ── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { background: var(--white); border-radius: var(--radius); padding: 18px 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border-light); text-align: center; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--navy); line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-light); margin-top: 6px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card.orange .stat-value { color: var(--orange); }
.stat-card.red .stat-value { color: var(--red); }
.stat-card.green .stat-value { color: var(--green); }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px; font-family: var(--font); font-size: 0.9rem; font-weight: 600; border: none; border-radius: var(--radius-sm); cursor: pointer; text-decoration: none; transition: all var(--transition); line-height: 1.3; white-space: nowrap; }
.btn-primary { background: var(--orange); color: var(--white); }
.btn-primary:hover { background: var(--orange-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(232,114,42,0.35); }
.btn-secondary { background: var(--navy); color: var(--white); }
.btn-secondary:hover { background: var(--navy-light); }
.btn-outline { background: var(--white); color: var(--navy); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--navy); background: #f8f9fa; }
.btn-danger { background: var(--red); color: var(--white); }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-block { display: flex; justify-content: center; width: 100%; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── FORMS ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--navy); margin-bottom: 6px; }
.form-hint { font-size: 0.8rem; color: var(--text-light); margin-top: 4px; }
.form-control { width: 100%; padding: 10px 14px; font-family: var(--font); font-size: 0.95rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--white); color: var(--text); transition: border-color var(--transition); }
.form-control:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(232,114,42,0.12); }
textarea.form-control { min-height: 80px; resize: vertical; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

/* ── CHECKBOXES ── */
.checkbox-group { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-item { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: #f8f9fa; border: 1.5px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition); font-size: 0.88rem; user-select: none; }
.checkbox-item:hover { border-color: var(--orange); background: var(--orange-light); }
.checkbox-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--orange); cursor: pointer; flex-shrink: 0; }
.checkbox-item.checked, .checkbox-item:has(input:checked) { background: var(--orange-light); border-color: var(--orange); }
.checkbox-single { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 0.9rem; cursor: pointer; }
.checkbox-single input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--orange); }
.checkbox-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; padding: 4px 0; }
.checkbox-select-all { border-bottom: 1.5px solid var(--border); padding-bottom: 10px; margin-bottom: 4px; border-radius: 0; }
.worker-role-label { color: var(--text-light); font-size: 0.82rem; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th { background: var(--navy); color: var(--white); padding: 10px 14px; text-align: left; font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--border-light); vertical-align: top; }
tr:hover td { background: #fafbfc; }
.table-empty { text-align: center; padding: 40px 20px; color: var(--text-light); }

/* ── BADGES / STATUS ── */
.badge { display: inline-block; padding: 3px 10px; font-size: 0.75rem; font-weight: 600; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.3px; }
.badge-active, .badge-open { background: #e0f2fe; color: #0369a1; }
.badge-draft { background: #f1f5f9; color: var(--text-light); }
.badge-completed, .badge-closed { background: var(--green-bg); color: #166534; }
.badge-archived { background: #f1f5f9; color: #64748b; }
.badge-in_progress, .badge-under_investigation { background: var(--amber-bg); color: #92400e; }

/* Risk badges */
.risk-very_low { background: #e0f2fe; color: #0369a1; }
.risk-low { background: var(--green-bg); color: #166534; }
.risk-moderate { background: var(--amber-bg); color: #92400e; }
.risk-high { background: #fed7aa; color: #9a3412; }
.risk-critical { background: var(--red-bg); color: #991b1b; }

/* ── FLASH MESSAGES ── */
.flash { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 0.9rem; font-weight: 500; animation: slideIn 0.3s ease; }
.flash-success { background: var(--green-bg); color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: var(--red-bg); color: #991b1b; border: 1px solid #fecdd3; }
.flash-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: inherit; opacity: 0.6; padding: 0 4px; }

/* ── AUTH PAGES ── */
.auth-card { width: 100%; max-width: 420px; background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.auth-header { background: var(--navy); padding: 32px 28px; text-align: center; }
.auth-header h1 { color: var(--white); font-size: 1.5rem; font-weight: 700; }
.auth-header .brand { color: var(--orange); font-size: 2rem; display: block; margin-bottom: 8px; }
.auth-header p { color: rgba(255,255,255,0.6); font-size: 0.88rem; margin-top: 6px; }
.auth-body { padding: 28px; }
.auth-footer { text-align: center; padding: 0 28px 24px; font-size: 0.88rem; color: var(--text-light); }
.auth-footer a { color: var(--orange); font-weight: 600; text-decoration: none; }
.auth-error { background: var(--red-bg); color: #991b1b; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 0.88rem; margin-bottom: 16px; }

/* ── TABS ── */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border-light); margin-bottom: 20px; overflow-x: auto; }
.tab { padding: 10px 18px; font-size: 0.88rem; font-weight: 600; color: var(--text-light); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; transition: var(--transition); }
.tab:hover { color: var(--text); }
.tab.active { color: var(--orange); border-bottom-color: var(--orange); }

/* ── JOB/ITEM CARDS ── */
.item-list { display: grid; gap: 12px; }
.item-card { display: block; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border-light); padding: 16px 20px; text-decoration: none; color: var(--text); transition: all var(--transition); }
.item-card:hover { box-shadow: var(--shadow); border-color: var(--orange); transform: translateY(-1px); }
.item-card h3 { font-size: 1rem; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.item-card .meta { font-size: 0.82rem; color: var(--text-light); display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; }
.item-card .meta span { display: flex; align-items: center; gap: 4px; }

/* ── TEMPLATE GRID ── */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.template-card { background: var(--white); border: 2px solid var(--border-light); border-radius: var(--radius); padding: 18px; cursor: pointer; transition: all var(--transition); text-decoration: none; color: var(--text); }
.template-card:hover, .template-card.selected { border-color: var(--orange); box-shadow: var(--shadow); }
.template-card.selected { background: var(--orange-light); }
.template-card h3 { font-size: 0.95rem; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.template-card .trade { font-size: 0.78rem; color: var(--orange); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.template-card p { font-size: 0.82rem; color: var(--text-light); margin-top: 8px; line-height: 1.4; }
.template-match { border-color: var(--orange); opacity: 0.85; }

/* ── SWMS STEP CARD ── */
.step-card { background: var(--white); border: 1.5px solid var(--border-light); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; transition: all var(--transition); }
.step-card.inactive { opacity: 0.5; }
.step-header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: #fafbfc; border-bottom: 1px solid var(--border-light); }
.step-number { width: 32px; height: 32px; background: var(--navy); color: var(--white); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
.step-header h3 { font-size: 0.92rem; font-weight: 600; flex: 1; }
.step-body { padding: 14px 16px; }
.step-body .field { margin-bottom: 10px; }
.step-body .field-label { font-size: 0.78rem; color: var(--text-light); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 3px; }
.step-body .field-value { font-size: 0.88rem; line-height: 1.5; }

/* ── WORKER ACKNOWLEDGEMENT ── */
.worker-list { display: grid; gap: 10px; }
.worker-item { display: flex; align-items: center; gap: 12px; background: var(--white); border: 1.5px solid var(--border-light); border-radius: var(--radius-sm); padding: 12px 16px; }
.worker-item.acknowledged { background: var(--green-bg); border-color: #86efac; }
.worker-item .worker-info { flex: 1; }
.worker-item .worker-name { font-weight: 600; font-size: 0.92rem; }
.worker-item .worker-role { font-size: 0.8rem; color: var(--text-light); }
.worker-item .worker-time { font-size: 0.78rem; color: var(--green); font-weight: 500; }
.worker-check { font-size: 1.3rem; color: var(--green); }

/* ── DETAIL SECTIONS ── */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; margin-bottom: 20px; }
.detail-item label { display: block; font-size: 0.78rem; color: var(--text-light); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 2px; }
.detail-item span, .detail-item p { font-size: 0.92rem; color: var(--text); }

/* ── EMPTY STATES ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-light); }
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1.1rem; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 0.9rem; margin-bottom: 20px; }

/* ── QUICK ACTIONS ── */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 24px; }
.quick-action { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 12px; background: var(--white); border: 1.5px solid var(--border-light); border-radius: var(--radius); text-decoration: none; color: var(--navy); font-weight: 600; font-size: 0.85rem; transition: all var(--transition); text-align: center; }
.quick-action:hover { border-color: var(--orange); box-shadow: var(--shadow); transform: translateY(-2px); }
.quick-action .qa-icon { font-size: 1.6rem; }

/* ── FILTERS ── */
.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filter-bar select, .filter-bar input { padding: 8px 12px; font-size: 0.85rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--white); font-family: var(--font); }

/* ── DISCLAIMER ── */
.disclaimer { background: var(--amber-bg); border: 1px solid #fcd34d; border-radius: var(--radius-sm); padding: 12px 16px; font-size: 0.82rem; color: #92400e; margin-bottom: 20px; line-height: 1.5; }
.disclaimer strong { display: block; margin-bottom: 4px; }

/* ── NOTIFIABLE BANNER ── */
.banner-warning { background: var(--red-bg); border: 1px solid #fecdd3; border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 16px; font-size: 0.88rem; color: #991b1b; font-weight: 500; }

/* ── PDF PRINT VIEW ── */
.pdf-view { max-width: 800px; margin: 0 auto; padding: 20px; font-size: 10pt; }
.pdf-view table { font-size: 9pt; }
.pdf-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 3px solid var(--navy); padding-bottom: 16px; margin-bottom: 20px; }
.pdf-header h1 { font-size: 16pt; color: var(--navy); }
.pdf-biz-details { font-size: 9pt; color: var(--text-light); text-align: right; }

/* ── ANIMATIONS ── */
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ── SECTION HEADING ── */
.section-heading { font-size: 1.05rem; font-weight: 700; color: var(--navy); margin: 28px 0 14px; padding-bottom: 8px; border-bottom: 2px solid var(--border-light); }

/* ── UTILITY ── */
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-light { color: var(--text-light); }
.text-sm { font-size: 0.82rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.hidden { display: none !important; }
.collapsible-toggle { cursor: pointer; color: var(--orange); font-size: 0.82rem; font-weight: 600; background: none; border: none; font-family: var(--font); }
.collapsible-content { display: none; margin-top: 8px; }
.collapsible-content.open { display: block; }

/* ── BOTTOM ACTION BAR (mobile) ── */
.bottom-bar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--white); border-top: 1px solid var(--border); padding: 12px 16px; box-shadow: 0 -4px 12px rgba(0,0,0,0.08); z-index: 50; display: flex; gap: 8px; }
.bottom-bar .btn { flex: 1; justify-content: center; }
@media (min-width: 768px) { .bottom-bar { position: static; border: none; box-shadow: none; padding: 20px 0 0; background: transparent; justify-content: flex-end; } }

/* ── RESPONSIVE ── */
@media (min-width: 768px) {
  .main-app { padding: 28px 24px 40px; }
  .page-header h1 { font-size: 1.75rem; }
  .stats { grid-template-columns: repeat(4, 1fr); }
}
