@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

/* ------------------------------------------------------------------
   Shared styles for the login page, the admin dashboard and the older
   customer pages. The customer banking app (bank/) has its own sheet
   but shares this palette so everything reads as one product.
   ------------------------------------------------------------------ */

:root {
  --ink: #0e1a2e;
  --paper: #f1f4f9;
  --card: #ffffff;
  --border: #e0e6f0;
  --text-muted: #62708a;

  /* "teal" is kept as the variable name because other pages reference it,
     but the primary colour is now the deep banking navy. */
  --teal: #14315c;
  --teal-dark: #0b2142;
  --accent: #3d7bea;
  --accent-soft: #e8f0fe;

  --amber: #b9791a;
  --amber-bg: #fbf0da;
  --moss: #2f7a4d;
  --moss-bg: #e2f3e9;
  --clay: #a24e1f;
  --clay-bg: #f5e8db;
  --rust: #b03a2e;
  --rust-bg: #fbe9e6;

  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(14, 26, 46, 0.06), 0 1px 3px rgba(14, 26, 46, 0.04);
  --shadow-md: 0 8px 24px rgba(14, 26, 46, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: 'IBM Plex Sans', -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
}

h1, h2 { font-family: 'Fraunces', Georgia, serif; letter-spacing: -0.01em; }

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Simple top bar --- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 17px; font-weight: 600; margin: 0; }
.topbar .role-badge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--teal);
}

