/* =====================================================================
   Tasgaon Road Register — Admin/Auth Shared Styles
   For login.php, reset-password.php, dashboard.php, and all Phase 4+
   authenticated pages. Same editorial palette as the public landing.
   ===================================================================== */

:root {
  --paper:         #FAF7F0;
  --paper-dark:    #F2EDE0;
  --ink:           #0B1F3A;
  --ink-soft:      #2A3D5A;
  --ink-muted:     #6B7A8C;
  --hairline:      #D9D1BF;
  --accent:        #C77A2E;
  --accent-dark:   #9E5E1F;
  --accent-soft:   #F5E6D3;
  --saffron:       #FF9933;
  --tri-white:     #FFFFFF;
  --tri-green:     #138808;
  --ok:            #2D7F3D;
  --ok-soft:       #DCFCE7;
  --warn:          #B45309;
  --warn-soft:     #FEF3C7;
  --danger:        #B91C1C;
  --danger-soft:   #FEE2E2;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* overflow-x: clip instead of hidden — prevents `html` / `body` from becoming a
   scroll container, which would break `position: sticky` on the sidebar.
   Browsers without `overflow: clip` fall back to `hidden` via the duplicate
   declaration below (older Safari ≤15.4, older Samsung Internet). */
html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;    /* fallback */
  overflow-x: clip;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  overflow-x: hidden;    /* fallback */
  overflow-x: clip;
}

.mr { font-family: 'Anek Devanagari', sans-serif; font-weight: 500; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

/* =====================================================================
   CENTERED AUTH CARD LAYOUT (login, reset-password)
   ===================================================================== */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--paper);
  position: relative;
}

@media (min-width: 900px) {
  .auth-shell { grid-template-columns: 1.1fr 1fr; }
}

.auth-side {
  display: none;
  background: var(--ink);
  color: var(--paper);
  padding: 60px;
  position: relative;
  overflow: hidden;
  flex-direction: column;
  justify-content: space-between;
}
@media (min-width: 900px) { .auth-side { display: flex; } }

.auth-side::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
}
.auth-side > * { position: relative; z-index: 1; }

.auth-side-title {
  font-family: 'Fraunces', serif;
  font-size: 42px;
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-top: auto;
  margin-bottom: 20px;
}
.auth-side-title em {
  font-style: italic;
  color: var(--accent);
  font-weight: 400;
}

.auth-side-sub {
  font-size: 16px;
  color: rgba(250, 247, 240, 0.75);
  max-width: 420px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.auth-side-stats {
  display: flex;
  gap: 40px;
  padding-top: 30px;
  border-top: 1px solid rgba(250, 247, 240, 0.12);
  margin-top: auto;
}
.auth-side-stat .num {
  font-family: 'Fraunces', serif;
  font-size: 32px;
  font-weight: 500;
  color: var(--paper);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.auth-side-stat .label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(250, 247, 240, 0.55);
  margin-top: 6px;
}

/* Tricolor strip on auth-side */
.auth-tricolor {
  display: flex;
  height: 3px;
  border-radius: 2px;
  overflow: hidden;
  max-width: 120px;
  margin-bottom: 28px;
}
.auth-tricolor span { flex: 1; }
.auth-tricolor span:nth-child(1) { background: var(--saffron); }
.auth-tricolor span:nth-child(2) { background: var(--paper); }
.auth-tricolor span:nth-child(3) { background: var(--tri-green); }

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
  text-decoration: none;
  color: var(--ink);
}
.auth-brand-emblem {
  width: 38px; height: 38px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(199, 122, 46, 0.25);
  position: relative;
}
.auth-brand-emblem::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1.5px solid rgba(255,255,255,0.4);
  border-radius: 50%;
}
.auth-brand-emblem svg {
  width: 20px; height: 20px;
  color: var(--paper);
  position: relative; z-index: 1;
}
.auth-brand-text .brand-name {
  font-family: 'Fraunces', serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}
