/* ==========================================================================
   Krishok Card — custom.css
   Design language: "field ledger" — a government farm register reimagined.
   Deep paddy green + rice-gold + indigo trust accent, warm paper surface.
   Every screen (auth + dashboard) pulls from the same token set below.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
  /* Brand */
  --color-primary: #1f4d3a;        /* deep paddy green — primary actions, sidebar */
  --color-primary-dark: #163a2b;
  --color-primary-light: #2f6b4f;
  --color-accent: #d4a017;         /* rice-gold — highlights, active states */
  --color-accent-dark: #b8860b;
  --color-secondary: #2c3e70;      /* indigo — links, secondary emphasis */

  /* Surfaces */
  --color-bg: #f6f4ee;             /* warm paper background */
  --color-surface: #ffffff;
  --color-surface-muted: #eef1ea;
  --color-border: #e1ddcd;

  /* Text */
  --color-text: #1c2321;
  --color-text-muted: #5b6660;
  --color-text-inverse: #f6f4ee;

  /* Status */
  --color-success: #3a7d5c;
  --color-success-bg: #e7f2ea;
  --color-warning: #c98a1f;
  --color-warning-bg: #fbf1de;
  --color-danger: #b3492d;
  --color-danger-bg: #fbebe5;
  --color-info: var(--color-secondary);
  --color-info-bg: #e8ebf5;

  /* Typography */
  --font-display: "Fraunces", "Noto Serif Bengali", Georgia, serif;
  --font-body: "Public Sans", "Noto Sans Bengali", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Scale */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(28, 35, 33, 0.06);
  --shadow-md: 0 6px 20px rgba(28, 35, 33, 0.08);
  --shadow-lg: 0 20px 48px rgba(22, 58, 43, 0.18);

  --sidebar-width: 264px;
  --topbar-height: 64px;
}

/* --------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 0.4em;
  color: var(--color-primary-dark);
  letter-spacing: -0.01em;
}

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

img { max-width: 100%; display: block; }

button { font-family: inherit; }

/* Visible keyboard focus everywhere */
a:focus-visible,
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

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

/* --------------------------------------------------------------------------
   3. Layout: field-row texture (signature motif)
   Thin repeating lines evoke tilled/paddy rows; used sparingly as a
   background accent on dark panels only.
   -------------------------------------------------------------------------- */
.field-rows {
  background-image: repeating-linear-gradient(
    115deg,
    rgba(246, 244, 238, 0.05) 0px,
    rgba(246, 244, 238, 0.05) 1px,
    transparent 1px,
    transparent 34px
  );
}

/* --------------------------------------------------------------------------
   4. Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.btn:active { transform: translateY(1px); }

.btn-block { width: 100%; }

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

.btn-outline {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text);
}
.btn-outline:hover {
  border-color: var(--color-primary);
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   5. Forms
   -------------------------------------------------------------------------- */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text);
}

.form-control {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.form-control::placeholder { color: #9aa39c; }
.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(31, 77, 58, 0.14);
}

.form-error {
  color: var(--color-danger);
  font-size: 13px;
  margin-top: 6px;
}

.form-hint-row {
  display: flex;
  justify-content: flex-end;
  margin: -8px 0 18px;
  font-size: 13px;
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: #f0cfc2; }
.alert-success { background: var(--color-success-bg); color: var(--color-success); border-color: #cfe6d7; }
.alert-info { background: var(--color-info-bg); color: var(--color-secondary); border-color: #d4dbef; }

/* --------------------------------------------------------------------------
   6. Auth screen — split card (login.html)
   -------------------------------------------------------------------------- */
.auth-screen {
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

.auth-panel {
  position: relative;
  background: linear-gradient(160deg, var(--color-primary-light) 0%, var(--color-primary) 45%, var(--color-primary-dark) 100%);
  color: var(--color-text-inverse);
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-x: hidden;
  overflow-y: auto;
  height: 100%;
}

/* soft "aurora" glows for a lighter, more contemporary feel than a flat fill */
.auth-panel__glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.35;
  pointer-events: none;
}
.auth-panel__glow--gold {
  width: 340px;
  height: 340px;
  background: var(--color-accent);
  top: -80px;
  right: -100px;
}
.auth-panel__glow--indigo {
  width: 300px;
  height: 300px;
  background: var(--color-secondary);
  bottom: -60px;
  left: -80px;
  opacity: 0.4;
}
.auth-panel__texture {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.auth-panel > * { position: relative; z-index: 1; }

.auth-panel__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-panel__brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary-dark);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 0 0 6px rgba(212, 160, 23, 0.18);
}

.auth-panel__brand-text .eyebrow {
  display: block;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
}

.auth-panel__headline {
  max-width: 420px;
}

.auth-panel__headline h1 {
  color: var(--color-text-inverse);
  font-size: 40px;
  line-height: 1.15;
  margin-bottom: 14px;
}

.auth-panel__headline p {
  opacity: 0.85;
  font-size: 16px;
}

/* the "card" visual — a stylised smart-card evoking the physical Krishok Card,
   rendered as a glass panel for a more modern, less flat look */
.id-card {
  width: 320px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(246, 244, 238, 0.28);
  box-shadow: var(--shadow-lg);
  padding: 20px;
  color: var(--color-text-inverse);
}

.id-card__row-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 26px;
}

.id-card__chip {
  width: 38px;
  height: 28px;
  border-radius: 5px;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-dark));
}

