/*
  Starken design system tokens + component classes for Fat.IA.
  Extracted (screens/sections, Button, Input only) from starken-design-system.json.
  Served from /public so Vite's dev middleware and prod build both expose it at /index.css
  (a bare-root file next to index.html is NOT copied/served by Vite — must live in public/).
*/

:root {
  /* Brand */
  --color-primary: #005E57;
  --color-primary-hover: #004E49;
  --color-primary-medium: #339690;
  --color-primary-light: #E5EFEF;

  /* Backgrounds */
  --bg-app: #F4F7F6;
  --bg-card: #FFFFFF;
  --bg-card-blue: #F1F6FA;
  --bg-sidebar: #FFFFFF;
  --bg-header: #FFFFFF;
  --bg-login: #EFF4F4;
  --bg-surface: #E7E7E7;
  --bg-surface-light: #F8F8F8;
  --bg-surface-blueish: #FAFBFD;
  --bg-green-light: #EDF7F4;
  --bg-green-medium: #C8E2D8;
  --bg-lavender: #FAF5FF;

  /* Text */
  --text-primary: #2D1E2F;
  --text-body: #364656;
  --text-secondary: #5E7389;
  --text-muted: #666666;
  --text-dark: #151A1F;
  --text-label: #333333;

  /* Borders */
  --border-default: #D3DDE7;
  --border-light: #E5E7EB;
  --border-focus: #005E57;

  /* Feedback */
  --success: #49DF6A;
  --success-bg: #E6FFDD;
  --success-text: #025B15;
  --error: #FE3232;
  --error-bg: #FFDCDA;
  --error-text: #940000;
  --warning: #EFB92F;
  --warning-bg: #FFEEE0;
  --warning-text: #5A2B08;

  /* Radius */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-card: 16px;
  --radius-pill: 999px;
  --radius-button-input: 8px;

  /* Shadows */
  --shadow-card: 0px 1px 3px rgba(0,0,0,0.05), 0px 1px 2px rgba(0,0,0,0.03);
  --shadow-dropdown: 0 10px 25px rgba(0,0,0,0.08);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Typography */
  --font-sans: 'Inter', 'Roboto', 'Helvetica Neue', sans-serif;
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 16px;
  --text-lg: 20px;
  --text-xl: 24px;
  --text-h1: 30px;
  --text-h2: 24px;
  --text-subtitle: 18px;
  --text-label-size: 12px;
}

html.dark {
  --color-primary-light: #0D2724;

  --bg-app: #090E0C;
  --bg-card: #121815;
  --bg-card-blue: #141D26;
  --bg-sidebar: #101512;
  --bg-header: #101512;
  --bg-login: #0D1311;
  --bg-surface: #1E2824;
  --bg-surface-light: #16201D;
  --bg-surface-blueish: #151F21;
  --bg-green-light: #0D221D;
  --bg-green-medium: #153E32;
  --bg-lavender: #181226;

  --text-primary: #ECEFF1;
  --text-body: #CFD8DC;
  --text-secondary: #90A4AE;
  --text-muted: #78909C;
  --text-dark: #FFFFFF;
  --text-label: #B0BEC5;

  --border-default: #2E3E37;
  --border-light: #202F28;
  --border-focus: #339690;

  --shadow-card: 0px 1px 3px rgba(0,0,0,0.4), 0px 1px 2px rgba(0,0,0,0.3);
  --shadow-dropdown: 0 10px 25px rgba(0,0,0,0.5);
}

/* ============ Button ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-button-input);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1), color 150ms cubic-bezier(0.4, 0, 0.2, 1), transform 150ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 150ms cubic-bezier(0.4, 0, 0.2, 1), border-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  font-family: var(--font-sans);
  outline: none;
  user-select: none;
  white-space: nowrap;
}

.btn-primary { background-color: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background-color: var(--color-primary-hover); transform: translateY(-1px); box-shadow: 0px 4px 8px rgba(0, 94, 87, 0.15); }

.btn-secondary { background-color: var(--color-primary-light); color: var(--color-primary); }
.btn-secondary:hover:not(:disabled) { background-color: var(--bg-green-medium); transform: translateY(-1px); }

.btn-ghost { background-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background-color: var(--bg-surface-light); color: var(--text-primary); }

.btn-danger { background-color: var(--error-bg); color: var(--error-text); }
.btn-danger:hover:not(:disabled) { background-color: #ffc8c5; color: var(--error); transform: translateY(-1px); }

.btn-sm { padding: 6px 12px; font-size: var(--text-xs); }
.btn-md { padding: 8px 16px; font-size: var(--text-sm); }
.btn-lg { padding: 10px 20px; font-size: var(--text-base); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:hover { transform: none; box-shadow: none; }

/* Loading: hide the label/icons (not just dim them) and overlay a centered spinner —
   matches the real Starken Button exactly, rather than swapping the leading icon. */
