/* =========================================================
   MCCIA Applied AI Studio — global theme
   Tokens + base + reusable components
   ========================================================= */

:root {
  /* Colors */
  --c-primary: #003F8A;
  --c-primary-2: #0056B3;
  --c-green: #10B981;
  --c-green-text: #059669;
  --c-red: #EF4444;
  --c-purple: #8B5CF6;
  --c-text: #0F172A;
  --c-muted: #475569;
  --c-subtle: #64748B;
  --c-white: #FFFFFF;
  --c-bg-alt: #F8FAFC;
  --c-dark: #060913;

  --bg-page: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 100%);
  --bg-card: rgba(255, 255, 255, 0.7);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-nav: rgba(255, 255, 255, 0.97);
  --bg-ghost: rgba(255, 255, 255, 0.6);
  --bg-backdrop: rgba(15, 23, 42, 0.4);

  --border: rgba(226, 232, 240, 0.85);
  --border-hover: rgba(0, 63, 138, 0.25);
  --border-active: rgba(0, 63, 138, 0.3);

  --tint-blue-bg: rgba(0, 63, 138, 0.06);
  --tint-blue-bg-soft: rgba(0, 63, 138, 0.02);
  --tint-blue-border: rgba(0, 63, 138, 0.14);
  --tint-green-bg: rgba(16, 185, 129, 0.07);
  --tint-green-border: rgba(16, 185, 129, 0.14);
  --tint-red-bg: rgba(239, 68, 68, 0.08);
  --tint-red-border: rgba(239, 68, 68, 0.22);

  --grad-primary: linear-gradient(135deg, #003F8A 0%, #0056B3 100%);

  /* Radius */
  --r-sm: 8px;
  --r-btn: 10px;
  --r-md: 12px;
  --r-lg: 20px;
  --r-pill: 99px;

  /* Shadows */
  --sh-card: 0 15px 40px -10px rgba(0, 63, 138, 0.04);
  --sh-card-hover: 0 20px 40px rgba(0, 63, 138, 0.08);
  --sh-btn: 0 4px 15px rgba(0, 63, 138, 0.15);
  --sh-btn-hover: 0 8px 25px rgba(0, 63, 138, 0.25);
  --ring: 0 0 0 3px rgba(0, 63, 138, 0.1);
  --ring-red: 0 0 0 3px rgba(239, 68, 68, 0.12);

  /* Typography */
  --f-head: "Bricolage Grotesque", "Outfit", system-ui, sans-serif;
  --f-body: "Outfit", Inter, system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t: 0.3s var(--ease);
  --t-fast: 0.2s var(--ease);

  /* Layout */
  --max-w: 1140px;
  --gutter: clamp(16px, 4vw, 48px);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--f-body);
  color: var(--c-text);
  background: var(--c-white);
  background-image: var(--bg-page);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--f-head);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--c-text);
}
h1 { letter-spacing: -0.03em; line-height: 1.1; }

.page-title { font-size: clamp(2rem, 5vw, 4.2rem); }
.section-title { font-size: clamp(1.9rem, 3.5vw, 2.5rem); }
.text-muted { color: var(--c-muted); }
.text-gradient {
  background: var(--grad-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.label-sm {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--c-subtle);
}

/* ---------- Card (glass) ---------- */
.card {
  background: var(--bg-card);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-card);
  padding: 2.2rem;
  transition: transform var(--t), background var(--t), border-color var(--t), box-shadow var(--t);
}
.card--interactive:hover {
  transform: translateY(-5px);
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  box-shadow: var(--sh-card-hover);
}
/* Static card (e.g. form): gentle hover without lift so fields don't move under the cursor */
.card--static:hover,
.card--static:focus-within {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  box-shadow: var(--sh-card-hover);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  min-height: 46px;
  font-family: var(--f-body);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--r-btn);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none; /* also used on <a> links */
  transition: transform var(--t), box-shadow var(--t), border-color var(--t), color var(--t), background var(--t);
}
.btn:focus-visible { outline: none; box-shadow: var(--ring), var(--sh-btn); }
.btn svg { width: 16px; height: 16px; transition: transform var(--t); }
.btn:disabled { opacity: 0.65; cursor: wait; transform: none !important; }

