/* ============================================================
   AFIAT PORTAL — shared.css
   Design System: Apple-inspired Glassmorphism
   afiat.synco.group
   ============================================================ */

/* ── SF Pro + Inter fallback ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;1,14..32,400&display=swap');

/* ── CSS Variables ── */
:root {
  /* Core palette */
  --apple-blue:    #007AFF;
  --apple-green:   #34C759;
  --apple-red:     #FF3B30;
  --apple-orange:  #FF9500;
  --apple-yellow:  #FFCC00;

  /* Neutral scale */
  --black:         #000000;
  --gray-900:      #1D1D1F;
  --gray-800:      #2C2C2E;
  --gray-700:      #3A3A3C;
  --gray-600:      #48484A;
  --gray-500:      #636366;
  --gray-400:      #8E8E93;
  --gray-300:      #AEAEB2;
  --gray-200:      #C7C7CC;
  --gray-100:      #E5E5EA;
  --gray-50:       #F2F2F7;
  --off-white:     #F5F5F7;
  --white:         #FFFFFF;

  /* Semantic */
  --bg-primary:    #F5F5F7;
  --bg-secondary:  #FFFFFF;
  --bg-dark:       #1D1D1F;
  --text-primary:  #1D1D1F;
  --text-secondary:#636366;
  --text-tertiary: #AEAEB2;
  --border:        rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.15);

  /* Glass */
  --glass-bg:      rgba(255,255,255,0.72);
  --glass-border:  rgba(255,255,255,0.5);
  --glass-shadow:  0 8px 32px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
  --glass-dark-bg: rgba(29,29,31,0.78);

  /* Blur */
  --blur-sm:       blur(8px);
  --blur-md:       blur(16px);
  --blur-lg:       blur(24px);

  /* Radius — continuous curvature squircle approximation */
  --radius-xs:     6px;
  --radius-sm:     10px;
  --radius-md:     14px;
  --radius-lg:     18px;
  --radius-xl:     24px;
  --radius-2xl:    32px;
  --radius-full:   9999px;

  /* Typography — SF Pro stack */
  --font:          -apple-system, 'SF Pro Text', 'SF Pro Display', 'Inter', BlinkMacSystemFont, sans-serif;
  --font-display:  -apple-system, 'SF Pro Display', 'SF Pro Text', 'Inter', BlinkMacSystemFont, sans-serif;

  /* Transitions */
  --ease:          cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-spring:   cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast:      120ms;
  --dur-mid:       220ms;
  --dur-slow:      380ms;

  /* Shadows */
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.05);
  --shadow-lg:     0 12px 40px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-blue:   0 4px 20px rgba(0,122,255,0.30);

  /* Dept colours */
  --dept-qc:       #007AFF;
  --dept-marketing:#FF9500;
  --dept-maint:    #AF52DE;
  --dept-prodst:   #34C759;
  --dept-prod:     #00C7BE;
  --dept-sales:    #FF3B30;
  --dept-hr:       #FF6B6B;
  --dept-admin:    #636366;
  --dept-proc:     #FFCC00;
}

/* ── Dark Mode ── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary:    #000000;
    --bg-secondary:  #1C1C1E;
    --text-primary:  #F5F5F7;
    --text-secondary:#AEAEB2;
    --text-tertiary: #636366;
    --border:        rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.15);
    --glass-bg:      rgba(29,29,31,0.78);
    --glass-border:  rgba(255,255,255,0.10);
    --glass-shadow:  0 8px 32px rgba(0,0,0,0.40), 0 2px 8px rgba(0,0,0,0.20);
  }
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--apple-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }
button { font-family: var(--font); cursor: pointer; border: none; outline: none; }
input, select, textarea { font-family: var(--font); }

/* ── Typography scale ── */
.t-largetitle { font-size: 34px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.2; }
.t-title1     { font-size: 28px; font-weight: 700; letter-spacing: -0.4px; line-height: 1.25; }
.t-title2     { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; line-height: 1.3; }
.t-title3     { font-size: 20px; font-weight: 600; letter-spacing: -0.2px; line-height: 1.3; }
.t-headline   { font-size: 17px; font-weight: 600; line-height: 1.4; }
.t-body       { font-size: 17px; font-weight: 400; line-height: 1.5; }
.t-callout    { font-size: 16px; font-weight: 400; line-height: 1.45; }
.t-subhead    { font-size: 15px; font-weight: 400; line-height: 1.4; }
.t-footnote   { font-size: 13px; font-weight: 400; line-height: 1.4; }
.t-caption    { font-size: 12px; font-weight: 400; line-height: 1.35; }
.t-caption2   { font-size: 11px; font-weight: 400; letter-spacing: 0.06em; line-height: 1.3; text-transform: uppercase; }