.btn-loading { position: relative; color: transparent !important; pointer-events: none; }

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-bottom-color: transparent;
  border-radius: 50%;
  animation: btn-spin 1s linear infinite;
  position: absolute;
  left: calc(50% - 8px);
  top: calc(50% - 8px);
}

.btn-primary.btn-loading .btn-spinner { color: #fff; }
.btn-secondary.btn-loading .btn-spinner,
.btn-ghost.btn-loading .btn-spinner { color: var(--color-primary); }
.btn-danger.btn-loading .btn-spinner { color: var(--error-text); }

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

/* ============ Input ============ */

.input-group { display: flex; flex-direction: column; gap: 6px; width: 100%; }

.input-label { font-size: var(--text-label-size); font-weight: 500; color: var(--text-label); }

.input-wrapper { position: relative; display: flex; align-items: center; width: 100%; }

.input-field {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-button-input);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: var(--bg-card);
  transition: border-color 150ms ease, box-shadow 150ms ease;
  outline: none;
  line-height: 1.5;
}

input.input-field, select.input-field { height: 42px; }
textarea.input-field { height: auto; resize: vertical; }

.input-field:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(0, 94, 87, 0.1); }

.input-field-error, .input-field-error:focus { border-color: var(--error); box-shadow: 0 0 0 3px rgba(254, 50, 50, 0.1); }

.input-field:disabled { background-color: var(--bg-surface-light); color: var(--text-muted); cursor: not-allowed; }

/* Real source uses appearance:none + a hand-drawn SVG chevron on every select.input-field,
   instead of relying on the browser's native dropdown arrow. */
select.input-field {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'><path d='M4 6l4 4 4-4' stroke='%23666666' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.input-field-has-icon-left { padding-left: 38px; }
.input-field-has-icon-right { padding-right: 38px; }

.input-icon-left, .input-icon-right {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  pointer-events: none;
}
.input-icon-left { left: 12px; }
.input-icon-right { right: 12px; }

.input-error-text { font-size: var(--text-xs); color: var(--error); font-weight: 500; }
.input-helper { font-size: var(--text-xs); color: var(--text-muted); }

/* ============ Dropdown ============ */

.starken-dropdown-container { position: relative; display: inline-block; }

.starken-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  width: 280px;
  max-height: 240px;
  overflow-y: auto;
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-dropdown);
  box-shadow: var(--shadow-dropdown);
  z-index: 100;
  padding: 6px 0;
  transform-origin: top left;
  animation: starken-dropdown-scale-in 150ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes starken-dropdown-scale-in {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.starken-dropdown-item {
  padding: 10px 14px;
  font-size: var(--text-base);
  color: var(--text-body);
  cursor: pointer;
  transition: background-color 100ms ease, color 100ms ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.starken-dropdown-item:hover { background-color: var(--bg-surface-light); color: var(--text-primary); }

/* ============ Section (grouped field boxes, e.g. "Coberturas", "Modo Taxa Básica") ============ */
/* Ported from the real source's proposal_editor.section_title — used for a mini-section
   header grouping several fields, distinct from a single field's .input-label. */
.section-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.section-description {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  margin: 0;
  line-height: 1.4;
}

/* ============ App sidebar layout ============ */
/* Ported from Starken_v3's DesignSystemPage .ds-layout/.ds-sidebar/.ds-nav-item/.ds-content
   (the only real sidebar pattern in that source repo) — renamed for Fat.IA and reused as
   the app's primary navigation, replacing the old top header entirely. */

.app-layout {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-app);
}

.app-sidebar {
  width: 300px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  padding: 32px 24px;
  overflow-y: auto;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.app-content {
  margin-left: 300px;
  flex: 1;
  min-width: 0;
  max-width: 1300px;
  padding: 48px 64px;
}

.app-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 32px 0 0;
  padding: 0;
}

.app-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 500;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 150ms ease;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.app-nav-item:hover:not(:disabled) {
  background-color: var(--bg-surface-light);
  color: var(--text-primary);
}
.app-nav-item.active {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}
.app-nav-item:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 1024px) {
  .app-sidebar { width: 240px; }
  .app-content { margin-left: 240px; padding: 32px 40px; }
}

