/* AZULEJO Design System - CSS Variables */

:root {
  /* Brand Colors - Primary Blues */
  --brand-primary: #5383aa;      /* Off Blue - Primary brand color */
  --brand-secondary: #82a2c1;   /* Old Faithful - Secondary/hover */
  --brand-accent: #a8d5f2;       /* Sky Breeze - Vibrant accent */
  --brand-light: #d4ebf7;        /* Cloud Light - Soft background */
  
  /* Legacy brand scale (mapped for compatibility) */
  --brand-50: #d4ebf7;   /* Cloud Light */
  --brand-100: #d4ebf7;  /* Cloud Light */
  --brand-200: #a8d5f2;  /* Sky Breeze */
  --brand-300: #a8d5f2;  /* Sky Breeze */
  --brand-400: #82a2c1;  /* Old Faithful */
  --brand-500: #5383aa;  /* Off Blue */
  --brand-600: #5383aa;  /* Off Blue */
  --brand-700: #3d5f7a;  /* Darkened Off Blue */
  --brand-800: #2a4154;  /* Darker */
  --brand-900: #1a2833;  /* Darkest */

  /* Semantic Colors */
  --success: #4caf50;           /* Primary Success */
  --success-light: #81c784;      /* Success Light */
  --success-bg: #e8f5e9;        /* Success Background */
  
  --warning: #ff9800;           /* Primary Warning */
  --warning-light: #ffb74d;     /* Warning Light */
  --warning-bg: #fff3e0;        /* Warning Background */
  
  --danger: #f44336;            /* Primary Danger */
  --danger-light: #e57373;      /* Danger Light */
  --danger-bg: #ffebee;         /* Danger Background */
  
  --info: #a8d5f2;              /* Sky Breeze */
  --info-secondary: #82a2c1;   /* Old Faithful */
  --info-bg: #d4ebf7;           /* Cloud Light */

  /* Neutrals */
  --text-primary: #545253;      /* Black Space - Primary text */
  --text-secondary: #807976;    /* Grey Suit - Secondary text */
  --text-tertiary: #9d9899;     /* Jet Grey - Tertiary/disabled */
  --border-default: #bdc2cc;    /* Grey Dawn - Borders */
  
  /* Legacy gray scale (mapped for compatibility) */
  --gray-50: #f5f6f7;          /* Lightest */
  --gray-100: #e8eaed;         /* Very light */
  --gray-200: #bdc2cc;         /* Grey Dawn */
  --gray-300: #bdc2cc;         /* Grey Dawn */
  --gray-400: #9d9899;         /* Jet Grey */
  --gray-500: #9d9899;         /* Jet Grey */
  --gray-600: #807976;         /* Grey Suit */
  --gray-700: #807976;         /* Grey Suit */
  --gray-800: #545253;         /* Black Space */
  --gray-900: #545253;         /* Black Space */

  /* Spacing */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */
  --space-16: 4rem;    /* 64px */

  /* Typography */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Manrope', var(--font-primary);

  /* Type Scale */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.25rem;    /* 20px */
  --text-xl: 1.5rem;     /* 24px */
  --text-2xl: 1.75rem;   /* 28px */
  --text-3xl: 2.25rem;   /* 36px */

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 999px;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(84, 82, 83, 0.1);
  --shadow-md: 0 4px 12px rgba(84, 82, 83, 0.15);
  --shadow-lg: 0 8px 24px rgba(84, 82, 83, 0.2);
  --shadow-focus: 0 0 0 3px rgba(83, 131, 170, 0.3);

  /* Max Width */
  --max-width: 1280px;

  /* Compatibility aliases for existing HTML styles */
  /* Spacing aliases */
  --spacing-xs: var(--space-1);
  --spacing-s: var(--space-2);
  --spacing-m: var(--space-3);
  --spacing-l: var(--space-4);
  --spacing-xl: var(--space-6);
  --spacing-xxl: var(--space-8);
  --spacing-xxxl: var(--space-12);

  /* Color aliases */
  --azulejo-blue: var(--brand-primary);
  --lisbon-sky: var(--brand-light);
  --ceramic-white: #FFFFFF;
  --tile-cream: var(--gray-50);
  --atlantic-deep-blue: var(--brand-800);

  /* Neutral aliases (old slate names) */
  --slate-900: var(--gray-900);
  --slate-700: var(--gray-700);
  --slate-500: var(--gray-500);
  --slate-300: var(--gray-300);
  --slate-100: var(--gray-100);

  /* Semantic color aliases */
  --success-green: var(--success);
  --success-green-bg: var(--success-bg);
  --warning-amber: var(--warning);
  --warning-amber-text: var(--warning);
  --warning-amber-bg: var(--warning-bg);
  --error-red: var(--danger);
  --error-red-bg: var(--danger-bg);
  --info-blue: var(--info);

  /* Border aliases */
  --border-width: 1px;
  --border-color: var(--border-default);

  /* Radius aliases */
  --radius-small: var(--radius-sm);
  --radius-medium: var(--radius-md);
  --radius-large: var(--radius-lg);

  /* Shadow aliases */
  --shadow-small: var(--shadow-sm);
  --shadow-medium: var(--shadow-md);
}

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