.container { max-width: 960px; margin: 0 auto; padding: 24px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card h2 { font-size: 16px; margin: 0 0 14px; }

/* --- Sidebar app shell --- */
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: 236px;
  background: linear-gradient(180deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: #e8eefb;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar .brand {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 19px;
  font-weight: 600;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar .brand::before {
  content: "";
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, #6ea0ff, #3d7bea);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}
.sidebar .brand-sub { font-size: 12px; color: #9db4dc; margin: 0 0 28px 36px; }
.sidebar nav { display: flex; flex-direction: column; gap: 3px; }
.sidebar nav a {
  color: #c4d3ee;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 14px;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.sidebar nav a.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 500;
  box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar .spacer { flex: 1; }
.sidebar .user-box { border-top: 1px solid rgba(255, 255, 255, 0.12); padding-top: 14px; font-size: 13px; }
.sidebar .user-box .name { font-weight: 500; color: #fff; }
.sidebar .user-box button {
  margin-top: 8px; width: 100%;
  background: transparent; color: #d5e0f5; border: 1px solid rgba(255, 255, 255, 0.2);
}
.sidebar .user-box button:hover { background: rgba(255, 255, 255, 0.08); opacity: 1; }

/* min-width:0 lets wide content (tables) scroll inside the page instead
   of pushing the whole layout sideways on small screens. */
.main { flex: 1; min-width: 0; padding: 36px; max-width: 1040px; }
.main h1 { font-size: 26px; margin: 0 0 4px; }
.main .lede { color: var(--text-muted); font-size: 14px; margin: 0 0 26px; }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; border-top: 3px solid var(--border); box-shadow: var(--shadow-sm); }
.stat.st-backlog { border-top-color: var(--clay); }
.stat.st-progress { border-top-color: var(--amber); }
.stat.st-done { border-top-color: var(--moss); }
.stat .num { font-size: 26px; font-weight: 600; font-family: 'Fraunces', serif; }
.stat .label { font-size: 12px; color: var(--text-muted); }

.task-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.task-row:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.task-row .row-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.task-row .title { font-size: 14px; font-weight: 500; }
.task-row .meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.badge { font-size: 11px; padding: 3px 10px; border-radius: 999px; white-space: nowrap; font-weight: 500; }
.badge.backlog { background: var(--clay-bg); color: var(--clay); }
.badge.in_progress { background: var(--amber-bg); color: var(--amber); }
.badge.done { background: var(--moss-bg); color: var(--moss); }
.badge.suspended { background: var(--rust-bg); color: var(--rust); }

.log-entry { border-left: 2px solid var(--border); padding-left: 12px; margin-bottom: 12px; }
.log-entry .note { font-size: 13px; }
.log-entry .when { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.subtask-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.subtask-dot {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.subtask-dot.done { background: var(--moss); }
.subtask-dot.pending { background: #9aa4b5; }
.subtask-dot svg { width: 9px; height: 9px; stroke: #fff; stroke-width: 3; fill: none; }
.subtask-title { font-size: 13px; }

input, select, textarea, button {
  font-family: inherit;
  font-size: 13px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 123, 234, 0.18);
}
textarea { width: 100%; resize: vertical; min-height: 60px; }
input, select { width: 100%; }

button {
  cursor: pointer;
  background: linear-gradient(180deg, #1c437c, var(--teal));
  color: #fff;
  border: none;
  font-weight: 500;
  transition: transform 0.12s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
button:hover { opacity: 0.92; box-shadow: 0 4px 12px rgba(20, 49, 92, 0.25); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.6; cursor: default; box-shadow: none; }
button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--border); box-shadow: none; }
button.secondary:hover { background: var(--paper); box-shadow: none; }
button.danger { background: var(--rust); }

.form-row { margin-bottom: 10px; }
.form-row label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; font-weight: 500; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .form-row { flex: 1; min-width: 140px; margin-bottom: 0; }

.error { color: var(--rust); background: var(--rust-bg); padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.success { color: var(--moss); background: var(--moss-bg); padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.muted { color: var(--text-muted); font-size: 13px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:hover td { background: #f8faff; }

/* Wide tables scroll sideways inside their card instead of breaking the page. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 520px; }

/* ------------------------------------------------------------------
   Toasts ("Login successful" etc.)
   ------------------------------------------------------------------ */
.toast {
  position: fixed;
  top: max(16px, env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 420px);
  padding: 12px 16px;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 12px 32px rgba(14, 26, 46, 0.22);
  border: 1px solid var(--border);
  opacity: 0;
  transform: translate(-50%, -14px);
  transition: opacity 0.28s ease, transform 0.28s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-icon {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.toast-success .toast-icon { background: var(--moss); }
.toast-error .toast-icon { background: var(--rust); }

/* ------------------------------------------------------------------
   Login page
   ------------------------------------------------------------------ */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top, 0px)) 16px max(20px, var(--safe-bottom));
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(61, 123, 234, 0.35), transparent 60%),
    radial-gradient(700px 500px at 100% 110%, rgba(110, 160, 255, 0.22), transparent 60%),
    linear-gradient(160deg, #0b2142 0%, #14315c 55%, #0e2749 100%);
}
.login-shell { width: 100%; max-width: 420px; animation: login-rise 0.5s ease both; }
@keyframes login-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; color: #fff; }
.login-logo {
  width: 44px; height: 44px; border-radius: 13px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #7aa8ff, #3d7bea);
  box-shadow: 0 8px 20px rgba(61, 123, 234, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}
.login-brand strong { display: block; font-family: 'Fraunces', Georgia, serif; font-size: 20px; font-weight: 600; line-height: 1.1; }
.login-brand span { font-size: 12px; color: #a9bfe6; }

.login-card {
  width: 100%;
  margin: 0;
  padding: 28px 24px;
  border-radius: 20px;
  border: none;
  box-shadow: 0 24px 60px rgba(4, 12, 28, 0.45);
}
.login-card h1 { font-size: 24px; margin: 0 0 4px; }
.login-card p.sub { color: var(--text-muted); font-size: 14px; margin: 0 0 22px; }
.login-card .form-row { margin-bottom: 14px; }
.login-card input { height: 46px; font-size: 15px; border-radius: 11px; padding: 10px 14px; }

.password-field { position: relative; }
.password-field input { padding-right: 62px; }
.password-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  height: 34px; padding: 0 10px; font-size: 12px; font-weight: 500;
  background: transparent; color: var(--text-muted); border-radius: 8px; box-shadow: none;
}
.password-toggle:hover { background: var(--paper); box-shadow: none; opacity: 1; }
.password-toggle:active { transform: translateY(-50%); }

.login-submit {
  width: 100%; height: 48px; margin-top: 4px; border-radius: 12px; font-size: 15px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(180deg, #4a86f2, #2f6bd8);
  box-shadow: 0 8px 20px rgba(47, 107, 216, 0.35);
}
.login-submit:hover { box-shadow: 0 10px 24px rgba(47, 107, 216, 0.45); }
.login-submit.done { background: linear-gradient(180deg, #38a169, var(--moss)); box-shadow: 0 8px 20px rgba(47, 122, 77, 0.35); }
.btn-spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff;
  animation: btn-spin 0.7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

.login-note { margin: 18px 0 0; text-align: center; font-size: 12px; color: #9db4dc; }

/* ------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------ */
@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 12px 16px; }
  .sidebar .brand-sub, .sidebar .spacer { display: none; }
  .sidebar nav { flex-direction: row; }
  .sidebar .user-box { border-top: none; padding-top: 0; margin-left: auto; }
  .main { padding: 18px 14px 28px; }
  .main h1 { font-size: 22px; }
  .grid-3 { grid-template-columns: 1fr; }
  .card { padding: 16px; border-radius: 12px; }

  /* 16px inputs stop iOS Safari zooming the page when a field is focused */
  input, select, textarea { font-size: 16px; }

  .inline-form .form-row { flex: 1 1 100%; max-width: none !important; min-width: 0; }
  .inline-form > button { flex: 1 1 100%; padding: 11px; }
  .container { padding: 16px; }
}

/* Admin dashboard specifically gets a hamburger + slide-in drawer instead
   of the row-collapse above - seven nav items don't fit well as a row. */
.hamburger-btn {
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border);
  cursor: pointer; margin-bottom: 14px; padding: 0; box-shadow: var(--shadow-sm);
}
.hamburger-btn span, .hamburger-btn span::before, .hamburger-btn span::after {
  display: block; width: 16px; height: 2px; background: var(--ink); position: relative;
}
.hamburger-btn span::before, .hamburger-btn span::after { content: ""; position: absolute; }
.hamburger-btn span::before { top: -5px; }
.hamburger-btn span::after { top: 5px; }
.sidebar-backdrop { display: none; }

@media (max-width: 720px) {
  .hamburger-btn { display: flex; }
  #admin-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
    width: min(260px, 82vw); flex-direction: column; overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  #admin-sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0, 0, 0, 0.35); }
  #admin-sidebar { align-items: stretch; }
  #admin-sidebar .brand-sub, #admin-sidebar .spacer { display: block; }
  #admin-sidebar nav { flex-direction: column; }
  #admin-sidebar .user-box { border-top: 1px solid rgba(255, 255, 255, 0.12); padding-top: 14px; margin-left: 0; }
  .sidebar-backdrop.open {
    display: block; position: fixed; inset: 0;
    background: rgba(8, 16, 32, 0.5); z-index: 99;
  }

  /* Customer list: each row becomes a small card instead of a 6-column
     table that would have to scroll sideways. */
  #clients-table { min-width: 0; }
  #clients-table thead { display: none; }
  #clients-table, #clients-table tbody, #clients-table tr, #clients-table td { display: block; width: 100%; }
  #clients-table tr.client-row {
    border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; background: #fff;
  }
  #clients-table tr.client-row td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    border: 0; padding: 5px 0; text-align: right; word-break: break-word;
  }
  #clients-table tr.client-row td::before {
    content: attr(data-label); color: var(--text-muted); font-size: 12px; text-align: left; flex-shrink: 0;
  }
  #clients-table tr.client-row td:last-child { justify-content: flex-end; padding-top: 8px; }
  #clients-table tr.client-row td:last-child::before { content: none; }
  #clients-table tr.manage-row td { padding: 0; border: 0; }
  #clients-table tr.manage-row { margin: -4px 0 14px; }
  #clients-table tbody tr:hover td { background: transparent; }

  #chat-messages-admin { height: 300px !important; }
}

@media (max-width: 380px) {
  .login-card { padding: 22px 18px; }
  .login-brand strong { font-size: 18px; }
}

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