.id-card__label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.75;
}

.id-card__number {
  font-family: var(--font-mono);
  font-size: 18px;
  letter-spacing: 0.08em;
  margin-top: 18px;
}

.auth-panel__hotline {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
.auth-panel__hotline strong {
  font-family: var(--font-mono);
  font-size: 18px;
  letter-spacing: 0.03em;
}

.auth-form-side {
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  height: 100%;
  overflow-y: auto;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 40px;
  position: relative;
  overflow: hidden;
  animation: auth-card-in 420ms ease both;
}

/* thin gradient accent bar across the top — a small "smart product" signature */
.auth-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent) 55%, var(--color-secondary));
}

@keyframes auth-card-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 6px;
}

.auth-card__subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 0 0 26px;
}

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 3px;
  font-size: 12px;
  font-weight: 600;
}
.lang-toggle span {
  padding: 5px 12px;
  border-radius: 999px;
  color: var(--color-text-muted);
  cursor: pointer;
}
.lang-toggle span.active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

/* input icon affixes (mail icon, password eye toggle) */
.input-icon-wrap { position: relative; display: flex; align-items: center; }
.input-icon-wrap .form-control { padding-right: 42px; }

.input-icon {
  position: absolute;
  right: 14px;
  display: flex;
  color: var(--color-text-muted);
  pointer-events: none;
}

.password-toggle {
  position: absolute;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
}
.password-toggle:hover { color: var(--color-text); background: var(--color-surface-muted); }
.password-toggle .icon-eye-off { display: none; }
.password-toggle.is-visible .icon-eye { display: none; }
.password-toggle.is-visible .icon-eye-off { display: block; }

.auth-card__secure {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 16px;
}

.auth-card__divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 20px 0 16px;
}

.auth-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--color-text-muted);
}

@media (max-width: 900px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-panel { display: none; }
}

@media (max-height: 760px) {
  .auth-panel { padding: 32px; gap: 16px; }
  .auth-panel__headline h1 { font-size: 32px; }
  .id-card { padding: 16px; }
  .id-card__row-top { margin-bottom: 16px; }
  .auth-card { padding: 28px; }
  .auth-card__subtitle { margin-bottom: 18px; }
}