body {
  font-family: var(--font-primary);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: #FFFFFF;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p {
  margin-bottom: var(--space-4);
}

/* Links */
a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--brand-secondary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
  font-weight: 500;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-primary);
  gap: var(--space-2);
}

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

.btn-primary:hover {
  background-color: var(--brand-secondary);
}

.btn-secondary {
  background-color: var(--brand-accent);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}

.btn-secondary:hover {
  background-color: var(--brand-secondary);
  color: white;
}

.btn-tertiary {
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  padding: var(--space-2) var(--space-4);
}

.btn-tertiary:hover {
  background-color: var(--brand-light);
  border-color: var(--brand-secondary);
}

.btn-ghost {
  background-color: transparent;
  color: var(--brand-primary);
  border: none;
  padding: var(--space-2) var(--space-4);
}

.btn-ghost:hover {
  background-color: var(--brand-light);
  color: var(--brand-secondary);
}

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

.btn-large {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-lg);
}

.btn-small {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}

/* Cards */
.card {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-default);
}

.card-title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-4);
  color: var(--text-primary);
}

.card-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

/* Inputs */
.input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-primary);
  transition: border-color 0.2s;
  color: var(--text-primary);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-primary);
  transition: border-color 0.2s;
  color: var(--text-primary);
  background-color: white;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-focus);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

.input::placeholder {
  color: var(--text-tertiary);
}

.input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-focus);
}

.input-group {
  margin-bottom: var(--space-4);
}

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.input-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.input-help {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

textarea.input {
  min-height: 100px;
  resize: vertical;
}

select.input {
  cursor: pointer;
}

/* Chips & Badges */
.chip {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  gap: var(--space-1);
}

.chip-confidence-high {
  background-color: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-light);
}

.chip-confidence-medium {
  background-color: var(--info-bg);
  color: var(--brand-primary);
  border: 1px solid var(--brand-accent);
}

.chip-confidence-low {
  background-color: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-light);
}

.chip-freshness {
  background-color: var(--gray-100);
  color: var(--text-secondary);
}

.chip-plan {
  background-color: var(--brand-light);
  color: var(--brand-primary);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
}

.badge-success {
  background-color: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background-color: var(--warning-bg);
  color: var(--warning);
}

.badge-error {
  background-color: var(--danger-bg);
  color: var(--danger);
}

.badge-info {
  background-color: var(--info-bg);
  color: var(--brand-primary);
}

.badge-neutral {
  background-color: var(--gray-100);
  color: var(--text-secondary);
}

/* Layout */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.container-wide {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.section {
  padding: var(--space-16) 0;
}

.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* Header */
.header {
  background: white;
  border-bottom: 1px solid var(--border-default);
  padding: var(--space-4) 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar {
  background: white;
  border-bottom: 1px solid var(--border-default);
  padding: var(--space-4) var(--space-6);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  font-size: var(--text-xl);
  color: var(--brand-primary);
  text-decoration: none;
  flex-shrink: 0;
}

.navbar-brand img {
  height: 32px;
  width: auto;
  display: block;
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  margin-left: var(--space-8);
  flex: 1;
  justify-content: center;
}

.nav-link {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: var(--text-sm);
  text-decoration: none;
  transition: all 0.2s;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
}

.nav-link:hover {
  color: var(--brand-primary);
  background-color: var(--brand-light);
}

.nav-link.active {
  color: var(--brand-primary);
  background-color: var(--brand-light);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-shrink: 0;
  margin-left: var(--space-4);
}

/* Stepper */
.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-8);
}