.auth-brand-text .brand-sub {
  font-size: 10px;
  color: var(--ink-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 2px;
}

.auth-heading {
  font-family: 'Fraunces', serif;
  font-size: 30px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 8px;
}
.auth-heading-mr {
  font-family: 'Anek Devanagari', sans-serif;
  font-size: 15px;
  color: var(--ink-muted);
  margin-bottom: 32px;
}

/* =====================================================================
   FORMS
   ===================================================================== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(199, 122, 46, 0.15);
}
.form-input::placeholder {
  color: var(--ink-muted);
  opacity: 0.7;
}
.form-input[readonly], .form-input:disabled {
  background: var(--paper-dark);
  color: var(--ink-muted);
  cursor: not-allowed;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 24px;
  cursor: pointer;
  user-select: none;
}
.form-check input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.form-check-label {
  font-size: 14px;
  color: var(--ink-soft);
}

.form-help {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 6px;
  line-height: 1.45;
}

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

/* =====================================================================
   BUTTONS
   ===================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  border: 0;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--ink);
  color: var(--paper);
  width: 100%;
  padding: 14px 20px;
  font-size: 16px;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(199, 122, 46, 0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--hairline);
}
.btn-ghost:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.btn-sm { padding: 8px 14px; font-size: 13px; }

/* =====================================================================
   ALERTS
   ===================================================================== */
.alert {
  padding: 14px 16px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-left: 3px solid;
}
.alert svg {
  flex-shrink: 0;
  width: 18px; height: 18px;
  margin-top: 1px;
}
.alert-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-left-color: var(--danger);
}
.alert-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-left-color: var(--warn);
}
.alert-ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-left-color: var(--ok);
}
.alert-info {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-left-color: var(--accent);
}

/* =====================================================================
   FOOTER (auth pages)
   ===================================================================== */
.auth-footer {
  text-align: center;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--hairline);
  font-size: 13px;
  color: var(--ink-muted);
}
.auth-footer a { color: var(--ink-soft); }
.auth-footer a:hover { color: var(--accent); }

/* =====================================================================
   APP SHELL (dashboard, data tables — Phase 4 ready)
   ===================================================================== */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
}

.sidebar {
  background: var(--ink);
  color: var(--paper);
  padding: 24px 0;
  position: sticky;
  top: 0;
  align-self: start;      /* prevent grid stretch that can break sticky */
  height: 100vh;
  max-height: 100vh;
  width: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: -240px;
    width: 240px;
    transition: left 0.3s;
    z-index: 200;
    top: 0;
  }
  .sidebar.open { left: 0; }
}

.sidebar-brand {
  padding: 0 24px 24px;
  border-bottom: 1px solid rgba(250, 247, 240, 0.12);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--paper);
  text-decoration: none;
}
.sidebar-brand svg {
  width: 24px; height: 24px;
  color: var(--accent);
  flex-shrink: 0;
}
.sidebar-brand .name {
  font-family: 'Fraunces', serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}
.sidebar-brand .sub {
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(250, 247, 240, 0.55);
  margin-top: 2px;
}

.sidebar-nav {
  list-style: none;
  flex: 1;
}
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 24px;
  color: rgba(250, 247, 240, 0.7);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.sidebar-nav li a:hover {
  color: var(--paper);
  background: rgba(250, 247, 240, 0.04);
}
.sidebar-nav li a.active {
  color: var(--paper);
  background: rgba(199, 122, 46, 0.12);
  border-left-color: var(--accent);
}
.sidebar-nav svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid rgba(250, 247, 240, 0.12);
  font-size: 12px;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--paper);
  font-weight: 600;
  flex-shrink: 0;
  font-size: 13px;
}
.sidebar-user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-user-name {
  color: var(--paper);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  color: rgba(250, 247, 240, 0.55);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(250, 247, 240, 0.6);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 0;
}
.sidebar-logout:hover { color: var(--accent); }
.sidebar-logout svg { width: 16px; height: 16px; }

.main {
  padding: 0;
  background: var(--paper);
  min-height: 100vh;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--hairline);
  background: var(--paper);
  gap: 16px;
}
@media (max-width: 900px) {
  .topbar { padding: 14px 20px; }
}
.topbar-title {
  font-family: 'Fraunces', serif;
  font-size: 24px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.topbar-title-sub {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.main-content {
  padding: 32px;
  max-width: 1400px;
}
@media (max-width: 900px) {
  .main-content { padding: 24px 20px; }
}

/* Mobile hamburger for sidebar */
.sidebar-toggle {
  display: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 8px;
  color: var(--ink);
}
@media (max-width: 900px) {
  .sidebar-toggle { display: block; }
}
.sidebar-toggle svg { width: 24px; height: 24px; }

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 31, 58, 0.4);
  z-index: 150;
}
.scrim.open { display: block; }

/* =====================================================================
   KPI / CARD BLOCKS (used on dashboard)
   ===================================================================== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 24px;
}
.card-title {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
  margin-bottom: 12px;
}
.card-value {
  font-family: 'Fraunces', serif;
  font-size: 36px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.card-value .unit {
  font-size: 14px;
  color: var(--ink-muted);
  font-style: italic;
  margin-left: 4px;
  font-weight: 400;
}
.card-sub {
  font-size: 13px;
  color: var(--ink-muted);
}

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

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