/* ═══════════════════════════════════════════════════════════════
   Oscar Accounting Coder — Stylesheet
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:      #1B4FBF;
  --primary-dark: #143D99;
  --primary-light:#4A7DE8;
  --navy:         #0F1F3D;
  --text:         #1B2B4E;
  --text-muted:   #5A6A82;
  --bg:           #F4F6F9;
  --border:       #C5CDD9;
  --white:        #FFFFFF;
  --success:      #107c10;
  --success-bg:   #DFF6DD;
  --error:        #d83b01;
  --error-bg:     #FDE7E0;
  --info-bg:      #EBF3FB;
  --info-border:  #B3D1F0;
  --shadow-sm:    0 1px 3px rgba(15,31,61,.08), 0 1px 2px rgba(15,31,61,.06);
  --shadow-md:    0 4px 16px rgba(15,31,61,.10), 0 2px 6px rgba(15,31,61,.07);
  --shadow-lg:    0 8px 32px rgba(15,31,61,.13);
  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    14px;
  --transition:   150ms ease;
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 72px; /* room for filename bar */
}

/* ── Header ─────────────────────────────────────────────────── */
.app-header {
  background: var(--navy);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.header-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 8px;
}

.header-titles {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.header-oscar {
  font-size: 1.55rem;
  font-weight: 800;
  color: #7DB8F7;
  letter-spacing: .04em;
}

.header-tagline {
  font-size: .78rem;
  color: #A8C4E8;
  font-weight: 400;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.header-right {
  font-size: .78rem;
  color: #7A92B0;
  letter-spacing: .02em;
}

/* ── Step Bar ────────────────────────────────────────────────── */
.step-bar-wrap {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: .75rem 2rem;
  overflow-x: auto;
}

.step-bar {
  display: flex;
  gap: .5rem;
  min-width: max-content;
  margin: 0 auto;
  max-width: 900px;
}

.step-pill {
  padding: .3rem .9rem;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: default;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  background: #E3E8F0;
  color: #8A98B0;
  border: 1.5px solid transparent;
}

.step-pill.current {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary-dark);
  box-shadow: 0 2px 6px rgba(27,79,191,.30);
}

.step-pill.done {
  background: var(--success-bg);
  color: var(--success);
  border-color: #A4D9A4;
}

.step-pill.done::before {
  content: "✓ ";
  font-weight: 700;
}

/* ── Main Wrap & Card ────────────────────────────────────────── */
.main-wrap {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
}

.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2rem 2.25rem 1.75rem;
  width: 100%;
  max-width: 640px;
}

.step-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 1.5rem;
  padding-bottom: .75rem;
  border-bottom: 2px solid var(--bg);
}

/* ── Drop Zone ───────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  outline: none;
  margin-bottom: 1.25rem;
}

.drop-zone:hover,
.drop-zone:focus,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: #EEF3FC;
}

.drop-icon {
  width: 48px;
  height: 48px;
  color: var(--primary-light);
  margin: 0 auto .75rem;
  display: block;
}

.drop-primary {
  font-size: 1rem;
  color: var(--text);
  font-weight: 500;
}

.drop-link {
  color: var(--primary);
  text-decoration: underline;
  font-weight: 600;
}

.drop-secondary {
  font-size: .83rem;
  color: var(--text-muted);
  margin-top: .35rem;
}

.file-chosen {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-sm);
  padding: .55rem .85rem;
  font-size: .88rem;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.file-chosen::before {
  content: "📄";
  font-size: 1rem;
}

/* ── Fields & Inputs ─────────────────────────────────────────── */
.fields-group {
  margin-top: .5rem;
}

.fields-heading {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.field-row {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.field-label {
  font-size: .84rem;
  font-weight: 600;
  color: var(--text);
}

.field-input,
.field-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  font-size: .93rem;
  color: var(--text);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  font-family: inherit;
}

.field-input:focus,
.field-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27,79,191,.15);
}

