/*
 * shared.css - Common design tokens and base styles for all PediCalc pages
 * Referenced by: index.html, calc.html, mlad.html
 */

/* =========================================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ========================================================= */
:root {
  /* Primary Accent: Emerald */
  --primary-accent: #059669;
  --primary-accent-dark: #047857;
  --primary-accent-light: rgba(5, 150, 105, 0.15);

  /* Backgrounds */
  --bg-primary: #f5f5f4;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;

  /* Text */
  --text-primary: #292524;
  --text-secondary: #57534e;
  --text-tertiary: #a8a29e;

  /* Borders & Inputs */
  --border-color: #e7e5e4;
  --input-bg: #f3f2ed;

  /* Shadows */
  --shadow: 0 1px 3px 0 rgba(60, 60, 50, 0.1), 0 1px 2px -1px rgba(60, 60, 50, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(60, 60, 50, 0.1), 0 2px 4px -2px rgba(60, 60, 50, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(60, 60, 50, 0.1), 0 4px 6px -4px rgba(60, 60, 50, 0.05);
  --shadow-hover: 0 20px 25px -5px rgba(60, 60, 50, 0.1), 0 10px 10px -5px rgba(60, 60, 50, 0.04);

  /* Glass / Sticky */
  --glass-bg: rgba(255, 255, 255, 0.9);
  --glass-border: rgba(229, 229, 224, 0.7);

  /* Drug category colors */
  --induction: #0ea5e9;
  --muscle-relaxant: #f59e0b;
  --analgesic: #059669;
  --adjunct: #8b5cf6;
  --reversal: #ef4444;
  --emergency: #f97316;
  --steroid: #14b8a6;
  --antiemetic: #65a30d;
  --local-anesthetic: #f43f5e;
  --infusion: #06b6d4;
  --antibiotic: #4f46e5;

  /* Semantic alerts */
  --caution-color: #fbbf24;
  --reset-color: #ef4444;

  /* Radii */
  --radius-card: 16px;
  --radius-input: 12px;
  --radius-tab: 50px;

  /* Animations */
  --anim-bezier: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* =========================================================
   DARK MODE OVERRIDES
   ========================================================= */
body.dark-mode {
  --primary-accent: #34d399;
  --primary-accent-dark: #10b981;
  --primary-accent-light: rgba(52, 211, 153, 0.15);

  --bg-primary: #0c0a09;
  --bg-secondary: #1c1917;
  --bg-card: #1c1917;

  --text-primary: #f5f5f4;
  --text-secondary: #d6d3d1;
  --text-tertiary: #a8a29e;

  --input-bg: #12100f;
  --border-color: #44403c;

  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.6);

  --glass-bg: rgba(28, 25, 23, 0.9);
  --glass-border: rgba(255, 255, 255, 0.1);

  --caution-color: #fcd34d;
  --reset-color: #f87171;
  --emergency: #fbbf24;
}

/* =========================================================
   BASE RESET & GLOBAL STYLES
   ========================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  touch-action: manipulation;
}

body {
  overflow-x: hidden;
  width: 100%;
  font-family: 'Manrope', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  font-size: 14px;
  transition: background-color 0.4s var(--anim-bezier),
              color 0.4s var(--anim-bezier),
              font-size 0.3s var(--anim-bezier);
  user-select: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: contain;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  letter-spacing: -0.02em;
}

input,
textarea,
select {
  user-select: text !important;
  font-family: 'Manrope', sans-serif;
}

/* Tabular numbers for numeric outputs */
input[type="number"] {
  font-feature-settings: "tnum" on;
  font-variant-numeric: tabular-nums;
}

/* =========================================================
   LAYOUT
   ========================================================= */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 15px 10px;
  animation: containerFadeIn 0.5s ease-out;
}

@keyframes containerFadeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* =========================================================
   HEADER
   ========================================================= */
header {
  background: linear-gradient(135deg, var(--primary-accent), var(--primary-accent-dark));
  color: white;
  padding: 15px;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

header::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 70%);
  transform: rotate(30deg);
  animation: shimmer 4s ease-in-out infinite alternate;
}

@keyframes shimmer {
  0%   { transform: translate(-30%, -30%) rotate(30deg); }
  100% { transform: translate(30%, 30%)  rotate(30deg); }
}

h1 {
  font-size: 1.5em;
  font-weight: 700;
  z-index: 1;
  flex: 1;
  min-width: 150px;
}

/* =========================================================
   HEADER CONTROLS
   ========================================================= */
.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.font-size-control {
  background: rgba(255,255,255,0.2);
  border-radius: 50px;
  box-shadow: 0 2px 5px rgba(0,0,0,.2);
  display: flex;
  align-items: center;
  padding: 2px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1;
}

