/* ============================================
   WEBAPP — Main Stylesheet
   ============================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0f14;
  --bg-2:      #13161e;
  --bg-3:      #1a1e28;
  --bg-4:      #222736;
  --border:    rgba(255,255,255,0.08);
  --border-md: rgba(255,255,255,0.14);

  --text:      #e8eaf0;
  --text-2:    #9aa0b4;
  --text-3:    #5c6278;

  --accent:      #4f7cff;
  --accent-h:    #3d66e8;
  --accent-glow: rgba(79,124,255,0.25);

  --success: #22c55e;
  --error:   #ef4444;
  --warning: #f59e0b;

  --radius:    12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;

  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.6);
}

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: var(--font); }

/* ---- Auth Layout ---- */
.auth-root {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 2rem 1rem;
  background: var(--bg);
}

.auth-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.auth-bg__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
}
.auth-bg__orb--1 {
  width: 500px; height: 500px;
  background: #4f7cff;
  top: -150px; left: -100px;
}
.auth-bg__orb--2 {
  width: 350px; height: 350px;
  background: #7c3aed;
  bottom: -80px; right: -80px;
}
.auth-bg__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 48px 48px;
}

.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}
.auth-container--wide { max-width: 560px; }

/* Brand */
.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
}
.auth-brand__icon {
  width: 36px; height: 36px;
  color: var(--accent);
}
.auth-brand__icon svg { width: 100%; height: 100%; }
.auth-brand__name {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* Card */
.auth-card {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  animation: card-in 0.35s cubic-bezier(0.22,1,0.36,1);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-card__header { margin-bottom: 1.75rem; }
.auth-card__title {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
}
.auth-card__sub { font-size: 0.875rem; color: var(--text-2); }

.auth-card__footer { margin-top: 1.5rem; text-align: center; }
.auth-card__footer-text { font-size: 0.875rem; color: var(--text-2); }

.auth-link { color: var(--accent); font-weight: 500; }
.auth-link:hover { text-decoration: underline; }

/* ---- Form Fields ---- */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 0.35rem; }

.field__label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.03em;
}
.field__required { color: var(--error); }

.field__wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.field__icon {
  position: absolute;
  left: 0.75rem;
  width: 16px; height: 16px;
  color: var(--text-3);
  pointer-events: none;
}