.stepper-step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.stepper-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-sm);
}

.stepper-step.active .stepper-number {
  background-color: var(--brand-primary);
  color: white;
}

.stepper-step.completed .stepper-number {
  background-color: var(--success);
  color: white;
}

.stepper-step.inactive .stepper-number {
  background-color: var(--border-default);
  color: var(--text-tertiary);
}

.stepper-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.stepper-step.active .stepper-label {
  color: var(--brand-primary);
  font-weight: 500;
}

.stepper-connector {
  width: 60px;
  height: 2px;
  background-color: var(--border-default);
  margin: 0 var(--space-2);
}

.stepper-step.completed + .stepper-connector {
  background-color: var(--success);
}

/* Azulejo Pattern */
.azulejo-pattern {
  background-image: 
    repeating-linear-gradient(0deg, transparent, transparent 20px, rgba(83, 131, 170, 0.05) 20px, rgba(83, 131, 170, 0.05) 21px),
    repeating-linear-gradient(90deg, transparent, transparent 20px, rgba(83, 131, 170, 0.05) 20px, rgba(83, 131, 170, 0.05) 21px);
  background-size: 60px 60px;
}

/* Confidence Meter */
.confidence-meter {
  width: 100%;
  height: 8px;
  background-color: var(--border-default);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: var(--space-2) 0;
}

.confidence-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.3s;
}

.confidence-fill.high {
  background-color: var(--success);
}

.confidence-fill.medium {
  background-color: var(--brand-primary);
}

.confidence-fill.low {
  background-color: var(--warning);
}

.confidence-fill.critical {
  background-color: var(--danger);
}

/* Offer Bands */
.offer-band {
  text-align: center;
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  background: var(--gray-50);
  border: 2px solid var(--border-default);
}

.offer-band.target {
  background: linear-gradient(135deg, var(--brand-light) 0%, white 100%);
  border-color: var(--brand-accent);
}

.offer-value {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--text-primary);
  font-feature-settings: "tnum";
  margin-bottom: var(--space-2);
}

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

.offer-perm2 {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

/* Source Footnote */
.source-footnote {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-4);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-default);
}

/* Table */
.table {
  width: 100%;
  border-collapse: collapse;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

.table th,
table th {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
  background-color: var(--gray-50);
}

thead {
  background-color: var(--gray-50);
}

thead th {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

tbody tr {
  transition: background-color 0.2s;
}

tbody tr:hover {
  background-color: var(--brand-light);
}

tbody tr:last-child td {
  border-bottom: none;
}

.table td,
table td {
  font-size: var(--text-sm);
}

.table td.numeric {
  text-align: right;
  font-feature-settings: "tnum";
}

/* Tabs */
.tabs {
  display: flex;
  gap: var(--space-4);
  border-bottom: 1px solid var(--border-default);
  margin-bottom: var(--space-8);
}

.tab {
  padding: var(--space-3) var(--space-4);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-family: var(--font-primary);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--brand-primary);
}

.tab.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-default);
  transition: 0.3s;
  border-radius: var(--radius-full);
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--brand-primary);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* Select */
.select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background-color: white;
  font-family: var(--font-primary);
  cursor: pointer;
  color: var(--text-primary);
}

select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background-color: white;
  font-family: var(--font-primary);
  cursor: pointer;
  color: var(--text-primary);
}

.select:focus,
select:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-focus);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-8);
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: var(--space-4);
  opacity: 0.3;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-small { font-size: var(--text-sm); color: var(--text-secondary); }
.text-xs { font-size: var(--text-xs); color: var(--text-tertiary); }

.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.flex { display: flex; }
.flex-column { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Slider input */
input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--border-default);
  outline: none;
  -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand-primary);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand-primary);
  cursor: pointer;
  border: none;
}

.slider {
  position: relative;
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--border-default);
  outline: none;
  -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand-primary);
  cursor: pointer;
}

.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand-primary);
  cursor: pointer;
  border: none;
}

/* Checkbox and Radio */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  height: auto;
  margin-right: var(--space-2);
  cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
  
  .stepper {
    flex-wrap: wrap;
  }
  
  .stepper-connector {
    display: none;
  }
  
  h1 { font-size: var(--text-2xl); }
  h2 { font-size: var(--text-xl); }
  
  .navbar-nav {
    display: none;
  }
  
  .container {
    padding: 0 var(--space-4);
  }
}
