/* ═══════════════════════════════════════════════════════
   Toyota Sub Contract Survey — styles.css
   ═══════════════════════════════════════════════════════ */

:root {
  --toyota-red:   #EB0A1E;
  --toyota-red-dk:#c5081a;
  --bg:           #F5F5F5;
  --bg-white:     #FFFFFF;
  --bg-surface:   #FAFAFA;
  --border:       rgba(0,0,0,0.10);
  --border-strong:rgba(0,0,0,0.18);
  --text:         #1A1A1A;
  --text-2:       #555555;
  --text-3:       #888888;
  --green:        #1B8A4C;
  --green-bg:     #EAF7EF;
  --green-text:   #0e5a31;
  --red-bg:       #FEF0F0;
  --red-text:     #991B1B;
  --amber:        #B45309;
  --amber-bg:     #FEF3CD;
  --amber-text:   #7C3D08;
  --blue-bg:      #EEF5FD;
  --blue-text:    #1a4a7a;
  --purple-bg:    #F3EEFF;
  --purple-text:  #5B21B6;
  --gray-bg:      #F1F0EB;
  --gray-text:    #444;
  --radius:       8px;
  --radius-lg:    12px;
  --radius-xl:    16px;
  --shadow:       0 1px 4px rgba(0,0,0,0.08);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.12);
}

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