/* --------------------------------------------------------------------------
   7. Dashboard shell (base.html)
   -------------------------------------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 160ms ease;
}

.sidebar {
  background: var(--color-primary-dark);
  color: var(--color-text-inverse);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(246, 244, 238, 0.18); border-radius: 999px; }

.sidebar-backdrop {
  display: none;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
  border-bottom: 1px solid rgba(246, 244, 238, 0.12);
  white-space: nowrap;
}

.sidebar__brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-accent);
  flex-shrink: 0;
}

.sidebar__brand-text { font-family: var(--font-display); font-size: 15px; font-weight: 600; }

.nav-group { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item { display: flex; flex-direction: column; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: rgba(246, 244, 238, 0.78);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}
.nav-link:hover {
  background: rgba(246, 244, 238, 0.08);
  color: var(--color-text-inverse);
  text-decoration: none;
}
.nav-link--active {
  background: var(--color-accent);
  color: var(--color-primary-dark);
  font-weight: 700;
}

.nav-link__icon { flex-shrink: 0; width: 18px; text-align: center; font-size: 15px; }
.nav-link__text { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-link__chevron {
  flex-shrink: 0;
  font-size: 11px;
  transition: transform 160ms ease;
  opacity: 0.7;
}
.nav-item--open > .nav-link--parent .nav-link__chevron { transform: rotate(-180deg); }
.nav-item--open > .nav-link--parent { color: var(--color-text-inverse); }

.nav-submenu {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 220ms ease;
}
.nav-item--open .nav-submenu { max-height: 640px; }

.nav-sublink {
  display: block;
  padding: 8px 10px 8px 42px;
  font-size: 13px;
  color: rgba(246, 244, 238, 0.68);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.nav-sublink:hover {
  background: rgba(246, 244, 238, 0.08);
  color: var(--color-text-inverse);
  text-decoration: none;
}
.nav-sublink--active {
  color: var(--color-accent);
  font-weight: 600;
}

.sidebar__footer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 12px;
  border-top: 1px solid rgba(246, 244, 238, 0.12);
}

/* Icon-rail collapsed state (desktop) */
.app-shell.is-collapsed { grid-template-columns: 76px 1fr; }
.app-shell.is-collapsed .sidebar__brand-text,
.app-shell.is-collapsed .nav-link__text,
.app-shell.is-collapsed .nav-link__chevron,
.app-shell.is-collapsed .nav-submenu {
  display: none;
}
.app-shell.is-collapsed .sidebar__brand { justify-content: center; padding-left: 0; padding-right: 0; }
.app-shell.is-collapsed .nav-link,
.app-shell.is-collapsed .nav-link--parent {
  justify-content: center;
  padding: 10px;
}
.app-shell.is-collapsed .topbar__menu-toggle { transform: scaleX(-1); }

.topbar__menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: background-color 120ms ease, transform 160ms ease;
}
.topbar__menu-toggle:hover { background: var(--color-surface-muted); }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
}

.topbar__search {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--color-text-muted);
  font-size: 14px;
}

.topbar__actions { display: flex; align-items: center; gap: 14px; }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-secondary);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.content { padding: 24px; }

.breadcrumb { font-size: 13px; color: var(--color-text-muted); margin-bottom: 16px; }

@media (max-width: 900px) {
  .app-shell,
  .app-shell.is-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.sidebar--open { transform: translateX(0); }

  /* text/chevrons must stay visible on mobile even if desktop collapse ran before resize */
  .app-shell .sidebar__brand-text,
  .app-shell .nav-link__text,
  .app-shell .nav-link__chevron {
    display: block;
  }
  .app-shell .nav-link,
  .app-shell .nav-link--parent {
    justify-content: flex-start;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(28, 35, 33, 0.45);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
  }
  .sidebar-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }
}

/* --------------------------------------------------------------------------
   8. Dashboard cards & stats
   -------------------------------------------------------------------------- */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.panel-hero {
  background: linear-gradient(120deg, var(--color-success-bg), var(--color-surface) 60%);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.panel-hero__meta p { color: var(--color-text-muted); margin: 4px 0 0; font-size: 14px; }

.panel-hero__actions { display: flex; gap: 12px; }

.chip {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  min-width: 190px;
  box-shadow: var(--shadow-sm);
}
.chip__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}
.chip__value { font-family: var(--font-display); font-size: 20px; font-weight: 700; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.stat {
  text-align: center;
  padding: 12px 8px;
}

.stat__ring {
  width: 68px;
  height: 68px;
  margin: 0 auto 10px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--color-primary-dark);
}

.stat__value { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.stat__label { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }

.grid-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-top: 20px;
}

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.queue-card {
  background: var(--color-success-bg);
  border-radius: var(--radius-md);
  padding: 18px;
}
.queue-card__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-primary-dark);
  margin-bottom: 8px;
}
.queue-card__value { font-family: var(--font-display); font-size: 24px; font-weight: 700; }

.queue-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.quick-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px;
  border-bottom: 1px solid var(--color-border);
}
.quick-link:last-child { border-bottom: none; }
.quick-link h4 { margin: 0 0 2px; font-size: 14px; color: var(--color-text); }
.quick-link p { margin: 0; font-size: 12px; color: var(--color-text-muted); }