.field__input {
  width: 100%;
  padding: 0.65rem 0.875rem 0.65rem 2.4rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9375rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.field__input::placeholder { color: var(--text-3); }
.field__input:focus {
  border-color: var(--accent);
  background: var(--bg-4);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* input without icon */
.field__wrap:not(:has(.field__icon)) .field__input { padding-left: 0.875rem; }

.field__toggle {
  position: absolute;
  right: 0.625rem;
  color: var(--text-3);
  padding: 0.2rem;
  display: flex;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s;
}
.field__toggle:hover { color: var(--text-2); }
.field__toggle svg { width: 16px; height: 16px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  position: relative;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.btn--primary:hover {
  background: var(--accent-h);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}
.btn--primary:active { transform: translateY(0); }

.btn--full { width: 100%; margin-top: 0.5rem; }

.btn__text { transition: opacity 0.15s; }
.btn__loader { display: none; position: absolute; }
.btn__loader svg { width: 20px; height: 20px; }

.htmx-indicator { display: none !important; }
.htmx-request .htmx-indicator { display: flex !important; }
.htmx-request .btn__text { opacity: 0; }
.htmx-request .btn__loader { display: flex; }

/* ---- Alerts ---- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  animation: alert-in 0.2s ease;
}
@keyframes alert-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }

.alert--error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  color: #fca5a5;
}
.alert--success {
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.25);
  color: #86efac;
}

.error-list { margin-top: 0.25rem; padding-left: 1rem; list-style: disc; }
.error-list li { margin-bottom: 0.15rem; }

/* ---- Signup Success ---- */
.signup-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1rem 0 0.5rem;
  gap: 1rem;
  animation: card-in 0.35s ease;
}
.signup-success__icon { color: var(--success); width: 64px; height: 64px; }
.signup-success__icon svg { width: 100%; height: 100%; }
.signup-success__title { font-size: 1.4rem; font-weight: 600; }
.signup-success__desc { color: var(--text-2); font-size: 0.9375rem; }

.success-circle {
  stroke-dasharray: 180;
  stroke-dashoffset: 180;
  animation: draw 0.5s ease forwards 0.1s;
}
.success-check {
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  animation: draw 0.4s ease forwards 0.5s;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---- Spinner ---- */
.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- App Layout ---- */
.app-root { display: flex; min-height: 100vh; background: #0d0f14; }

.sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.75rem;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0.5rem 1.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.sidebar__brand .auth-brand__icon { width: 26px; height: 26px; color: var(--accent); }
.sidebar__brand .auth-brand__icon svg { width: 100%; height: 100%; }

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5625rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
  transition: all 0.15s;
}
.sidebar__link svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar__link:hover { background: var(--bg-3); color: var(--text); }
.sidebar__link--active { background: rgba(79,124,255,0.12); color: var(--accent); }

.sidebar__user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 0.5rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.sidebar__avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 600;
  flex-shrink: 0;
}
.sidebar__user-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sidebar__user-name {
  font-size: 0.8125rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar__logout {
  color: var(--text-3);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  transition: color 0.15s, background 0.15s;
}
.sidebar__logout:hover { color: var(--error); background: rgba(239,68,68,0.08); }
.sidebar__logout svg { width: 18px; height: 18px; }

.app-main { flex: 1; padding: 2rem; overflow-y: auto; min-width: 0; background: #0d0f14; }

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
}
.app-header__title { font-size: 1.5rem; font-weight: 600; }
.app-header__sub { font-size: 0.875rem; color: var(--text-2); margin-top: 0.2rem; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: border-color 0.15s, transform 0.15s;
}
.stat-card:hover { border-color: var(--border-md); transform: translateY(-2px); }

.stat-card__icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-card__icon svg { width: 22px; height: 22px; }
.stat-card__icon--blue  { background: rgba(79,124,255,0.12); color: var(--accent); }
.stat-card__icon--green { background: rgba(34,197,94,0.12);  color: var(--success); }
.stat-card__icon--amber { background: rgba(245,158,11,0.12); color: var(--warning); }

.stat-card__content { display: flex; flex-direction: column; }
.stat-card__label { font-size: 0.75rem; color: var(--text-2); }
.stat-card__value { font-size: 1.5rem; font-weight: 600; line-height: 1.2; }

.info-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.info-card__title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.info-item { display: flex; flex-direction: column; gap: 0.25rem; }
.info-item__label { font-size: 0.72rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.info-item__value { font-size: 0.9375rem; font-weight: 500; }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge--admin    { background: rgba(239,68,68,0.15);  color: #fca5a5; }
.badge--manager  { background: rgba(79,124,255,0.15); color: #93b4ff; }
.badge--staff    { background: rgba(100,116,139,0.15);color: #94a3b8; }
.badge--delivery { background: rgba(245,158,11,0.15); color: #fcd34d; }
.badge--status-in     { background: rgba(34,197,94,0.15);  color: #86efac; }
.badge--status-out    { background: rgba(239,68,68,0.15);  color: #fca5a5; }
.badge--status-active { background: rgba(79,124,255,0.15); color: #93b4ff; }

/* ---- Error Pages ---- */
.error-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
  padding: 2rem;
}
.error-page__code { font-size: 7rem; font-weight: 800; color: var(--bg-4); line-height: 1; }
.error-page__title { font-size: 1.25rem; font-weight: 600; }
.error-page__desc  { color: var(--text-2); }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 3px; }

/* ---- Data Table ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th {
  text-align: left;
  padding: 0.625rem 1rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg-3); }

.member-id {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.text-muted { color: var(--text-3); font-size: 0.8125rem; }

/* ---- Empty State ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 3rem 1rem;
  color: var(--text-3);
  text-align: center;
}
.empty-state svg {
  width: 48px; height: 48px;
  opacity: 0.4;
}
.empty-state p { font-size: 0.9rem; }