body {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Topbar ──────────────────────────────────────────── */
.topbar {
  background: var(--toyota-red);
  color: #fff;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-logo { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.topbar-logo i { font-size: 20px; }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 12px; }
.topbar-badge { background: rgba(255,255,255,0.2); padding: 3px 12px; border-radius: 20px; font-size: 11px; font-weight: 500; }

@media (max-width: 640px) {
  .topbar {
    height: auto; flex-wrap: wrap; row-gap: 6px; padding: 10px 14px;
  }
  .topbar-logo { font-size: 13px; flex-wrap: wrap; row-gap: 2px; }
  .topbar-logo small { display: block; margin-left: 0; margin-top: 2px; }
  .topbar-right { font-size: 11px; flex-wrap: wrap; row-gap: 6px; }
}

/* ── Role switcher ───────────────────────────────────── */
.role-switcher {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.role-tabs { display: flex; gap: 6px; }
.role-tab {
  padding: 6px 16px; border-radius: 20px; font-size: 12px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border-strong);
  background: var(--bg-surface); color: var(--text-2);
  font-family: inherit; transition: all .15s;
  display: flex; align-items: center; gap: 6px;
}
.role-tab i { font-size: 13px; }
.role-tab.active { background: var(--toyota-red); color: #fff; border-color: var(--toyota-red); }
.period-label { font-size: 11px; color: var(--text-3); }

/* ── Layout ──────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: calc(100vh - 100px);
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: 210px;
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  flex-shrink: 0;
  min-height: calc(100vh - 100px);
}
.nav-section {
  font-size: 10px; color: var(--text-3);
  padding: 12px 18px 4px;
  text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600;
}
.nav-item {
  padding: 9px 18px; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; gap: 9px;
  color: var(--text-2); border-left: 3px solid transparent;
  transition: all .12s; user-select: none; position: relative;
}
.nav-item i { font-size: 16px; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: #FEF0F0; color: var(--toyota-red); border-left-color: var(--toyota-red); font-weight: 600; }
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--toyota-red); color: #fff;
  border-radius: 20px; font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: auto;
}
.nav-badge:empty { display: none; }

/* ── Main content ────────────────────────────────────── */
.main-content { flex: 1; padding: 24px; overflow: auto; min-width: 0; }
.page { display: none; }
.page.active { display: block; }
.page-header { margin-bottom: 20px; }
.page-title { font-size: 18px; font-weight: 600; }
.page-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 13px; font-weight: 600; margin-bottom: 14px;
  display: flex; align-items: center; gap: 6px;
}
.card-title i { font-size: 15px; color: var(--toyota-red); }
.card-desc { font-size: 12px; color: var(--text-3); line-height: 1.6; }

/* ── Metrics ─────────────────────────────────────────── */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.metric {
  background: var(--bg-white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow);
}
.metric-label { font-size: 10px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.metric-value { font-size: 26px; font-weight: 600; line-height: 1; }
.metric-sub { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.compact-metrics { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.compact-metrics .metric { flex: 0 0 200px; padding: 10px 12px; margin-bottom: 0; }
.compact-metrics .metric-value { font-size: 20px; }
.compact-metrics .metric-label { font-size: 9px; margin-bottom: 4px; }

/* ── Tables ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 8px 12px;
  color: var(--text-3); border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.4px; background: var(--bg-surface); white-space: nowrap;
}
td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-surface); }

/* ── Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge i { font-size: 10px; }
.badge-green  { background: var(--green-bg);  color: var(--green-text); }
.badge-red    { background: var(--red-bg);    color: var(--red-text); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber-text); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue-text); }
.badge-purple { background: var(--purple-bg); color: var(--purple-text); }
.badge-gray   { background: var(--gray-bg);   color: var(--gray-text); }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  padding: 7px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border-strong);
  background: var(--bg-white); color: var(--text);
  font-family: inherit; transition: all .12s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn i { font-size: 13px; }
.btn-primary { background: var(--toyota-red); color: #fff; border-color: var(--toyota-red); }
.btn-primary:hover { background: var(--toyota-red-dk); }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-sm i { font-size: 12px; }
.btn-danger  { background: var(--red-bg);  color: var(--red-text);  border-color: #f5b8b8; }
.btn-danger:hover  { background: #f5c6c6; }
.btn-success { background: var(--green-bg); color: var(--green-text); border-color: #a8dfc0; }
.btn-success:hover { background: #d1f0e0; }
.btn-amber   { background: var(--amber-bg); color: var(--amber-text); border-color: #f0d495; }
.btn-amber:hover   { background: #fde9a8; }

/* ── Alerts ──────────────────────────────────────────── */
.alert {
  border-radius: var(--radius); padding: 11px 14px; margin-bottom: 14px;
  display: flex; align-items: flex-start; gap: 10px; font-size: 13px;
  border-left: 4px solid transparent;
}
.alert i { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.alert-warning { background: var(--amber-bg); color: var(--amber-text); border-left-color: var(--amber); }
.alert-danger  { background: var(--red-bg);   color: var(--red-text);   border-left-color: #E24B4A; }
.alert-info    { background: var(--blue-bg);  color: var(--blue-text);  border-left-color: #378ADD; }

/* ── Forms ───────────────────────────────────────────── */
.filter-bar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.form-input {
  padding: 8px 11px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); font-size: 13px;
  background: var(--bg-white); color: var(--text);
  font-family: inherit; transition: border-color .12s;
}
.form-input:focus { outline: none; border-color: var(--toyota-red); }
select.form-input { cursor: pointer; }

/* ── Progress ────────────────────────────────────────── */
.progress-bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--toyota-red); transition: width .4s; }

/* ── Submit meta ─────────────────────────────────────── */
.submit-meta {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; margin-top: 12px;
}
.submit-meta-title { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.submit-meta-row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 12px; color: var(--text-2); }
.submit-meta-row span:last-child { font-weight: 600; color: var(--text); }

/* ── Dashboard dept grid ─────────────────────────────── */
.dept-grid { display: flex; flex-direction: column; gap: 8px; }
.dept-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }

/* ── Modals ──────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-white); border-radius: var(--radius-xl);
  padding: 24px; width: 480px; max-width: 95vw;
  border: 1px solid var(--border); box-shadow: var(--shadow-md);
  animation: modalIn .18s ease;
}
@keyframes modalIn { from { transform: translateY(-16px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.modal-sub { font-size: 12px; color: var(--text-3); margin-bottom: 18px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.modal-info {
  background: var(--blue-bg); border-radius: var(--radius);
  padding: 9px 12px; font-size: 12px; color: var(--blue-text);
  display: flex; gap: 6px; align-items: flex-start;
}
.modal-info i { flex-shrink: 0; margin-top: 1px; }

/* ── Detail modal ────────────────────────────────────── */
.detail-field { background: var(--bg-surface); border-radius: var(--radius); padding: 8px 10px; }
.detail-label { display: block; font-size: 10px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 2px; }

/* ── Toast ───────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #1A1A1A; color: #fff;
  border-radius: var(--radius); padding: 11px 18px;
  font-size: 13px; z-index: 999;
  display: flex; gap: 8px; align-items: center;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: all .2s; max-width: 340px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
#toast.show { opacity: 1; transform: none; pointer-events: auto; }
#toast.error { background: var(--toyota-red); }
#toast i { font-size: 14px; }

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* ── Login overlay fix ───────────────────────────────── */
#login-error[style*="flex"] { display: flex !important; }

/* ── Missing badge class fix ─────────────────────────── */
.badge-green  { background: var(--green-bg);  color: var(--green-text);  border: 1px solid rgba(27,138,76,0.15); }
.badge-red    { background: var(--red-bg);    color: var(--red-text);    border: 1px solid rgba(235,10,30,0.15); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber-text);  border: 1px solid rgba(180,83,9,0.15); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue-text);   border: 1px solid rgba(37,99,235,0.15); }
.badge-purple { background: var(--purple-bg); color: var(--purple-text); border: 1px solid rgba(91,33,182,0.15); }
.badge-gray   { background: var(--gray-bg);   color: var(--gray-text);   border: 1px solid rgba(0,0,0,0.08); }

/* ── Card desc consistent spacing ────────────────────── */
.card-desc + * { margin-top: 0; }

/* ── Export page count label ─────────────────────────── */
#export-xlsx-count { color: var(--blue-text); background: var(--blue-bg); padding: 4px 10px; border-radius: 6px; display: inline-block; }

/* ── Table thead sticky ──────────────────────────────── */
.table-wrap thead th { position: sticky; top: 0; z-index: 2; }

/* ── Topbar logout btn ───────────────────────────────── */
#logout-btn { transition: background .15s; }

/* ── Print styles (PDF export page) ─────────────────── */
@media print {
  .topbar, .role-switcher, .sidebar, #logout-btn { display: none !important; }
}

/* ── Notification bell (topbar, all 4 portals) ──────────── */
.notif-bell-wrap { position: relative; }
#notif-bell-btn {
  background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3);
  color: #fff; border-radius: 50%; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative; font-family: inherit;
}
#notif-bell-btn i { font-size: 16px; }
.notif-badge {
  position: absolute; top: -4px; right: -4px; background: #E24B4A; color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 10px; min-width: 16px; height: 16px;
  padding: 0 4px; display: flex; align-items: center; justify-content: center; line-height: 1;
}
.notif-dropdown {
  position: absolute; top: 42px; right: 0; width: 340px; max-height: 420px;
  overflow-y: auto; background: var(--bg-white); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md); z-index: 300; color: var(--text-1);
  border: 1px solid var(--border);
}
.notif-dropdown-header {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.notif-dropdown-header b { font-size: 13px; }
.notif-dropdown-header button {
  font-size: 11px; color: #2563EB; background: none; border: none; cursor: pointer; font-family: inherit;
}
.notif-list { padding: 6px; }
.notif-item {
  display: block; padding: 9px 10px; border-radius: 8px; cursor: pointer;
  text-decoration: none; color: inherit;
}
.notif-item:hover { background: var(--bg-surface); }
.notif-item.unread { background: var(--blue-bg); }
.notif-item-title { font-size: 12px; font-weight: 600; margin-bottom: 2px; color: #000; }
.notif-item-body { font-size: 11px; color: #000; margin-bottom: 3px; }
.notif-item-time { font-size: 10px; color: #000; }
.notif-empty { padding: 24px 12px; text-align: center; font-size: 12px; color: var(--text-3); }
.notif-dropdown-footer {
  padding: 10px; text-align: center; border-top: 1px solid var(--border);
}
.notif-dropdown-footer a { font-size: 12px; color: #2563EB; text-decoration: none; }

/* Row a clicked notification navigates to and points at (see notifications.js consumeNotifHighlight) */
tr.row-highlight { background: var(--amber-bg) !important; transition: background 2s ease; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .sidebar { width: 170px; }
}
@media (max-width: 640px) {
  .sidebar { display: none; }
  .main-content { padding: 14px; }
  .metrics { grid-template-columns: 1fr 1fr; }
}
