/* =====================================================================
   Suncoast Local App — admin UI styles
   Mobile-first. Brand-consistent with the marketing site.
   ===================================================================== */

:root {
  /* Brand colors (matching marketing site) */
  --brand-navy:        #021327;
  --brand-navy-soft:   #06203c;
  --brand-cream:       #f5f3ee;
  --brand-cream-soft:  #ebe6db;
  --brand-gold:        #d29a3d;
  --brand-gold-soft:   #e8b15a;
  --brand-teal:        #2c5f5d;

  /* Surfaces */
  --surface-bg:        #f5f3ee;
  --surface-1:         #ffffff;
  --surface-2:         #fdfcf8;
  --surface-sidebar:   #021327;

  /* Text */
  --text-1:            #021327;
  --text-2:            #3a4a60;
  --text-3:            #5e6c80;
  --text-on-navy:      #f5f3ee;
  --text-on-navy-soft: rgba(245, 243, 238, 0.7);

  /* Borders */
  --border-subtle:     #e8e4d6;
  --border-strong:     #cfc9b8;

  /* States */
  --color-success:     #2f7d4d;
  --color-error:       #b73e3e;
  --color-warn:        #c87d2b;
  --color-info:        #2563eb;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, monospace;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(2, 19, 39, 0.05);
  --shadow-md: 0 4px 12px rgba(2, 19, 39, 0.08);
  --shadow-lg: 0 12px 32px rgba(2, 19, 39, 0.15);

  /* Sidebar */
  --sidebar-width: 240px;
  --sidebar-z: 100;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-1);
  background: var(--surface-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; color: var(--text-1); }
p  { margin: 0 0 var(--space-3); color: var(--text-2); }

hr { border: 0; border-top: 1px solid var(--border-subtle); margin: var(--space-5) 0; }

/* =====================================================================
   AUTH PAGES (login, forgot, reset, invite)
   ===================================================================== */

body.auth {
  min-height: 100vh;
  background: var(--brand-navy);
  background-image: radial-gradient(circle at 30% 20%, rgba(210,154,61,0.12), transparent 50%),
                    radial-gradient(circle at 70% 80%, rgba(44,95,93,0.15), transparent 50%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}

.auth__shell {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
}

.auth__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--brand-cream);
  text-decoration: none;
}
.auth__brand:hover { text-decoration: none; }

.auth__brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--brand-gold);
  color: var(--brand-navy);
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: var(--radius-md);
}

.auth__brand-text {
  font-size: 17px;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.auth__card {
  width: 100%;
  background: var(--surface-1);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
}

.auth__title {
  margin: 0 0 var(--space-2);
  font-size: 24px;
}

.auth__lede {
  color: var(--text-3);
  font-size: 14px;
  margin: 0 0 var(--space-5);
}

.auth__alt {
  text-align: center;
  margin: var(--space-5) 0 0;
  font-size: 14px;
  color: var(--text-3);
}

/* =====================================================================
   ADMIN SHELL (sidebar + main)
   ===================================================================== */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--surface-sidebar);
  color: var(--text-on-navy);
  display: flex;
  flex-direction: column;
  z-index: var(--sidebar-z);
  /* Mobile: hidden by default, slid in via transform */
  transform: translateX(-100%);
  transition: transform 200ms ease;
}

.sidebar.is-open { transform: translateX(0); }

.sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5);
  border-bottom: 1px solid rgba(245,243,238,0.1);
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--brand-cream);
  text-decoration: none;
}
.sidebar__logo:hover { text-decoration: none; }

.sidebar__logo-mark {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-gold);
  color: var(--brand-navy);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.05em;
  border-radius: var(--radius-sm);
}

.sidebar__logo-text {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.sidebar__close {
  background: none;
  border: 0;
  color: var(--text-on-navy);
  font-size: 28px;
  line-height: 1;
  width: 32px;
  height: 32px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.sidebar__close:hover { background: rgba(245,243,238,0.06); }

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) 0;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-list__heading {
  padding: var(--space-4) var(--space-5) var(--space-2);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(245,243,238,0.5);
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px var(--space-5);
  color: var(--text-on-navy);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background 80ms ease, border-color 80ms ease;
}

.nav-link:hover {
  background: rgba(245,243,238,0.04);
  text-decoration: none;
}

.nav-link.is-active {
  background: rgba(210,154,61,0.1);
  border-left-color: var(--brand-gold);
  color: var(--brand-gold-soft);
}

.nav-link.is-stub {
  color: rgba(245,243,238,0.5);
  cursor: default;
}
.nav-link.is-stub:hover {
  background: transparent;
}

.badge {
  display: inline-block;
  background: rgba(245,243,238,0.1);
  color: rgba(245,243,238,0.7);
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 999px;
  text-transform: uppercase;
}

.sidebar__footer {
  padding: var(--space-3);
  border-top: 1px solid rgba(245,243,238,0.1);
}

.user-menu summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius-sm);
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: rgba(245,243,238,0.04); }

