/* ============================================================
   IMECA PORTAL — Minimal Corporate Design System
   Design tokens + components. Brand: Imeca yellow + slate ink.
   ============================================================ */

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

:root {
  /* Brand */
  --brand-yellow: #fef200;
  --brand-yellow-soft: #fff9b8;
  --brand-ink: #1c2434;
  --brand-ink-soft: #2a3447;

  /* Neutral scale (slate) */
  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Semantic */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #059669;
  --success-soft: #ecfdf5;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --info: #0891b2;
  --info-soft: #ecfeff;

  /* Surface */
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .06), 0 2px 4px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 28px rgba(15, 23, 42, .10), 0 4px 8px rgba(15, 23, 42, .04);
  --ring: 0 0 0 3px rgba(37, 99, 235, .25);

  /* Motion */
  --t-fast: 120ms cubic-bezier(.4, 0, .2, 1);
  --t-med:  200ms cubic-bezier(.4, 0, .2, 1);

  /* z-index */
  --z-sticky: 50;
  --z-modal:  100;
  --z-tooltip: 200;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--slate-900);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--brand-yellow); color: var(--brand-ink); }

/* ============================================================
   TOPBAR
   ============================================================ */
header.topbar {
  background: var(--brand-yellow);
  color: var(--brand-ink);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(28, 36, 52, .15);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}
header.topbar .brand { display: flex; align-items: center; gap: 12px; }
header.topbar img.logo {
  height: 36px;
  width: auto;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .08));
}
header.topbar h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--brand-ink);
}
header.topbar nav {
  display: flex;
  gap: 4px;
  align-items: center;
}
header.topbar nav a {
  color: var(--brand-ink);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 7px 12px;
  border-radius: var(--r-sm);
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
}
header.topbar nav a:hover {
  background: rgba(28, 36, 52, .08);
}
header.topbar nav a.active {
  background: var(--brand-ink);
  color: var(--brand-yellow);
}
header.topbar nav a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--brand-ink);
}
.user-chip {
  font-size: 12.5px;
  color: var(--brand-ink);
  font-weight: 600;
  padding: 6px 12px;
  background: rgba(28, 36, 52, .08);
  border-radius: var(--r-full);
}
.user-chip small {
  font-weight: 500;
  opacity: .75;
  margin-left: 4px;
}
#langToggle {
  background: var(--brand-ink) !important;
  color: var(--brand-yellow) !important;
  font-weight: 700;
  padding: 6px 12px !important;
  font-size: 12px !important;
  border-radius: var(--r-sm);
  min-height: 32px;
}
#langToggle:hover { background: var(--brand-ink-soft) !important; }

/* ============================================================
   BUTTONS
   ============================================================ */
button {
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.2;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), color var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
}
button:hover { background: var(--primary-hover); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: .55; cursor: not-allowed; }

button.secondary { background: var(--surface); color: var(--slate-700); border-color: var(--border); }
button.secondary:hover { background: var(--slate-50); border-color: var(--border-strong); }

button.success { background: var(--success); }
button.success:hover { background: #047857; }

button.danger { background: var(--danger); }
button.danger:hover { background: #b91c1c; }

button.ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border);
}
button.ghost:hover { background: var(--primary-soft); border-color: var(--primary); }

/* ============================================================
   LAYOUT
   ============================================================ */
main {
  padding: 28px;
  max-width: 1440px;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--shadow-xs);
  margin-bottom: 18px;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
  min-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(254, 242, 0, .35), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, rgba(28, 36, 52, .08), transparent 60%),
    var(--bg);
}
.login-card {
  width: 380px;
  background: var(--surface);
  padding: 36px;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}
.login-card h2 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--slate-900);
}

/* ============================================================
   FORMS
   ============================================================ */
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 12px;
  background: var(--surface);
  color: var(--slate-900);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input:hover, select:hover, textarea:hover { border-color: var(--slate-400); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}
textarea { min-height: 90px; resize: vertical; line-height: 1.55; }

label {
  display: block;
  font-size: 12.5px;
  margin-bottom: 6px;
  color: var(--slate-700);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  border-radius: var(--r-sm);
  padding: 8px 12px;
}

/* ============================================================
   KANBAN
   ============================================================ */
.kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(260px, 1fr));
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.kanban-col {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
  min-height: 240px;
}
.kanban-col h3 {
  font-size: 11.5px;
  margin: 0 0 14px;
  text-transform: uppercase;
  color: var(--slate-600);
  letter-spacing: 0.08em;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.problem-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  border-left: 3px solid var(--primary);
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
}
.problem-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.problem-card:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.problem-card .meta {
  font-size: 10.5px;
  color: var(--slate-500);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-weight: 500;
}
.problem-card .title {
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.4;
  color: var(--slate-900);
  letter-spacing: -0.005em;
}
.problem-card .countdown {
  font-size: 11.5px;
  margin-top: 8px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}
.countdown.green  { color: var(--success); }
.countdown.yellow { color: var(--warning); }
.countdown.red    { color: var(--danger); }