/* ── Glass card ── */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--glass-shadow);
}

/* ── Solid card ── */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ── Nav bar (top) ── */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: var(--glass-bg);
  backdrop-filter: var(--blur-lg);
  -webkit-backdrop-filter: var(--blur-lg);
  border-bottom: 1px solid var(--border);
}
.nav-bar .nav-brand {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-bar .nav-brand .nav-logo {
  width: 28px; height: 28px;
  background: var(--apple-blue);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 32px;
  flex: 1;
}
.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  cursor: pointer;
  border: none;
  background: transparent;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav-link:hover { background: var(--gray-100); color: var(--text-primary); text-decoration: none; }
.nav-link.active { background: var(--apple-blue); color: white; }
.nav-link svg { width: 16px; height: 16px; }
.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}
.nav-avatar {
  width: 30px; height: 30px;
  border-radius: var(--radius-full);
  background: var(--apple-blue);
  color: white;
  font-size: 12px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--apple-blue);
  color: white;
  box-shadow: var(--shadow-blue);
}
.btn-primary:hover { background: #0071EB; }

.btn-secondary {
  background: var(--gray-100);
  color: var(--text-primary);
}
.btn-secondary:hover { background: var(--gray-200); }

.btn-danger  { background: var(--apple-red); color: white; }
.btn-success { background: var(--apple-green); color: white; }
.btn-ghost   { background: transparent; color: var(--apple-blue); }
.btn-ghost:hover { background: rgba(0,122,255,0.08); }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 17px; }
.btn-icon {
  width: 34px; height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  color: var(--text-secondary);
}
.btn-icon:hover { background: var(--gray-200); color: var(--text-primary); }

/* ── Form inputs ── */
.input-field {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  outline: none;
}
.input-field:focus {
  border-color: var(--apple-blue);
  box-shadow: 0 0 0 3px rgba(0,122,255,0.15);
}
.input-field::placeholder { color: var(--text-tertiary); }