.user-menu__avatar {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-gold);
  color: var(--brand-navy);
  font-weight: 700;
  border-radius: 50%;
  font-size: 13px;
}

.user-menu__name {
  flex: 1;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu ul {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
  background: rgba(245,243,238,0.04);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.user-menu__role {
  padding: var(--space-2) var(--space-3);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(245,243,238,0.5);
  border-bottom: 1px solid rgba(245,243,238,0.08);
}

.user-menu li a,
.user-menu__logout {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  background: none;
  border: 0;
  color: var(--text-on-navy);
  text-decoration: none;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.user-menu li a:hover,
.user-menu__logout:hover {
  background: rgba(245,243,238,0.06);
  text-decoration: none;
}

/* Mobile sidebar toggle button (top-left of viewport when sidebar closed) */
.sidebar-toggle {
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  width: 44px;
  height: 44px;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  z-index: calc(var(--sidebar-z) - 1);
  box-shadow: var(--shadow-sm);
}
.sidebar-toggle__bar {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-1);
  border-radius: 1px;
}

.main {
  min-height: 100vh;
  padding: var(--space-6) var(--space-4) var(--space-7);
}

.main__inner {
  max-width: 1200px;
  margin: 0 auto;
  /* Push down so the sidebar toggle button doesn't overlap */
  padding-top: var(--space-7);
}

@media (min-width: 900px) {
  .sidebar { transform: translateX(0); }
  .sidebar__close { display: none; }
  .sidebar-toggle { display: none; }
  .main { margin-left: var(--sidebar-width); padding: var(--space-6); }
  .main__inner { padding-top: 0; }
}

/* =====================================================================
   PAGE LAYOUT — page-head, panels, dash-grid
   ===================================================================== */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.page-head__title {
  font-size: 26px;
  margin: 0 0 var(--space-1);
}

.page-head__lede {
  margin: 0;
  color: var(--text-3);
  font-size: 14px;
}

.page-head__actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

.panel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.panel__title {
  font-size: 16px;
  margin: 0;
}

.dash-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .dash-grid { grid-template-columns: 1.6fr 1fr; }
}

/* =====================================================================
   STAT CARDS
   ===================================================================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.stat-card {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
}

.stat-card__value {
  font-size: 32px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--brand-navy);
}

.stat-card__label {
  margin-top: var(--space-1);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* =====================================================================
   ACTIVITY LIST
   ===================================================================== */

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.activity {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
}
.activity:last-child { border-bottom: 0; }

.activity__action {
  color: var(--text-3);
  margin-left: var(--space-2);
}

.activity__entity {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-3);
  margin-left: var(--space-2);
}

.activity__time {
  color: var(--text-3);
  font-size: 12px;
  white-space: nowrap;
}

/* Phase list on dashboard */
.phase-list { list-style: none; margin: 0; padding: 0; }
.phase {
  display: block;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
}
.phase:last-child { border-bottom: 0; }
.phase strong { display: block; margin-bottom: var(--space-1); font-size: 14px; }
.phase span { color: var(--text-3); font-size: 13px; }
.phase--done strong::before {
  content: "✓";
  color: var(--color-success);
  margin-right: var(--space-2);
}
.phase--current strong { color: var(--brand-gold); }
.phase--current strong::before {
  content: "→";
  margin-right: var(--space-2);
}

/* =====================================================================
   TABLES
   ===================================================================== */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th, .table td {
  padding: var(--space-3) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.table th {
  font-weight: 600;
  color: var(--text-3);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--surface-2);
}

.table tbody tr:hover { background: var(--surface-2); }

/* Scroll the table on small screens instead of wrapping */
.panel:has(> .table) { padding: 0; overflow-x: auto; }
.panel:has(> .table) > .table { margin: 0; }