.btn-primary {
  background: var(--grad-primary);
  color: var(--c-white);
  box-shadow: var(--sh-btn);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--sh-btn-hover); }
.btn-primary:hover svg { transform: translateX(3px); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: var(--bg-ghost);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-color: var(--border);
  color: var(--c-muted);
}
.btn-ghost:hover { border-color: var(--c-primary); color: var(--c-primary); transform: translateY(-2px); }

.btn-danger {
  background: var(--tint-red-bg);
  border-color: var(--tint-red-border);
  color: var(--c-red);
}
.btn-danger:hover { transform: translateY(-2px); border-color: var(--c-red); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--r-pill);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--tint-blue-bg);
  border: 1px solid var(--tint-blue-border);
  color: var(--c-primary);
}
.badge--green { background: var(--tint-green-bg); border-color: var(--tint-green-border); color: var(--c-green-text); }
.badge--red { background: var(--tint-red-bg); border-color: var(--tint-red-border); color: var(--c-red); }
.badge-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px var(--tint-green-border);
  animation: pulse 2s var(--ease) infinite;
}

/* ---------- Icon tile ---------- */
.icon-tile {
  width: 44px; height: 44px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-btn);
  background: var(--tint-blue-bg);
  border: 1px solid var(--tint-blue-border);
  color: var(--c-primary);
  transition: transform var(--t);
}
.icon-tile svg { width: 18px; height: 18px; }
.icon-tile--green { background: var(--tint-green-bg); border-color: var(--tint-green-border); color: var(--c-green-text); }
.icon-tile--red { background: var(--tint-red-bg); border-color: var(--tint-red-border); color: var(--c-red); }
.icon-tile:hover, .card:hover .icon-tile { transform: scale(1.1) rotate(5deg); }

/* ---------- Inputs ---------- */
.input {
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 1rem;
  font-family: var(--f-body);
  font-size: max(16px, 0.95rem); /* 16px+ prevents iOS zoom on focus */
  color: var(--c-text);
  background: var(--c-white);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder { color: var(--c-subtle); opacity: 0.75; }
.input:hover { border-color: var(--border-hover); }
.input:focus { outline: none; border-color: var(--c-primary); box-shadow: var(--ring); }
.input.is-invalid, .is-invalid .input { border-color: var(--c-red); }
.is-invalid .input:focus { box-shadow: var(--ring-red); }

select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.75rem;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
}
select.input:invalid { color: var(--c-subtle); }
select.input option { color: var(--c-text); }

/* ---------- Table ---------- */
.table-wrap {
  background: var(--c-white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; text-align: left; }
.table th, .table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.table tr:last-child th, .table tr:last-child td { border-bottom: none; }
.table th {
  background: var(--c-bg-alt);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-subtle);
}
.table td { color: var(--c-text); font-weight: 500; word-break: break-word; }
.table tr { transition: background var(--t-fast); }
.table tr:hover td { background: var(--tint-blue-bg-soft); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--bg-backdrop);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.modal-backdrop.show { display: flex; animation: fade-in 0.3s var(--ease); }
.modal-card {
  width: 100%;
  max-width: 500px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--bg-card-hover);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-card-hover);
  padding: 2.2rem;
}
.modal-backdrop.show .modal-card { animation: rise-in 0.4s var(--ease); }

/* ---------- Alert / toast ---------- */
.alert {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  border-radius: var(--r-md);
  border: 1px solid var(--tint-blue-border);
  background: var(--tint-blue-bg);
  color: var(--c-primary);
  font-size: 0.9rem;
  font-weight: 600;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert--red { background: var(--tint-red-bg); border-color: var(--tint-red-border); color: var(--c-red); }
.alert--green { background: var(--tint-green-bg); border-color: var(--tint-green-border); color: var(--c-green-text); }

/* ---------- Motion ---------- */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse { 50% { box-shadow: 0 0 0 6px transparent; } }

.reveal {
  opacity: 0;
  animation: rise-in 0.6s var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * 80ms);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; }
}

@media (max-width: 600px) {
  .card, .modal-card { padding: 1.5rem; }
}