.input-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input-group { display: flex; flex-direction: column; gap: 0; }
.input-group .input-field:not(:last-child) {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
}
.input-group .input-field:not(:first-child) {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* ── Badges / pills ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-blue    { background: rgba(0,122,255,0.12); color: #005CC5; }
.badge-green   { background: rgba(52,199,89,0.14); color: #248A3D; }
.badge-red     { background: rgba(255,59,48,0.12); color: #C4001A; }
.badge-orange  { background: rgba(255,149,0,0.14); color: #A85200; }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }
.badge-purple  { background: rgba(175,82,222,0.12); color: #6B2A9E; }
.badge-yellow  { background: rgba(255,204,0,0.18); color: #7A5C00; }

/* Priority badges */
.priority-high   { background: rgba(255,59,48,0.12); color: #C4001A; }
.priority-medium { background: rgba(255,149,0,0.14); color: #A85200; }
.priority-low    { background: rgba(52,199,89,0.14); color: #248A3D; }

/* Status badges */
.status-done       { background: rgba(52,199,89,0.14); color: #248A3D; }
.status-inprogress { background: rgba(0,122,255,0.12); color: #005CC5; }
.status-overdue    { background: rgba(255,59,48,0.12); color: #C4001A; }
.status-pending    { background: var(--gray-100); color: var(--gray-600); }

/* ── KPI / Stat cards ── */
.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-card .stat-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1;
}
.stat-card .stat-sub {
  font-size: 13px;
  color: var(--text-tertiary);
}
.stat-card .stat-trend {
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 3px;
}
.stat-card .stat-trend.up   { color: var(--apple-green); }
.stat-card .stat-trend.down { color: var(--apple-red); }

/* ── Section header ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

/* ── Dot indicator ── */
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-green  { background: var(--apple-green); }
.dot-orange { background: var(--apple-orange); }
.dot-red    { background: var(--apple-red); }
.dot-blue   { background: var(--apple-blue); }
.dot-gray   { background: var(--gray-300); }

/* ── Page layout ── */
.page-wrapper { min-height: 100vh; }
.page-content { max-width: 1200px; margin: 0 auto; padding: 32px 24px 80px; }

/* ── Grid utilities ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-content { padding: 20px 16px 60px; }
  .nav-links { display: none; }
}
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* ── Progress bar ── */
.progress-track {
  height: 6px;
  background: var(--gray-100);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--apple-blue);
  transition: width var(--dur-slow) var(--ease);
}
.progress-fill.green  { background: var(--apple-green); }
.progress-fill.orange { background: var(--apple-orange); }
.progress-fill.red    { background: var(--apple-red); }

/* ── Dept pill colours ── */
.dept-QC         { background: rgba(0,122,255,0.12);  color: #005CC5; }
.dept-Marketing  { background: rgba(255,149,0,0.14);  color: #A85200; }
.dept-Maintenance{ background: rgba(175,82,222,0.12); color: #6B2A9E; }
.dept-ProductionStore { background: rgba(52,199,89,0.14);  color: #248A3D; }
.dept-Production { background: rgba(0,199,190,0.14);  color: #006B68; }
.dept-Sales      { background: rgba(255,59,48,0.12);  color: #C4001A; }
.dept-HumanResources  { background: rgba(255,107,107,0.14); color: #9B1A1A; }
.dept-Admin      { background: var(--gray-100);       color: var(--gray-600); }
.dept-Procurement{ background: rgba(255,204,0,0.18);  color: #7A5C00; }

/* ── Toast notification ── */
.toast-container {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  background: var(--gray-900);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  animation: toastIn 0.25s var(--ease-spring) forwards, toastOut 0.25s var(--ease) forwards 2.8s;
  pointer-events: auto;
}
@keyframes toastIn  { to { opacity:1; transform: translateY(0) scale(1); } }
@keyframes toastOut { to { opacity:0; transform: translateY(-8px) scale(0.96); } }

/* ── Page entry animation ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.anim-1 { animation: fadeUp var(--dur-slow) var(--ease) both; }
.anim-2 { animation: fadeUp var(--dur-slow) var(--ease) 60ms both; }
.anim-3 { animation: fadeUp var(--dur-slow) var(--ease) 120ms both; }
.anim-4 { animation: fadeUp var(--dur-slow) var(--ease) 180ms both; }
.anim-5 { animation: fadeUp var(--dur-slow) var(--ease) 240ms both; }
.anim-6 { animation: fadeUp var(--dur-slow) var(--ease) 300ms both; }

/* ── Modal overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-mid) var(--ease);
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal-box {
  background: var(--bg-secondary);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  padding: 28px;
  transform: translateY(20px) scale(0.97);
  transition: transform var(--dur-mid) var(--ease-spring);
}
.modal-overlay.open .modal-box {
  transform: translateY(0) scale(1);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

/* ── Select styled ── */
.select-field {
  width: 100%;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23AEAEB2' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  cursor: pointer;
}
.select-field:focus {
  border-color: var(--apple-blue);
  box-shadow: 0 0 0 3px rgba(0,122,255,0.15);
}

/* ── Table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
.data-table tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--gray-50); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-300); }
