/* Contract Automation – Style */
/* Brand: Aareon Brand Identity Guidelines V.01.1 */

@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:wght@400;500&display=swap');

:root {
  /* Aareon primary palette */
  --color-primary:        #051163; /* Aareon blue */
  --color-primary-light:  #086DFB; /* Bright blue */
  --color-accent:         #FF7F62; /* Coral */
  --color-sand:           #F7F3F0; /* Sand – main background */
  --color-stone:          #EBE3DC; /* Stone – borders / subtle */
  --color-peach:          #FFD8CA; /* Peach – highlight boxes */

  /* Complementary / text */
  --color-headline:       #081326; /* Headline black */
  --color-body-gray:      #384152; /* Body copy gray */
  --color-green:          #50B214;
  --color-green-light:    #B9E99C;

  /* Semantic mappings */
  --color-bg:             var(--color-sand);
  --color-surface:        #ffffff;
  --color-border:         var(--color-stone);
  --color-text:           var(--color-headline);
  --color-muted:          var(--color-body-gray);
  --color-success:        #2F630E;
  --color-success-bg:     var(--color-green-light);
  --color-error:          #a00000;
  --color-error-bg:       #fee2e2;

  --radius: 6px;
  --shadow: 0 1px 4px rgba(5,17,99,.10);
}

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

body {
  /* Aareon fallback: Segoe UI for body copy, as per brand guidelines */
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.4; /* brand: body line-height x1.4 */
}

/* ── Header ─────────────────────────────────────────────────────── */
header {
  background: var(--color-primary); /* Aareon blue */
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 6px rgba(5,17,99,.30);
}
/* Aareon brand: Georgia (fallback) for large titles */
header h1 {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 22px;
  font-weight: 400; /* Canela regular equivalent */
  letter-spacing: .01em;
  line-height: 1.05; /* brand: large title line-height x1.05 */
}
header .subtitle { font-size: 12px; opacity: .80; }

/* ── Layout ─────────────────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px;
}

/* ── Section card ────────────────────────────────────────────────── */
.section-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.section-header {
  background: var(--color-primary); /* Aareon blue */
  color: #fff;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  letter-spacing: .02em;
}
.section-header .toggle-icon { transition: transform .2s; }
.section-header.collapsed .toggle-icon { transform: rotate(-90deg); }

.section-body {
  padding: 16px;
}
.section-body.hidden { display: none; }

/* ── Form grid ───────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px 20px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-group.full-width { grid-column: 1 / -1; }
.form-group.half-width { grid-column: span 2; }

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted); /* body copy gray */
  text-transform: uppercase;
  letter-spacing: .03em;
}
label .required { color: var(--color-accent); margin-left: 2px; } /* Coral */
label .opt { color: var(--color-muted); font-weight: 400; font-size: 11px; }

input[type="text"],
input[type="email"],
input[type="number"],
select,
textarea {
  border: 1px solid var(--color-border); /* Stone */
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--color-text); /* Headline black */
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary-light); /* Bright blue */
  box-shadow: 0 0 0 3px rgba(8,109,251,.15); /* Bright blue glow */
}
input.error, select.error { border-color: var(--color-accent); } /* Coral */
textarea { resize: vertical; min-height: 64px; }

.field-hint {
  font-size: 11px;
  color: var(--color-muted);
  font-style: italic;
}

/* ── Toggle-visible fields ───────────────────────────────────────── */
.conditional { display: none; }
.conditional.visible { display: flex; }
.conditional.payer-block.visible { display: block; }

/* ── Positions table ─────────────────────────────────────────────── */
.positions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.positions-header h3 { font-size: 14px; font-weight: 600; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); color: #fff; }           /* Aareon blue */
.btn-primary:hover:not(:disabled) { background: var(--color-primary-light); } /* Bright blue */
.btn-secondary { background: var(--color-stone); color: var(--color-text); }  /* Stone */
.btn-secondary:hover:not(:disabled) { background: #d5cdc6; }
.btn-danger { background: var(--color-accent); color: #fff; }              /* Coral */
.btn-danger:hover:not(:disabled) { background: #e06040; }
.btn-success { background: var(--color-green); color: #fff; }              /* Green */
.btn-success:hover:not(:disabled) { background: var(--color-success); }

.positions-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

table.positions-table {
  border-collapse: collapse;
  min-width: 100%;
  font-size: 12px;
}
.positions-table th {
  background: var(--color-primary); /* Aareon blue */
  color: #fff;
  padding: 8px 10px;
  white-space: nowrap;
  font-weight: 600;
  text-align: left;
  letter-spacing: .02em;
}
.positions-table td {
  padding: 6px 6px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
.positions-table tr:hover td { background: var(--color-peach); } /* Peach on hover – brand highlight */
.positions-table input, .positions-table select {
  padding: 4px 6px;
  font-size: 12px;
  min-width: 80px;
}
.positions-table .actions { white-space: nowrap; display: flex; gap: 4px; }

/* ── Generate section ────────────────────────────────────────────── */
.generate-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border); /* Stone */
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 32px;
}
/* Aareon brand: Georgia (fallback) for section titles */
.generate-section h2 {
  margin-bottom: 16px;
  font-size: 18px;
  font-family: 'EB Garamond', Georgia, serif;
  font-weight: 400;
  color: var(--color-headline);
  line-height: 1.2;
}
.generate-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.generate-buttons .btn { min-width: 180px; justify-content: center; }

/* ── Spinner ──────────────────────────────────────────────────────── */
.spinner {
  display: none;
  width: 20px; height: 20px;
  border: 3px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto;
}
.spinner.active { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ───────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 9999;
  max-width: 360px;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.success { background: var(--color-green); }        /* Green */
#toast.error { background: var(--color-accent); }         /* Coral */

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .generate-buttons { flex-direction: column; }
}
