/* ==========================================================================
   Meridian — Base CSS Foundation
   Marketing Analytics Platform
   ========================================================================== */

/* --------------------------------------------------------------------------
   Google Fonts — Inter
   -------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ==========================================================================
   Design Tokens
   ========================================================================== */
:root {
  /* --- Brand Colors --- */
  --navy:            #0B1628;
  --amber:           #E8A83E;
  --slate:           #6B7B8D;
  --white:           #F7F8FA;
  --bg:              #F0F2F5;
  --card:            #FFFFFF;
  --border:          #E2E5EA;
  --text:            #1A2332;
  --text-secondary:  #5A6574;
  --danger:          #E85454;
  --success:         #34C77B;

  /* --- Derived / Interactive Colors --- */
  --amber-hover:     #D49A32;
  --amber-light:     rgba(232, 168, 62, 0.10);
  --navy-hover:      #142240;
  --navy-light:      rgba(11, 22, 40, 0.06);
  --danger-light:    rgba(232, 84, 84, 0.10);
  --success-light:   rgba(52, 199, 123, 0.10);
  --focus-ring:      rgba(232, 168, 62, 0.35);

  /* --- Typography --- */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* --- Spacing Scale --- */
  --space-xs:   4px;
  --space-sm:   8px;
  --space-md:   16px;
  --space-lg:   24px;
  --space-xl:   32px;
  --space-2xl:  48px;
  --space-3xl:  64px;

  /* --- Border Radius --- */
  --radius-sm:  4px;
  --radius:     8px;
  --radius-lg:  12px;
  --radius-xl:  16px;

  /* --- Shadows --- */
  --shadow-sm:  0 1px 2px rgba(11, 22, 40, 0.05);
  --shadow:     0 1px 3px rgba(11, 22, 40, 0.07),
                0 1px 2px rgba(11, 22, 40, 0.04);
  --shadow-lg:  0 4px 12px rgba(11, 22, 40, 0.08),
                0 2px 4px rgba(11, 22, 40, 0.04);
  --shadow-xl:  0 12px 32px rgba(11, 22, 40, 0.12),
                0 4px 8px rgba(11, 22, 40, 0.06);

  /* --- Transitions --- */
  --transition:      150ms ease;
  --transition-slow: 300ms ease;

  /* --- Z-Index Scale --- */
  --z-dropdown: 100;
  --z-modal:    200;
  --z-toast:    300;
  --z-cursor:   400;
}

/* ==========================================================================
   CSS Reset
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

ul,
ol {
  list-style: none;
}

a {
  text-decoration: none;
  color: inherit;
}

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

fieldset {
  border: none;
}

/* Remove default button styles */
button {
  background: none;
  border: none;
  cursor: pointer;
}

/* Remove autofill styles */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--card) inset;
  -webkit-text-fill-color: var(--text);
  transition: background-color 5000s ease-in-out 0s;
}

/* ==========================================================================
   Typography
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
  color: var(--navy);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}

h2 {
  font-size: 2.25rem;
  letter-spacing: -0.02em;
}

h3 {
  font-size: 1.75rem;
}

h4 {
  font-size: 1.375rem;
}

h5 {
  font-size: 1.125rem;
  font-weight: 600;
}

h6 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

p:last-child {
  margin-bottom: 0;
}

strong, b {
  font-weight: 600;
}

small {
  font-size: 0.875rem;
}

/* --- Text Utilities --- */
.text-sm {
  font-size: 0.875rem;
  line-height: 1.5;
}

.text-lg {
  font-size: 1.125rem;
  line-height: 1.6;
}

.text-xl {
  font-size: 1.25rem;
  line-height: 1.5;
}

.text-secondary {
  color: var(--text-secondary);
}

.text-amber {
  color: var(--amber);
}

.text-navy {
  color: var(--navy);
}

.text-danger {
  color: var(--danger);
}

.text-success {
  color: var(--success);
}

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

.text-right {
  text-align: right;
}

.font-medium {
  font-weight: 500;
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   Links
   ========================================================================== */
a:not(.btn) {
  color: var(--amber);
  text-decoration: none;
  transition: color var(--transition);
}

a:not(.btn):hover {
  text-decoration: underline;
  color: var(--amber-hover);
}

a:not(.btn):focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color var(--transition),
              color var(--transition),
              border-color var(--transition),
              box-shadow var(--transition),
              transform var(--transition);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
}

.btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

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

.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary — amber bg, navy text */
.btn-primary {
  background-color: var(--amber);
  color: var(--navy);
  border-color: var(--amber);
}

.btn-primary:hover {
  background-color: var(--amber-hover);
  border-color: var(--amber-hover);
  box-shadow: var(--shadow);
}

/* Secondary — navy bg, white text */
.btn-secondary {
  background-color: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}

.btn-secondary:hover {
  background-color: var(--navy-hover);
  border-color: var(--navy-hover);
  box-shadow: var(--shadow);
}

/* Ghost — transparent, navy text, border */
.btn-ghost {
  background-color: transparent;
  color: var(--navy);
  border-color: var(--border);
}

.btn-ghost:hover {
  background-color: var(--navy-light);
  border-color: var(--slate);
}

/* Danger */
.btn-danger {
  background-color: var(--danger);
  color: #FFFFFF;
  border-color: var(--danger);
}

.btn-danger:hover {
  background-color: #D04545;
  border-color: #D04545;
  box-shadow: var(--shadow);
}

/* Button Sizes */
.btn-sm {
  padding: 6px 14px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1.0625rem;
  border-radius: var(--radius-lg);
}

/* Icon-only button */
.btn-icon {
  padding: 10px;
  min-width: 40px;
  min-height: 40px;
}

.btn-icon.btn-sm {
  padding: 6px;
  min-width: 32px;
  min-height: 32px;
}

/* ==========================================================================
   Form Elements
   ========================================================================== */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  margin-bottom: var(--space-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="date"],
textarea,
select,
.form-input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition),
              box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
input[type="search"]:hover,
input[type="url"]:hover,
input[type="tel"]:hover,
input[type="date"]:hover,
textarea:hover,
select:hover,
.form-input:hover {
  border-color: var(--slate);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
textarea:focus,
select:focus,
.form-input:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

input::placeholder,
textarea::placeholder {
  color: var(--slate);
  opacity: 1;
}

input:disabled,
textarea:disabled,
select:disabled {
  background-color: var(--bg);
  color: var(--slate);
  cursor: not-allowed;
  opacity: 0.7;
}

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

/* Select Dropdown */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7B8D' d='M6 8.825a.7.7 0 0 1-.495-.205l-3.5-3.5a.7.7 0 0 1 .99-.99L6 7.135l3.005-3.005a.7.7 0 0 1 .99.99l-3.5 3.5A.7.7 0 0 1 6 8.825Z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px;
  padding-right: 38px;
  cursor: pointer;
}

/* Checkbox & Radio base */
input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--amber);
  cursor: pointer;
}

/* Form validation states */
.form-input.is-invalid,
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
  border-color: var(--danger);
}

.form-input.is-invalid:focus,
input.is-invalid:focus,
select.is-invalid:focus,
textarea.is-invalid:focus {
  box-shadow: 0 0 0 3px var(--danger-light);
}

.form-error {
  display: block;
  margin-top: var(--space-xs);
  font-size: 0.8125rem;
  color: var(--danger);
}