.field-input::placeholder { color: #A8B4C6; }

.field-select {
  padding: 0;
  height: auto;
  cursor: pointer;
}

.field-select option {
  padding: .4rem .75rem;
}

.field-select option:checked {
  background: var(--primary);
  color: var(--white);
}

.search-input {
  margin-bottom: .5rem;
}

.monospace {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: .87rem;
}

/* ── Sub-field (date/initials group) ─────────────────────────── */
.sub-field {
  margin-top: 1.25rem;
  padding: 1rem 1.125rem;
  background: var(--bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.date-human {
  font-size: .83rem;
  color: var(--text-muted);
  min-height: 1.2em;
  font-style: italic;
}

/* ── Radio Group ─────────────────────────────────────────────── */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .65rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  font-size: .93rem;
  font-weight: 500;
}

.radio-label:hover {
  border-color: var(--primary-light);
  background: #EEF3FC;
}

.radio-label input[type="radio"] {
  accent-color: var(--primary);
  width: 17px;
  height: 17px;
  cursor: pointer;
  flex-shrink: 0;
}

.radio-label:has(input:checked) {
  border-color: var(--primary);
  background: #EEF3FC;
}

/* ── AI Badge ────────────────────────────────────────────────── */
.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: #FFF8E6;
  border: 1px solid #F0D080;
  border-radius: 20px;
  padding: .3rem .85rem;
  font-size: .8rem;
  color: #7A5900;
  font-weight: 600;
  margin-bottom: .85rem;
}

.ai-badge::before { content: "✦"; color: #F5A623; }

/* ── Info Box ────────────────────────────────────────────────── */
.info-box {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-md);
  padding: .9rem 1rem;
  font-size: .9rem;
  color: #1A4A7A;
}

.info-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--primary);
  margin-top: .05em;
}

/* ── Grant Select ────────────────────────────────────────────── */
.grant-select {
  cursor: pointer;
}

/* ── Spacer ──────────────────────────────────────────────────── */
.spacer-md { height: 1.5rem; }

/* ── Review Grid ─────────────────────────────────────────────── */
.review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .65rem 1.5rem;
}

.review-item {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.review-key {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
}

.review-val {
  font-size: .93rem;
  color: var(--text);
  font-weight: 500;
  word-break: break-word;
}

.review-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .55rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background var(--transition), border-color var(--transition),
              box-shadow var(--transition), transform var(--transition);
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary-dark);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(27,79,191,.30);
}

.btn-secondary {
  background: var(--white);
  color: var(--primary);
  border-color: var(--primary);
}

.btn-secondary:hover:not(:disabled) {
  background: #EEF3FC;
}

.btn-success {
  background: var(--success);
  color: var(--white);
  border-color: #0A6A0A;
}

.btn-success:hover:not(:disabled) {
  background: #0A6A0A;
  box-shadow: 0 2px 8px rgba(16,124,16,.30);
}

.btn-onedrive {
  background: #0078d4;
  color: var(--white);
  border-color: #006bbf;
}

.btn-onedrive:hover:not(:disabled) {
  background: #006bbf;
  box-shadow: 0 2px 8px rgba(0,120,212,.30);
}

.btn-onedrive:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.btn-demo {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
  font-size: .8rem;
  margin-top: .75rem;
  width: 100%;
  opacity: .7;
}

.btn-demo:hover {
  background: #f0f4ff;
  color: var(--primary);
  border-color: var(--primary);
  opacity: 1;
}

.btn-lg {
  padding: .7rem 1.6rem;
  font-size: 1rem;
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── Nav Buttons ─────────────────────────────────────────────── */
.nav-buttons {
  display: flex;
  align-items: center;
  padding-top: 1.5rem;
  margin-top: 1.5rem;
  border-top: 1px solid var(--bg);
}

.nav-spacer { flex: 1; }

/* ── Messages ────────────────────────────────────────────────── */
.error-msg {
  font-size: .85rem;
  color: var(--error);
  background: var(--error-bg);
  border: 1px solid #F0C0A8;
  border-radius: var(--radius-sm);
  padding: .5rem .8rem;
  margin-top: .5rem;
}

.success-msg {
  font-size: .85rem;
  color: var(--success);
  background: var(--success-bg);
  border: 1px solid #A4D9A4;
  border-radius: var(--radius-sm);
  padding: .5rem .8rem;
  margin-top: .5rem;
}

/* ── Filename Preview Bar ────────────────────────────────────── */
.filename-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #D8E8F8;
  border-top: 1.5px solid #A8C8E8;
  padding: .6rem 1.5rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  z-index: 200;
  min-height: 48px;
  flex-wrap: wrap;
}

.filename-label {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #1A4A7A;
  white-space: nowrap;
}

.filename-value {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: .84rem;
  color: #0F2D5A;
  word-break: break-all;
}

/* ── Loading Overlay ─────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,31,61,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(3px);
}

.loading-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 2.5rem 3rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #D0DAFA;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Utility ─────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .app-header { padding: 0 1rem; }
  .header-right { display: none; }
  .step-bar-wrap { padding: .6rem 1rem; }
  .main-wrap { padding: 1rem .5rem; }
  .card { padding: 1.5rem 1.25rem 1.25rem; }
  .review-grid { grid-template-columns: 1fr; }
  .review-actions { flex-direction: column; }
  .filename-bar { padding: .5rem 1rem; }
}
