/* ═══════════════════════════════════════════════════════════════════════
   Gulf ESG Platform — Design System v2
   Forced light mode · Inter typeface · Professional SaaS aesthetic
   ═══════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* Force light mode regardless of OS preference */
:root { color-scheme: light only; }

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

/* ── Design tokens ──────────────────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg:          #f4f5f7;
  --bg2:         #ffffff;
  --surface:     #f9fafb;
  --surface2:    #f1f3f5;

  /* Borders */
  --border:      #e5e7eb;
  --border2:     #d1d5db;

  /* Text */
  --text:        #111827;
  --text2:       #4b5563;
  --text3:       #9ca3af;

  /* Brand accent — deep teal */
  --accent:      #0f6b5c;
  --accent-h:    #0a5549;
  --accent-lt:   #ecfdf5;
  --accent-mid:  #6ee7b7;

  /* Secondary — slate blue */
  --blue:        #3b5bdb;
  --blue-lt:     #eef2ff;

  /* Semantic */
  --green:       #166534;
  --green-lt:    #dcfce7;
  --amber:       #92400e;
  --amber-lt:    #fef3c7;
  --red:         #991b1b;
  --red-lt:      #fee2e2;
  --purple:      #5b21b6;
  --purple-lt:   #ede9fe;

  /* Sidebar */
  --sidebar-bg:  #0f1f2e;
  --sidebar-w:   232px;

  /* Shape */
  --r:           6px;
  --r-lg:        10px;
  --r-xl:        14px;

  /* Typography */
  --font: 'Inter', -apple-system, 'Helvetica Neue', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;

  /* Elevation */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:   0 20px 48px rgba(0,0,0,0.14), 0 8px 16px rgba(0,0,0,0.06);
}

/* ── Base ───────────────────────────────────────────────────────────── */
html { -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ── Login / Password change screens ───────────────────────────────── */
#login-screen, #changepw-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #0f1f2e 0%, #1a3a4a 100%);
}

.login-card {
  background: #ffffff;
  border-radius: var(--r-xl);
  padding: 44px 40px;
  width: min(420px, 90vw);
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.logo-mark-lg {
  width: 42px;
  height: 42px;
  background: var(--accent);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

/* ── App shell ──────────────────────────────────────────────────────── */
#app { display: flex; height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  -webkit-app-region: no-drag;
  border-right: 1px solid rgba(255,255,255,0.05);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-app-region: no-drag;
  /* GPU compositing for smooth scrolling */
  will-change: transform;
  transform: translateZ(0);
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

#main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
  -webkit-app-region: no-drag;
  will-change: scroll-position;
  transform: translateZ(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 28px 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  -webkit-app-region: drag;
  flex-shrink: 0;
}

.logo-mark {
  width: 30px;
  height: 30px;
  background: var(--accent);
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}

.logo-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #f9fafb;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.logo-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  margin-top: 1px;
  letter-spacing: 0.01em;
}

.logo-text { line-height: 1.3; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  padding: 16px 16px 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 14px 7px 16px;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  color: rgba(255,255,255,0.5);
  font-size: 12.5px;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
  -webkit-app-region: no-drag;
  letter-spacing: -0.01em;
  contain: layout style;
}

.nav-item:hover {
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.05);
}

.nav-item.active {
  color: #fff;
  background: rgba(255,255,255,0.08);
  border-left-color: var(--accent-mid);
  font-weight: 500;
}

.nav-icon {
  font-size: 13px;
  width: 16px;
  text-align: center;
  opacity: 0.8;
  flex-shrink: 0;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

#sidebar-user-info {
  margin-bottom: 10px;
  line-height: 1.5;
}

.btn-logout {
  width: 100%;
  padding: 7px 14px 7px 16px;
  background: transparent;
  border: none;
  border-left: 2px solid transparent;
  border-radius: 0;
  color: rgba(255,255,255,0.45);
  font-size: 12.5px;
  font-family: var(--font);
  cursor: pointer;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
  margin-top: 4px;
}

.btn-logout::before {
  content: '↪';
  font-size: 13px;
  width: 16px;
  text-align: center;
  opacity: 0.7;
  flex-shrink: 0;
}

.btn-logout:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.85);
  border-left-color: rgba(255,255,255,0.2);
}

/* ── View container ─────────────────────────────────────────────────── */
#view-container { padding: 28px 32px 40px; }

.view-content { max-width: 1200px; }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.view-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.view-header-actions,
.view-header > div:last-child {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ── Cards ──────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 0;
  margin-bottom: 16px;
  overflow: hidden;
}

.card > *:first-child:not(table):not(.table-wrap) {
  padding: 18px 20px;
}

.card > .table-wrap,
.card > table {
  padding: 0;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
}

/* Cards with direct padding (non-table content) */
.card-body { padding: 20px; }

/* ── Stat cards (dashboard) ─────────────────────────────────────────── */
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-icon { font-size: 20px; margin-bottom: 10px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -0.03em; line-height: 1; }
.stat-unit  { font-size: 11px; color: var(--text3); margin-top: 3px; }
.stat-label { font-size: 11px; color: var(--text2); margin-top: 6px; font-weight: 500; }

/* Metric grid (module views) */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.metric-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  border-top: 3px solid var(--border);
}