.font-adjust-btn {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1em;
  padding: 6px 8px;
  border-radius: 50%;
  transition: all .25s var(--anim-bezier);
  line-height: 1;
}

.font-adjust-btn:hover {
  background: rgba(255,255,255,0.3);
  transform: scale(1.1);
}

#font-size-indicator {
  color: white;
  font-weight: 600;
  font-size: .75em;
  padding: 0 4px;
  min-width: 40px;
  text-align: center;
  user-select: none;
  font-feature-settings: "tnum" on;
  font-variant-numeric: tabular-nums;
}

.dark-mode-toggle {
  background: rgba(255,255,255,0.2);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: .75em;
  font-weight: 600;
  box-shadow: 0 2px 5px rgba(0,0,0,.2);
  transition: all .25s var(--anim-bezier);
  outline: none;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  min-width: 120px;
  overflow: hidden;
}

.dark-mode-toggle:hover {
  background: rgba(255,255,255,0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,.2);
}

.dark-mode-toggle:active { transform: translateY(0px); }

.dark-mode-toggle i { transition: transform 0.4s var(--anim-bezier); }
body.dark-mode .dark-mode-toggle i { transform: rotate(180deg); }

/* =========================================================
   SECTIONS & CARDS
   ========================================================= */
.section {
  background: var(--bg-card);
  padding: 15px;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
  margin-bottom: 15px;
  transition: box-shadow .3s var(--anim-bezier), transform 0.3s var(--anim-bezier);
  border: 1px solid var(--border-color);
}

.section:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.section h2 {
  font-size: 1.25em;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section h2 i { color: var(--primary-accent); }

/* =========================================================
   FORM ELEMENTS
   ========================================================= */
.input-field label {
  font-size: .8em;
  color: var(--text-secondary);
  margin-bottom: 5px;
  font-weight: 600;
  display: block;
}

.input-field input,
.input-field select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-input);
  font-size: 16px; /* Prevents iOS zoom */
  background: var(--input-bg);
  color: var(--text-primary);
  transition: border-color .3s var(--anim-bezier), box-shadow .3s var(--anim-bezier);
  appearance: none;
}

.input-field input:focus,
.input-field select:focus {
  outline: none;
  border-color: var(--primary-accent);
  box-shadow: 0 0 0 4px var(--primary-accent-light);
  background: var(--bg-card);
}

/* =========================================================
   DISCLAIMER / WARNING BANNER
   ========================================================= */
.warning {
  background: #fffbeb;
  border-left: 5px solid #f59e0b;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.8em;
  color: #b45309;
  font-weight: 500;
  margin-bottom: 15px;
  box-shadow: var(--shadow);
}

body.dark-mode .warning {
  background: #451a03;
  color: #fcd34d;
  border-left: 5px solid #f59e0b;
}

/* =========================================================
   INFO BOX
   ========================================================= */
.info-box {
  background: var(--bg-secondary);
  border-left: 4px solid var(--primary-accent);
  padding: 12px 15px;
  margin: 15px 0;
  border-radius: 8px;
  font-size: 0.85em;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.info-box strong { color: var(--primary-accent); font-weight: 600; }

/* =========================================================
   FOOTER
   ========================================================= */
footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.8em;
  color: var(--text-secondary);
  padding: 20px 10px;
  border-top: 1px solid var(--border-color);
}

footer a {
  color: var(--primary-accent);
  text-decoration: none;
  font-weight: 600;
}

footer a:hover { text-decoration: underline; }

/* =========================================================
   ANIMATIONS
   ========================================================= */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

/* =========================================================
   RESPONSIVE - TABLET+
   ========================================================= */
@media (min-width: 768px) {
  .container { padding: 20px 15px; }
  h1 { font-size: 2em; }
  .section h2 { font-size: 1.5em; }
}

/* =========================================================
   RESPONSIVE - MOBILE
   ========================================================= */
@media (max-width: 480px) {
  .input-field input,
  .input-field select,
  input[type="number"] {
    font-size: 16px !important; /* Prevent iOS zoom */
    padding: 8px 10px;
  }

  header::before {
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 60%);
    animation-duration: 2.5s;
  }

  .header-controls {
    flex-wrap: wrap;
    justify-content: flex-end;
    flex-grow: 1;
    gap: 8px;
  }

  .font-size-control { padding: 2px; }

  .font-adjust-btn {
    padding: 4px 6px;
    font-size: 0.9em;
  }

  .dark-mode-toggle {
    padding: 6px 12px;
    font-size: 0.7em;
    min-width: 100px;
  }

  h1 { font-size: 1.2em; }
}
