/**
 * ============================================================================
 * SchedgEdit ALPHA 1.1.1 - MAIN STYLESHEET
 * ============================================================================
 * Manager pages are desktop-first; employee pages collapse cleanly for phones.
 * Every major visual region is labeled so styling can be edited quickly.
 * ============================================================================
 */

/* ---------- DESIGN TOKENS ---------- */
:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #111827;
  --primary-soft: #eef2ff;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --success: #166534;
  --success-soft: #f0fdf4;
  --warning: #92400e;
  --warning-soft: #fffbeb;
  --radius: 16px;
  --shadow: 0 10px 28px rgba(17, 24, 39, 0.07);
}

/* ---------- BASE PAGE RESET ---------- */
* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

/* ---------- SHARED TOP NAVIGATION ---------- */
.topbar {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 28px;
  background: #111827;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand-block { display: flex; align-items: center; gap: 18px; }
.brand { font-weight: 900; font-size: 1.25rem; letter-spacing: -0.03em; }
.brand span, .auth-logo span { font-size: .65em; padding: 3px 7px; border-radius: 999px; background: #fff; color: #111827; margin-left: 4px; }
.store-label { color: #cbd5e1; font-size: .9rem; }
.top-actions { display: flex; align-items: center; gap: 18px; font-size: .92rem; }
.top-actions a:hover, .link-button:hover { color: #c7d2fe; }
.inline-form { display: inline; margin: 0; }
.link-button { border: 0; background: none; color: #fff; padding: 0; }

/* ---------- GENERIC PAGE LAYOUT ---------- */
.page { width: min(1580px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 56px; }
.narrow-page { max-width: 1000px; }
.manager-page { max-width: 1580px; }
.employee-page { max-width: 850px; }
.section-heading, .manager-toolbar, .employee-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; letter-spacing: -0.035em; }
h2 { letter-spacing: -0.02em; }
.eyebrow { text-transform: uppercase; letter-spacing: .1em; font-size: .72rem; color: var(--muted); font-weight: 800; margin-bottom: 7px; }
.muted { color: var(--muted); }

/* ---------- BUTTONS ---------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 750;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.button:active { transform: translateY(1px); }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: #273449; }
.button-secondary { background: #fff; color: var(--text); border-color: var(--line); }
.button-secondary:hover { border-color: #c7cdd6; background: #fafafa; }
.button-danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.button:disabled { cursor: not-allowed; opacity: .6; }
.button-small { min-height: 34px; padding: 6px 10px; font-size: .85rem; }
.button-wide { width: 100%; }
.toolbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.toolbar-actions form { margin: 0; }

/* ---------- FLASH MESSAGES ---------- */
.flash { padding: 12px 14px; border-radius: 11px; margin-bottom: 18px; border: 1px solid; transition: opacity .3s ease; }
.flash-success { background: var(--success-soft); color: var(--success); border-color: #bbf7d0; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.flash-fade { opacity: 0; }

/* ---------- GENERIC PANELS ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.compact-panel { padding: 18px 20px; }
.panel-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.panel-heading-row h2 { margin-bottom: 0; }
.empty-state { padding: 24px; border: 1px dashed #cbd5e1; color: var(--muted); border-radius: 12px; text-align: center; background: var(--panel-soft); }

/* ---------- STATUS PILLS ---------- */
.status-line { display: flex; align-items: center; gap: 10px; }
.status-pill { display: inline-flex; padding: 4px 9px; border-radius: 999px; font-size: .72rem; font-weight: 850; letter-spacing: .05em; }
.status-pill.draft { color: #92400e; background: #fef3c7; }
.status-pill.published { color: #166534; background: #dcfce7; }
.status-pill.denied { color: #991b1b; background: #fee2e2; }

/* ---------- MANAGER SUMMARY METRICS ---------- */
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: 0 6px 20px rgba(17,24,39,.04); }
.metric-card span { color: var(--muted); display: block; font-size: .84rem; }
.metric-card strong { font-size: 1.75rem; display: block; margin-top: 5px; }
.metric-card a { display: inline-block; margin-top: 7px; color: #4338ca; font-size: .82rem; }

/* ---------- LABOR DISTRIBUTION BAR ---------- */
.labor-panel { padding: 22px; }
.labor-bar { display: flex; width: 100%; height: 32px; overflow: hidden; border-radius: 10px; background: #eef2f7; border: 1px solid #dde3eb; }
.labor-segment { min-width: 2px; height: 100%; transition: filter .15s ease, transform .15s ease; }
.labor-segment:hover { filter: brightness(.9); transform: scaleY(1.08); }
.labor-legend { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px 18px; margin-top: 16px; }
.labor-person { display: flex; align-items: center; gap: 9px; min-width: 0; }
.labor-person div { min-width: 0; }
.labor-person strong, .labor-person span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.labor-person span { color: var(--muted); font-size: .8rem; }
.color-dot { width: 11px; height: 11px; border-radius: 999px; flex: 0 0 11px; }

/* ---------- EMPLOYEE COLOR PALETTE ---------- */
.employee-color-0 { background: #4f46e5; }
.employee-color-1 { background: #0f766e; }
.employee-color-2 { background: #c2410c; }
.employee-color-3 { background: #be185d; }
.employee-color-4 { background: #7c3aed; }
.employee-color-5 { background: #0369a1; }
.employee-color-6 { background: #3f6212; }
.employee-color-7 { background: #a16207; }
.employee-color-8 { background: #9f1239; }
.employee-color-9 { background: #4338ca; }
.employee-color-10 { background: #155e75; }
.employee-color-11 { background: #854d0e; }

/* ---------- SEVEN DAY MANAGER CARD GRID ---------- */
.day-card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.day-card {
  min-height: 290px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 6px 20px rgba(17,24,39,.04);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.day-card:hover { transform: translateY(-2px); border-color: #c7d2fe; box-shadow: 0 14px 30px rgba(17,24,39,.09); }
.day-card-header { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.day-card-header span:first-child { display: block; color: var(--muted); text-transform: uppercase; font-size: .7rem; font-weight: 800; }
.day-card-header strong { display: block; margin-top: 4px; }
.edit-chip { background: var(--primary-soft); color: #3730a3; padding: 5px 8px; border-radius: 8px; font-size: .75rem; font-weight: 750; }
.day-card-metrics { display: flex; gap: 18px; margin: 16px 0; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.day-card-metrics span { font-size: .8rem; color: var(--muted); }
.day-card-metrics strong { color: var(--text); }
.day-shift-list { display: flex; flex-direction: column; gap: 8px; }
.mini-shift { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 8px; font-size: .82rem; }
.mini-shift span:last-child { color: var(--muted); }

/* ---------- AUDIT HISTORY ---------- */
.audit-row { display: grid; grid-template-columns: 170px 1fr 220px; gap: 14px; border-top: 1px solid var(--line); padding: 11px 0; font-size: .84rem; }
.audit-row small { color: var(--muted); text-align: right; }

/* ---------- FORM ELEMENTS ---------- */
.stack-form { display: flex; flex-direction: column; gap: 14px; }
.stack-form label, .shift-edit-row label, .two-column-form label { font-size: .82rem; color: var(--muted); font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 9px;
  padding: 9px 10px;
  margin-top: 6px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(99,102,241,.12); border-color: #818cf8; }
.check-label { display: flex !important; align-items: center; gap: 9px; color: var(--text) !important; font-weight: 600 !important; }
.check-label input { width: auto; margin: 0; }
.feature-unavailable { color: var(--muted) !important; cursor: not-allowed; }
.feature-unavailable input { cursor: not-allowed; }
.two-column-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- MANAGER DAILY EDITOR ---------- */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.editor-table-panel { margin-bottom: 0; }
.shift-edit-row { display: grid; grid-template-columns: 1.35fr 1.15fr .7fr .7fr .55fr auto; gap: 9px; align-items: end; padding: 13px 0; border-top: 1px solid var(--line); }
.employee-cell { display: flex; align-items: center; gap: 8px; }
.employee-cell select { margin: 0; }
.row-actions { display: flex; align-items: end; }
.delete-form { display: flex; justify-content: flex-end; margin-top: -4px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.sticky-editor-card { position: sticky; top: 92px; margin-bottom: 0; }
.warning-panel { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; background: var(--warning-soft); color: var(--warning); border: 1px solid #fde68a; padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; }

/* ---------- REQUEST CENTER ---------- */
.requests-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.request-card { display: flex; justify-content: space-between; gap: 18px; padding: 16px 0; border-top: 1px solid var(--line); }
.request-card h3 { margin: 7px 0 5px; }
.request-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.request-actions form { margin: 0; }

/* ---------- TABLES ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- AUTHENTICATION PAGE ---------- */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #eef2ff 0, #f5f7fb 40%); }
.auth-card { width: min(460px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); padding: 30px; }
.auth-logo { font-weight: 900; font-size: 1.25rem; margin-bottom: 22px; }
.auth-card h1 { font-size: 2rem; }
.demo-credentials { margin-top: 20px; padding: 14px; border-radius: 12px; background: #f8fafc; display: grid; gap: 6px; font-size: .85rem; }
.demo-credentials code { color: #4338ca; }

/* ---------- STORE SELECTOR ---------- */
.store-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.store-choice-card { display: flex; justify-content: space-between; gap: 20px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); }
.store-choice-card h2 { margin: 4px 0; }
.store-choice-card p { margin: 0; color: var(--muted); }
.card-kicker { font-size: .72rem; font-weight: 800; letter-spacing: .08em; color: #4338ca; }

/* ---------- EMPLOYEE MOBILE-FIRST UI ---------- */
.employee-hero { align-items: center; }
.week-nav-mobile { display: flex; gap: 7px; }
.employee-hours-card { background: #111827; color: #fff; border-radius: 18px; padding: 22px; margin-bottom: 18px; }
.employee-hours-card span { color: #cbd5e1; display: block; }
.employee-hours-card strong { display: block; font-size: 2.6rem; margin-top: 4px; }
.employee-panel { box-shadow: 0 6px 18px rgba(17,24,39,.04); }
.employee-shift-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); padding: 15px 0; }
.employee-shift-card h3 { margin: 0 0 5px; }
.employee-shift-card p { margin-bottom: 0; }
.week-calendar-export { margin-bottom: 12px; }
.week-calendar-export .button { min-height: 44px; }
.week-calendar-export p { margin: 8px 0 0; font-size: .875rem; }
.shift-calendar-link { display: inline-flex; align-items: center; min-height: 44px; font-size: .875rem; text-decoration: underline; }
.swap-details { min-width: 190px; }
.swap-details summary, .details-heading { cursor: pointer; font-weight: 800; }
.compact-form { margin-top: 10px; }
.full-schedule-mobile { margin-top: 15px; }
.full-day-block { padding: 14px 0; border-top: 1px solid var(--line); }
.full-day-shift { display: flex; justify-content: space-between; gap: 14px; padding: 6px 0; font-size: .86rem; }
.full-day-shift span { color: var(--muted); text-align: right; }
.employee-request-card { align-items: center; }
.request-history { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 15px; }
.history-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; }
.notification-form { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

/* ---------- ADVANCED STORE SETTINGS ---------- */
.settings-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.danger-panel { border-color: #fecaca; }
.danger-panel h2 { color: var(--danger); }
.danger-panel .warning-panel { margin-bottom: 18px; }
.confirm-store-code { max-width: 320px; }
.settings-divider { border-top: 1px solid var(--line); margin: 26px 0 20px; }
.email-settings-panel { margin-top: 18px; max-width: 760px; }
.email-settings-panel .warning-panel { margin-bottom: 16px; }
.email-settings-form { max-width: 460px; }
.email-setup-status { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.email-setup-status > div { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-soft); }
.email-setup-status strong { display: block; margin-bottom: 8px; }
.email-setup-status p { font-size: .84rem; line-height: 1.45; margin: 10px 0; }
.verify-email-form { margin-top: 14px; }
.remove-email-form { margin-top: 14px; }

/* ---------- RESPONSIVE MANAGER FALLBACK ---------- */
@media (max-width: 1200px) {
  .day-card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .labor-legend { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .shift-edit-row { grid-template-columns: 1fr 1fr 1fr; }
  .row-actions { align-self: stretch; }
}

@media (max-width: 900px) {
  .page { width: min(100% - 24px, 850px); padding-top: 18px; }
  .topbar { position: static; padding: 14px 16px; align-items: flex-start; }
  .brand-block { flex-direction: column; align-items: flex-start; gap: 3px; }
  .top-actions { gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
  .manager-toolbar, .section-heading, .employee-hero { flex-direction: column; }
  .toolbar-actions { justify-content: flex-start; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .day-card-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .labor-legend { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .editor-layout, .requests-layout, .settings-layout, .email-setup-status { grid-template-columns: 1fr; }
  .sticky-editor-card { position: static; }
  .audit-row { grid-template-columns: 1fr; gap: 4px; }
  .audit-row small { text-align: left; }
  .store-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .topbar { flex-direction: column; }
  .top-actions { justify-content: flex-start; }
  .metric-grid, .day-card-grid, .labor-legend { grid-template-columns: 1fr; }
  .day-card { min-height: 0; }
  .two-column-form { grid-template-columns: 1fr; }
  .employee-shift-card, .request-card, .full-day-shift { flex-direction: column; align-items: flex-start; }
  .full-day-shift span { text-align: left; }
  .swap-details { width: 100%; }
  .shift-edit-row { grid-template-columns: 1fr; }
}

/* ---------- EMPLOYEE ROSTER ADMIN EXTRAS ---------- */
.inline-dot { display: inline-block; margin-right: 7px; vertical-align: middle; }
.small-note { font-size: .78rem; margin-top: 16px; line-height: 1.45; }

.offline-disabled { opacity: .5; }

.employee-admin-layout > * { min-width: 0; }
[data-offline-form] input[type="checkbox"], .legal-acknowledgments input[type="checkbox"] { width: auto; margin: 3px 6px 0 0; flex-shrink: 0; }
[data-offline-form] label:has(input[type="checkbox"]), .legal-acknowledgments label { display: block; line-height: 1.6; }
.legal-acknowledgments { min-inline-size: 0; margin: 12px 0; padding: 12px; border: 1px solid var(--border, #d1d5db); border-radius: 10px; }
.legal-acknowledgments label { margin: 10px 0; }
[data-online-fields] > label { margin-bottom: 12px; }

.phone-entry-disabled { opacity: .5; }
.phone-entry-disabled input { cursor: not-allowed; }
