/* VMSquad — UAE Vendor Management Platform
   Shared stylesheet: Buyer Console, Vendor Portal, Contractor App
   Locale: en-AE  |  Currency: AED  |  Date: dd/MM/yyyy
   WCAG 2.2 AA compliant colors and focus states */

/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
  --primary: #0A4D8C;      /* UAE corporate blue */
  --primary-dark: #073a6a;
  --accent: #E8A838;        /* UAE gold accent */
  --accent-dark: #c88a1e;
  --success: #1a7a4a;
  --warning: #c47a0a;
  --danger: #b91c1c;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f0f4f8;
  --border: #d1dce8;
  --text: #1a2b3c;
  --text-muted: #5a7080;
  --text-light: #8aa4b8;
  --radius: 6px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ─── Reset + Base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Typography ─────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 { font-weight: 600; line-height: 1.25; color: var(--text); }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* ─── Layout Shell ───────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar Navigation ─────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: var(--primary);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.sidebar-logo h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  letter-spacing: -0.02em;
}

.sidebar-logo span {
  display: block;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.55);
  margin-top: 2px;
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,0.75);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.1);
  color: white;
  text-decoration: none;
}

.sidebar-nav a.active {
  background: rgba(255,255,255,0.15);
  color: white;
  border-left: 3px solid var(--accent);
}

.sidebar-nav a svg { width: 18px; height: 18px; opacity: 0.8; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.75rem;
  color: rgba(255,255,255,0.4);
}

/* ─── Main Content ───────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.topbar-breadcrumb { font-size: 0.8rem; color: var(--text-muted); }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.notif-btn {
  position: relative;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  transition: border-color 0.15s;
}

.notif-btn:hover { border-color: var(--primary); color: var(--primary); }
.notif-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.notif-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--danger);
  color: white;
  border-radius: 50%;
  width: 16px; height: 16px;
  font-size: 0.65rem;
  display: flex; align-items: center; justify-content: center;
}

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text);
  transition: border-color 0.15s;
}
.user-menu-btn:hover { border-color: var(--primary); }

.page-content {
  flex: 1;
  padding: 24px;
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2, .card-header h3 { font-size: 0.95rem; font-weight: 600; }

.card-body { padding: 18px; }
.card-body + .card-body { border-top: 1px solid var(--border); }

.card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ─── Metric Cards ───────────────────────────────────────────────────────── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.metric-card .metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 6px;
}

.metric-card .metric-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.metric-card .metric-sub {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 4px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: var(--surface-2);
  padding: 10px 14px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--surface-2); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

td { padding: 11px 14px; vertical-align: middle; }
td .cell-primary { font-weight: 600; color: var(--text); }
td .cell-muted { color: var(--text-muted); font-size: 0.8rem; }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-open    { background: #d1fae5; color: #065f46; }
.badge-active  { background: #dbeafe; color: #1e40af; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-draft   { background: #f3f4f6; color: #374151; }
.badge-filled  { background: #d1fae5; color: #065f46; }
.badge-rejected, .badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-submitted { background: #dbeafe; color: #1e40af; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: white; }

.btn-accent { background: var(--accent); color: var(--text); }
.btn-accent:hover { background: var(--accent-dark); text-decoration: none; }

.btn-outline {
  background: none;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; text-decoration: none; }

.btn-ghost {
  background: none;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); text-decoration: none; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #991b1b; text-decoration: none; }

.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}
.form-label span.required { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: var(--font);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10, 77, 140, 0.12);
}

.form-control:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.form-control::placeholder { color: var(--text-light); }
.form-control.error { border-color: var(--danger); }
.form-control:disabled { background: var(--surface-2); color: var(--text-muted); }

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' viewBox='0 0 20 20' fill='%235a7080'%3E%3Cpath d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; padding-right: 36px; }

.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 3px; }
.form-error { font-size: 0.75rem; color: var(--danger); margin-top: 3px; }

.form-row { display: grid; gap: 16px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ─── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-icon { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.alert-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.alert-danger  { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-info    { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }

/* ─── Auth Pages ────────────────────────────────────────────────────────── */
.auth-shell {
  min-height: 100vh;
  background: linear-gradient(135deg, #0A4D8C 0%, #073a6a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo h1 { font-size: 1.5rem; color: var(--primary); font-weight: 700; }
.auth-logo p { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--surface-2);
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 8px 0;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.auth-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

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

.tab-btn {
  padding: 8px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* ─── Pagination ─────────────────────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; align-items: center; margin-top: 16px; }
.pagination .page-info { font-size: 0.8rem; color: var(--text-muted); margin-left: auto; }

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

/* ─── Score Indicator ───────────────────────────────────────────────────── */
.score-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 0.875rem;
  font-weight: 700;
}

.score-high { background: #d1fae5; color: #065f46; }
.score-med  { background: #fef3c7; color: #92400e; }
.score-low  { background: #fee2e2; color: #991b1b; }

/* ─── Section Headers ────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title { font-size: 1.1rem; font-weight: 600; }

/* ─── Utility ───────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-sm { font-size: 0.8rem; }
.text-xs { font-size: 0.72rem; }
.text-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex  { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ─── Notification Panel ───────────────────────────────────────────────── */
.notif-panel {
  position: fixed;
  top: 56px;
  right: 24px;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 200;
  max-height: 480px;
  overflow-y: auto;
}

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--surface-2);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
  transition: background 0.1s;
}

.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: #f0f7ff; }
.notif-item.unread:hover { background: #e8f2ff; }

.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 5px; }
.notif-content { flex: 1; }
.notif-title { font-size: 0.8rem; font-weight: 600; color: var(--text); }
.notif-msg { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.notif-time { font-size: 0.7rem; color: var(--text-light); margin-top: 3px; }

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

.modal {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.modal-header h2 { font-size: 1.1rem; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); line-height: 1; padding: 0; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ─── Mobile Contractor App Styles ───────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 56px; overflow: visible; }
  .sidebar-logo h1, .sidebar-logo span, .sidebar-nav span, .sidebar-footer { display: none; }
  .sidebar-nav a { padding: 12px; justify-content: center; }
  .main-content { margin-left: 56px; }
  .page-content { padding: 16px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar-title { display: none; }
}

@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .app-shell { flex-direction: column; }
}

/* ─── RTL Stub (Arabic support) ──────────────────────────────────────────── */
[dir="rtl"] { direction: rtl; }
[dir="rtl"] .sidebar { left: auto; right: 0; }
[dir="rtl"] .main-content { margin-left: 0; margin-right: 240px; }

/* ─── Focus & Accessibility ─────────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* Skip link */
.skip-link {
  position: absolute;
  top: -40px; left: 0;
  background: var(--primary);
  color: white;
  padding: 8px 16px;
  z-index: 999;
  transition: top 0.2s;
  font-weight: 600;
  border-radius: 0 0 4px 0;
}
.skip-link:focus { top: 0; color: white; }