@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .app-sidebar {
    position: relative;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-light);
    padding: 24px;
  }
  .app-content { margin-left: 0; padding: 24px; }
}

/* Hide native number spinner, matches design system's number_spinner_hidden rule */
.input-field[type="number"]::-webkit-outer-spin-button,
.input-field[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.input-field[type="number"] { -moz-appearance: textfield; }

/* ============ Card ============ */

.starken-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-card);
  padding: var(--space-md);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-light);
  transition: box-shadow 150ms ease;
}
.starken-card-blue { background-color: var(--bg-card-blue); border-color: rgba(0, 94, 87, 0.05); }
.starken-card-green { background-color: var(--bg-green-light); border-color: rgba(0, 94, 87, 0.08); }

/* ============ Auth screen layout ============ */

.auth-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg-login);
  padding: var(--space-lg);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.auth-logo { display: flex; justify-content: center; }

.auth-header { text-align: center; display: flex; flex-direction: column; gap: 6px; }

.auth-title { font-size: 22px; font-weight: 700; color: var(--text-primary); margin: 0; line-height: 1.3; }

.auth-subtitle { font-size: 14px; color: var(--text-secondary); margin: 0; }

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.auth-error {
  font-size: 13px;
  color: var(--error-text);
  background: var(--error-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.auth-footer { text-align: center; }

.auth-link { font-size: 14px; color: var(--color-primary); text-decoration: none; font-weight: 500; }
.auth-link:hover { text-decoration: underline; }

@media (max-width: 480px) {
  .auth-card { padding: 28px 20px; }
}

/* ============ Toast ============ */
/* Ported from Starken_v3's real Toast.tsx + components.css -- ToastProvider/useToast pattern,
   used for import/export feedback (percentage progress + success/warning/error result). */

.starken-toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.starken-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
  box-shadow: var(--shadow-dropdown);
  min-width: 320px;
  max-width: 420px;
  border-left: 4px solid var(--color-primary);
  position: relative;
  overflow: hidden;
  animation: starken-toast-slide-in 250ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes starken-toast-slide-in {
  from { transform: translateY(20px) scale(0.9); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes starken-toast-shrink-width {
  from { width: 100%; }
  to { width: 0%; }
}

.starken-toast-success { border-left-color: var(--success); }
.starken-toast-success .starken-toast-icon { color: var(--success); }

.starken-toast-error { border-left-color: var(--error); }
.starken-toast-error .starken-toast-icon { color: var(--error); }

.starken-toast-warning { border-left-color: var(--warning); }
.starken-toast-warning .starken-toast-icon { color: var(--warning); }

.starken-toast-info { border-left-color: var(--color-primary-medium); }
.starken-toast-info .starken-toast-icon { color: var(--color-primary-medium); }

.starken-toast-content { flex: 1; }
.starken-toast-title { font-weight: 600; font-size: var(--text-sm); color: var(--text-primary); margin-bottom: 2px; }
.starken-toast-message { font-size: var(--text-xs); color: var(--text-body); }

.starken-toast-close {
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  transition: background-color 100ms ease;
}
.starken-toast-close:hover { background-color: var(--bg-surface-light); }

.starken-toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background-color: currentColor;
  opacity: 0.2;
}

/* ============ Import progress bar ============ */
.import-progress-track {
  width: 100%;
  height: 6px;
  background-color: var(--bg-surface-light);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.import-progress-fill {
  height: 100%;
  background-color: var(--color-primary);
  transition: width 150ms ease;
}