.metric-card.green  { border-top-color: #059669; }
.metric-card.amber  { border-top-color: #d97706; }
.metric-card.blue   { border-top-color: var(--blue); }
.metric-card.red    { border-top-color: #dc2626; }
.metric-card.purple { border-top-color: var(--purple); }

.metric-label { font-size: 11px; color: var(--text3); margin-bottom: 6px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.metric-value { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; line-height: 1.1; }
.metric-unit  { font-size: 11px; color: var(--text3); margin-left: 3px; font-weight: 400; }

/* ── Forms ──────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  padding: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group.span2 { grid-column: span 2; }
.form-group.span3 { grid-column: span 3; }

label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text2);
  letter-spacing: 0.01em;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
input[type="email"],
select,
textarea {
  padding: 7px 10px;
  border: 1px solid var(--border2);
  border-radius: var(--r);
  font-size: 12.5px;
  font-family: var(--font);
  background: var(--bg2);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15,107,92,0.1);
}

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

textarea { resize: vertical; min-height: 72px; }

.calc-field {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  border-color: var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
}

input[readonly] {
  background: var(--surface);
  color: var(--text2);
  cursor: default;
}

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--r);
  font-size: 12.5px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.12s;
  border: 1px solid transparent;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); }

.btn-secondary,
.btn {
  background: var(--bg2);
  color: var(--text);
  border-color: var(--border2);
}
.btn:hover,
.btn-secondary:hover { background: var(--surface); border-color: var(--border2); }

/* Override for primary — must come after base .btn */
.btn.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.btn-primary:hover { background: var(--accent-h); }

.btn-danger {
  background: var(--red-lt);
  color: var(--red);
  border-color: #fca5a5;
}
.btn-danger:hover { background: #fecaca; }

.btn-amber {
  background: var(--amber-lt);
  color: var(--amber);
  border-color: #fcd34d;
}
.btn-amber:hover { background: #fde68a; }

.btn-sm { padding: 4px 10px; font-size: 11.5px; }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--text3); font-size: 16px; padding: 4px; border-radius: var(--r); }
.btn-icon:hover { color: var(--text); background: var(--surface2); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Tables ─────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text3);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
}

tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: #f8fafc; }

.td-mono {
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* data table wrapper */
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text3);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #f8fafc; }

/* ── Badges ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.badge-green  { background: var(--green-lt);  color: var(--green); }
.badge-amber  { background: var(--amber-lt);  color: var(--amber); }
.badge-red    { background: var(--red-lt);    color: var(--red); }
.badge-blue   { background: var(--blue-lt);   color: var(--blue); }
.badge-purple { background: var(--purple-lt); color: var(--purple); }
.badge-gray   { background: var(--surface2);  color: var(--text2); }

/* ── Role tags ──────────────────────────────────────────────────────── */
.role-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.role-Admin        { background: var(--accent);  color: #fff; }
.role-ESGManager   { background: var(--blue);    color: #fff; }
.role-Approver     { background: #d97706;        color: #fff; }
.role-Submitter    { background: var(--text2);   color: #fff; }
.role-Auditor      { background: var(--purple);  color: #fff; }

/* ── Alerts ─────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--r);
  font-size: 12.5px;
  margin-bottom: 14px;
  line-height: 1.5;
}
.alert-warn   { background: var(--amber-lt); color: #7c2d12; border: 1px solid #fcd34d; }
.alert-info   { background: var(--blue-lt);  color: #1e3a8a; border: 1px solid #a5b4fc; }
.alert-ok     { background: var(--green-lt); color: var(--green); border: 1px solid #86efac; }
.alert-danger { background: var(--red-lt);   color: var(--red);   border: 1px solid #fca5a5; }

/* ── Modal ──────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--bg2);
  border-radius: var(--r-xl);
  width: min(660px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.modal-wide { width: min(860px, 94vw); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg2);
  z-index: 1;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text3);
  padding: 4px;
  border-radius: var(--r);
  line-height: 1;
  transition: all 0.1s;
}
.modal-close:hover { color: var(--text); background: var(--surface2); }

.modal-body { padding: 20px 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  bottom: 0;
}

/* ── Tabs ───────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 9px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  color: var(--text2);
  margin-bottom: -1px;
  transition: all 0.12s;
  letter-spacing: -0.01em;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 500;
}

.tab-btn:hover:not(.active) { color: var(--text); }

/* ── Misc components ────────────────────────────────────────────────── */
.flag-row td { background: #fffbeb !important; }

.empty-state {
  text-align: center;
  padding: 52px 24px;
  color: var(--text3);
}
.empty-icon { font-size: 32px; margin-bottom: 12px; opacity: 0.6; }
.empty-text { font-size: 14px; font-weight: 500; color: var(--text2); }
.empty-sub  { font-size: 12px; margin-top: 6px; color: var(--text3); }

.standards-row { display: flex; flex-wrap: wrap; gap: 6px; }
.std-pill {
  font-size: 10.5px;
  padding: 2px 9px;
  border-radius: 100px;
  border: 1px solid var(--border2);
  color: var(--text2);
  background: var(--surface);
  font-weight: 500;
}

/* ── Scrollbar ──────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Typography helpers ─────────────────────────────────────────────── */
strong { font-weight: 600; }
small  { font-size: 11px; color: var(--text3); }
hr     { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── Progress bar ───────────────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 100px;
  background: var(--accent);
  transition: width 0.3s ease;
}

/* ── Standards detail panel animation ───────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Context bar ────────────────────────────────────────────────────── */
#context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 32px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 var(--border);
}

/* ── Context selector overlay ───────────────────────────────────────── */
#context-selector-overlay select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15,107,92,0.1);
  outline: none;
}

/* ── Dashboard charts responsive ────────────────────────────────────── */
@media (max-width: 1100px) {
  .view-content > div[style*="grid-template-columns:1.1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}