/* =====================================================================
   PILLS / BADGES (status, role)
   ===================================================================== */

.pill {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-2);
  white-space: nowrap;
}

.pill--role-super_admin { background: #fef3e2; color: #8a5a16; border-color: #f0c97a; }
.pill--role-admin       { background: #e8f0ff; color: #1d4a8a; border-color: #b8cdf0; }
.pill--role-sales       { background: #e6f4ea; color: #2f7d4d; border-color: #b0d8be; }
.pill--role-designer    { background: #f0e8ff; color: #5a2a9c; border-color: #c8b3e8; }
.pill--role-client      { background: #fff4e0; color: #8a5500; border-color: #f0d090; }

.pill--status-active   { background: #e6f4ea; color: #2f7d4d; border-color: #b0d8be; }
.pill--status-pending  { background: #fff4e0; color: #8a5500; border-color: #f0d090; }
.pill--status-disabled { background: #fde8e8; color: #8a2a2a; border-color: #f0bbbb; }

/* =====================================================================
   FORMS
   ===================================================================== */

.form { display: flex; flex-direction: column; gap: var(--space-4); }
.form--narrow { max-width: 480px; }
.form--inline { flex-direction: row; align-items: flex-end; gap: var(--space-3); flex-wrap: wrap; }
.form--inline label { display: block; font-size: 13px; margin-bottom: var(--space-1); color: var(--text-3); }

.form-row { display: flex; flex-direction: column; gap: var(--space-2); }
.form-row label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.form-row--two-col {
  flex-direction: row;
  gap: var(--space-3);
}
.form-row--two-col > div { flex: 1; display: flex; flex-direction: column; gap: var(--space-2); }

.form input[type="text"],
.form input[type="email"],
.form input[type="password"],
.form select,
.form textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-1);
}

.form input:focus,
.form select:focus,
.form textarea:focus {
  outline: 2px solid var(--brand-gold);
  outline-offset: -1px;
  border-color: var(--brand-gold);
}

.form input:disabled,
.form select:disabled {
  background: var(--surface-2);
  color: var(--text-3);
  cursor: not-allowed;
}

.form-hint {
  font-size: 12px;
  color: var(--text-3);
}

/* =====================================================================
   BUTTONS
   ===================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background 80ms ease, border-color 80ms ease, color 80ms ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn--primary {
  background: var(--brand-gold);
  color: var(--brand-navy);
  border-color: var(--brand-gold);
}
.btn--primary:hover { background: var(--brand-gold-soft); border-color: var(--brand-gold-soft); }

.btn--secondary {
  background: var(--surface-1);
  color: var(--text-1);
  border-color: var(--border-strong);
}
.btn--secondary:hover { background: var(--surface-2); border-color: var(--text-3); }

.btn--ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn--ghost:hover { background: var(--surface-2); }

.btn--danger {
  background: var(--color-error);
  color: white;
  border-color: var(--color-error);
}
.btn--danger:hover { background: #9b3535; border-color: #9b3535; }

.btn--full { width: 100%; }
.btn--sm { padding: 6px 12px; font-size: 13px; }

/* =====================================================================
   FLASH MESSAGES
   ===================================================================== */

.flash-stack { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-5); }

.flash {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 14px;
  border: 1px solid transparent;
}

.flash--success { background: #e6f4ea; color: #225f3a; border-color: #b0d8be; }
.flash--error   { background: #fde8e8; color: #7a2424; border-color: #f0bbbb; }
.flash--warning { background: #fff4e0; color: #6e4400; border-color: #f0d090; }
.flash--info    { background: #e8f0ff; color: #15376a; border-color: #b8cdf0; }

/* Spacing for inline flashes inside auth cards */
body.auth .flash { margin-bottom: var(--space-3); }

/* =====================================================================
   DETAIL LIST (definition list for user/account info)
   ===================================================================== */

.detail-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-2) var(--space-4);
  margin: 0;
  font-size: 14px;
}
.detail-list dt {
  font-weight: 600;
  color: var(--text-3);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.detail-list dd { margin: 0; }

/* =====================================================================
   MISC
   ===================================================================== */

.empty {
  color: var(--text-3);
  font-size: 14px;
  text-align: center;
  padding: var(--space-5) 0;
}

.link { color: var(--brand-teal); }