/* ============================================================
   TAGS
   ============================================================ */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--slate-100);
  color: var(--slate-700);
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid var(--border);
  line-height: 1.6;
}
.tag.success { background: var(--success-soft); color: #065f46; border-color: #a7f3d0; }
.tag.warn    { background: var(--warning-soft); color: #92400e; border-color: #fde68a; }
.tag.best    { background: var(--brand-yellow-soft); color: #714b00; border-color: #fde047; }

/* ============================================================
   FILTERS
   ============================================================ */
.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 0;
}
.filters > div { flex: 1; min-width: 160px; }
.filters input, .filters select { margin-bottom: 0; }

/* ============================================================
   MODAL
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  animation: fade-in var(--t-med);
}
.modal-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 28px;
  width: 600px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: scale-in var(--t-med);
}
.modal-card h2 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--slate-900);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes scale-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0)  scale(1); }
}

.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }

.history-item {
  font-size: 12px;
  color: var(--slate-600);
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}
.history-item:last-child { border-bottom: none; }

.empty {
  text-align: center;
  color: var(--slate-500);
  padding: 48px 20px;
  font-style: normal;
  font-size: 13.5px;
  background: var(--surface-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
}

/* ============================================================
   BEST PRACTICES
   ============================================================ */
.bp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.bp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  border-top: 3px solid var(--brand-yellow);
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.bp-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.bp-card h4 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--slate-900);
}

/* ============================================================
   ADMIN — USER ROWS
   ============================================================ */
.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
}
.user-row:last-child { border-bottom: none; }
.user-row > div:first-child { flex: 1; }

.user-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-xs);
}
.user-card .u-name { font-weight: 700; font-size: 14px; color: var(--slate-900); }
.user-card .u-email { color: var(--slate-600); font-size: 12.5px; }

.save-status {
  font-size: 12px;
  color: var(--success);
  font-weight: 600;
}

.section-title {
  font-size: 11.5px;
  font-weight: 700;
  margin: 20px 0 10px;
  color: var(--slate-600);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Admin reports specific */
.prob-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.prob-row:last-child { border-bottom: none; }
.prob-row .title { flex: 1; font-weight: 600; color: var(--slate-900); font-size: 13.5px; }

.manager-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}
.manager-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  color: var(--slate-900);
}
.stores { display: flex; flex-direction: column; gap: 8px; }

/* ============================================================
   RESPONSIVE — desktop / tablet
   ============================================================ */
@media (max-width: 1100px) {
  .kanban { grid-template-columns: repeat(3, minmax(240px, 1fr)); }
}
@media (max-width: 900px) {
  .kanban { grid-template-columns: 1fr; }
  header.topbar { flex-wrap: wrap; gap: 8px; }
  main { padding: 20px; }
}

/* ============================================================
   RESPONSIVE — mobile (preserves hamburger nav from JS)
   ============================================================ */
.nav-toggle { display: none; }

@media (max-width: 640px) {
  body { font-size: 14px; }
  main { padding: 14px; }

  header.topbar {
    padding: 10px 14px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  header.topbar h1 { font-size: 14px; }
  header.topbar img.logo { height: 30px; }

  .nav-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid rgba(28, 36, 52, .25);
    border-radius: var(--r-sm);
    padding: 0;
    cursor: pointer;
    flex: 0 0 auto;
    color: var(--brand-ink);
  }
  .nav-toggle:focus-visible { box-shadow: 0 0 0 2px var(--brand-ink); outline: none; }
  .nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--brand-ink);
    border-radius: 2px;
    transition: transform var(--t-med), opacity var(--t-med);
  }
  header.topbar.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  header.topbar.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
  header.topbar.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  header.topbar nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--brand-yellow);
    border-bottom: 1px solid rgba(28, 36, 52, .2);
    box-shadow: var(--shadow-lg);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 6px 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--t-med);
  }
  header.topbar.nav-open nav { max-height: 85vh; overflow-y: auto; }

  header.topbar nav a {
    display: block;
    padding: 14px 18px;
    border-radius: 0;
    font-size: 15px;
    font-weight: 600;
    border-bottom: 1px solid rgba(28, 36, 52, .08);
  }
  header.topbar nav a.active {
    background: var(--brand-ink);
    color: var(--brand-yellow);
  }

  .user-chip {
    padding: 12px 18px;
    font-size: 13px;
    color: var(--brand-ink);
    border-bottom: 1px solid rgba(28, 36, 52, .08);
    background: rgba(28, 36, 52, .05);
    border-radius: 0;
  }
  .user-chip small {
    display: block;
    font-size: 11px;
    color: var(--slate-700);
    margin-top: 2px;
    font-weight: 500;
    margin-left: 0;
  }
  header.topbar nav #langToggle,
  header.topbar nav #logoutBtn {
    margin: 8px 14px !important;
    width: calc(100% - 28px);
    padding: 10px !important;
    font-size: 14px !important;
    min-height: 44px;
  }

  .card { padding: 16px; }
  .filters { flex-direction: column; gap: 8px; }
  .filters > div { width: 100%; min-width: 0; }
  .login-wrap { min-height: 92vh; padding: 20px; }
  .login-card { width: 100%; padding: 26px 22px; }
  .modal { padding: 8px; align-items: flex-start; padding-top: 12px; }
  .modal-card { width: 100%; max-width: 100%; padding: 20px 18px; max-height: 95vh; }
  .modal-card h2 { font-size: 18px; }
  .row { flex-direction: column; gap: 10px; }
  .user-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .actions { flex-direction: column; }
  .actions button { width: 100%; min-height: 44px; }
  .problem-card { padding: 12px; }
  .problem-card .title { font-size: 13px; }
  input, select, textarea { font-size: 16px; } /* avoid iOS zoom */
  button { font-size: 14px; padding: 10px 14px; min-height: 44px; }
}