.form-hint {
  display: block;
  margin-top: var(--space-xs);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   Tables
   ========================================================================== */
table {
  font-size: 0.9375rem;
}

thead {
  border-bottom: 2px solid var(--border);
}

thead th {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  text-align: left;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background-color var(--transition);
}

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

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

tbody td {
  padding: 12px 16px;
  vertical-align: middle;
}

/* ==========================================================================
   Layout — Container
   ========================================================================== */
.container {
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
}

@media (max-width: 640px) {
  .container {
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }
}

.container-sm {
  max-width: 720px;
}

.container-lg {
  max-width: 1400px;
}

/* ==========================================================================
   Layout — Flexbox Utilities
   ========================================================================== */
.flex {
  display: flex;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.flex-1 {
  flex: 1;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.items-end {
  align-items: flex-end;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-end {
  justify-content: flex-end;
}

.gap-xs {
  gap: var(--space-xs);
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.gap-lg {
  gap: var(--space-lg);
}

.gap-xl {
  gap: var(--space-xl);
}

/* ==========================================================================
   Layout — Grid Utilities
   ========================================================================== */
.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-lg);
}

@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

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

@media (max-width: 640px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Card
   ========================================================================== */
.card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-lg);
  transition: box-shadow var(--transition-slow);
}

.card:hover {
  box-shadow: var(--shadow);
}

.card-header {
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--navy);
}

.card-body {
  /* Default spacing handled by parent .card padding */
}

.card-footer {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   Spacing Utilities
   ========================================================================== */
.mt-xs  { margin-top: var(--space-xs); }
.mt-sm  { margin-top: var(--space-sm); }
.mt-md  { margin-top: var(--space-md); }
.mt-lg  { margin-top: var(--space-lg); }
.mt-xl  { margin-top: var(--space-xl); }
.mt-2xl { margin-top: var(--space-2xl); }
.mt-3xl { margin-top: var(--space-3xl); }

.mb-xs  { margin-bottom: var(--space-xs); }
.mb-sm  { margin-bottom: var(--space-sm); }
.mb-md  { margin-bottom: var(--space-md); }
.mb-lg  { margin-bottom: var(--space-lg); }
.mb-xl  { margin-bottom: var(--space-xl); }
.mb-2xl { margin-bottom: var(--space-2xl); }
.mb-3xl { margin-bottom: var(--space-3xl); }

.py-sm  { padding-top: var(--space-sm);  padding-bottom: var(--space-sm); }
.py-md  { padding-top: var(--space-md);  padding-bottom: var(--space-md); }
.py-lg  { padding-top: var(--space-lg);  padding-bottom: var(--space-lg); }
.py-xl  { padding-top: var(--space-xl);  padding-bottom: var(--space-xl); }
.py-2xl { padding-top: var(--space-2xl); padding-bottom: var(--space-2xl); }
.py-3xl { padding-top: var(--space-3xl); padding-bottom: var(--space-3xl); }

.px-sm  { padding-left: var(--space-sm);  padding-right: var(--space-sm); }
.px-md  { padding-left: var(--space-md);  padding-right: var(--space-md); }
.px-lg  { padding-left: var(--space-lg);  padding-right: var(--space-lg); }
.px-xl  { padding-left: var(--space-xl);  padding-right: var(--space-xl); }

/* ==========================================================================
   Display & Visibility Utilities
   ========================================================================== */
.hidden {
  display: none;
}

.block {
  display: block;
}

.inline-block {
  display: inline-block;
}

.relative {
  position: relative;
}

.absolute {
  position: absolute;
}

.sticky {
  position: sticky;
  top: 0;
}

.overflow-hidden {
  overflow: hidden;
}

.overflow-auto {
  overflow: auto;
}

.w-full {
  width: 100%;
}

/* ==========================================================================
   Badges & Tags
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.6;
  border-radius: 100px;
  white-space: nowrap;
}

.badge-amber {
  background-color: var(--amber-light);
  color: #A67520;
}

.badge-success {
  background-color: var(--success-light);
  color: #1F8A4E;
}

.badge-danger {
  background-color: var(--danger-light);
  color: #C23434;
}

.badge-navy {
  background-color: var(--navy-light);
  color: var(--navy);
}

/* ==========================================================================
   Dividers
   ========================================================================== */
hr,
.divider {
  border: none;
  height: 1px;
  background-color: var(--border);
  margin: var(--space-lg) 0;
}

/* ==========================================================================
   Scrollbar Styling
   ========================================================================== */

/* WebKit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--slate);
  border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--navy);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--slate) transparent;
}

/* ==========================================================================
   Selection
   ========================================================================== */
::selection {
  background-color: var(--amber-light);
  color: var(--navy);
}

/* ==========================================================================
   Focus Visible — Global
   ========================================================================== */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ==========================================================================
   Responsive Visibility
   ========================================================================== */
@media (max-width: 640px) {
  .hide-mobile {
    display: none !important;
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .hide-tablet {
    display: none !important;
  }
}

@media (min-width: 1025px) {
  .hide-desktop {
    display: none !important;
  }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Print
   ========================================================================== */
@media print {
  body {
    background: #FFFFFF;
    color: #000000;
  }

  .card {
    box-shadow: none;
    border: 1px solid #CCCCCC;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666666;
  }
}
