/* RedactorApp - Premium Elegant Medical Theme */
/* Based on globals.css design system */

@import url("/web/css/fonts.css");

/* ============================================
   CSS VARIABLES - Design System
   ============================================ */
:root {
  /* Primary Colors - Deep Blue */
  --color-primary: #1B277A;
  --color-primary-hover: #141d5e;
  --color-primary-light: #e8eaf4;
  --color-primary-fg: #ffffff;

  /* Secondary Colors - Red */
  --color-secondary: #B9131E;
  --color-secondary-hover: #8f0f18;
  --color-secondary-light: #fce8e9;
  --color-secondary-fg: #ffffff;

  /* Accent Colors */
  --color-accent-purple: #8C05DB;
  --color-accent-green: #01FF79;

  /* Neutral Colors */
  --color-bg: linear-gradient(135deg, #e8eaf4 0%, #f0f1f8 100%);
  --color-surface: #ffffff;
  --color-surface-alt: #f8fafc;
  --color-text: #1a202c;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;

  /* Status */
  --color-success: #059669;
  --color-success-light: #ecfdf5;
  --color-warning: #d97706;
  --color-warning-light: #fffbeb;
  --color-error: #dc2626;
  --color-error-light: #fef2f2;
  --color-info: #0891b2;
  --color-info-light: #ecfeff;

  /* Typography */
  --font-heading: "DM Sans", sans-serif;
  --font-body: "Roboto", sans-serif;
  --font-accent: "Inter", sans-serif;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px rgba(27, 39, 122, 0.15);

  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-normal: 250ms ease-in-out;
  --transition-slow: 350ms ease-in-out;
}

/* ============================================
   BASE STYLES
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--color-bg) !important;
  color: var(--color-text);
  font-size: 0.9375rem;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.25;
  color: var(--color-text);
}

/* ============================================
   ALERTS / MESSAGES
   ============================================ */
.alert {
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 400;
  border-left: 4px solid;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.alert-success {
  border-color: var(--color-success);
  background: var(--color-success-light);
  color: #065f46;
}

.alert-error {
  border-color: var(--color-error);
  background: var(--color-error-light);
  color: #991b1b;
}

.alert-warning {
  border-color: var(--color-warning);
  background: var(--color-warning-light);
  color: #92400e;
}

.alert-info {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  color: var(--color-primary);
}

/* ============================================
   AUTH CARDS (login, register, reset)
   ============================================ */
.auth-card {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.97) 0%, rgba(248, 250, 252, 0.95) 100%);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-primary);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  padding: 2.5rem;
  position: relative;
  overflow: hidden;
}

.auth-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(27, 39, 122, 0.02) 0%, rgba(140, 5, 219, 0.02) 100%);
  pointer-events: none;
}

.auth-title {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-subtitle {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 1.5rem;
}

/* ============================================
   DASHBOARD
   ============================================ */
.dashboard-card {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.97) 0%, rgba(248, 250, 252, 0.95) 100%);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-primary);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  padding: 2.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.dashboard-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(27, 39, 122, 0.02) 0%, rgba(140, 5, 219, 0.02) 100%);
  pointer-events: none;
}

.dashboard-title {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.dashboard-subtitle {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  margin-bottom: 2rem;
}

.dashboard-modules {
  display: flex;
  gap: 1.25rem;
  justify-content: center;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.module-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem 2rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  text-decoration: none;
  transition: all var(--transition-normal);
  min-width: 180px;
}

.module-active:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  border-color: var(--color-primary);
}

.module-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.module-icon {
  font-size: 1.5rem;
  color: var(--color-primary);
}

.module-disabled .module-icon {
  color: var(--color-text-muted);
}

.module-name {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.module-desc {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-family: var(--font-accent);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.375rem;
  letter-spacing: 0.01em;
}

.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  outline: none;
  transition: all var(--transition-fast);
}

.form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(27, 39, 122, 0.1);
}

.form-input::placeholder {
  color: #94a3b8;
}

.form-select {
  width: 100%;
  padding: 0.625rem 2.5rem 0.625rem 0.875rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  transition: all var(--transition-fast);
}

.form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(27, 39, 122, 0.1);
}

.form-error {
  font-size: 0.75rem;
  color: var(--color-error);
  margin-top: 0.25rem;
}

.form-checkbox {
  accent-color: var(--color-primary);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-accent);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.625rem 1.25rem;
  border: none;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
  outline: none;
  letter-spacing: 0.015em;
  position: relative;
  overflow: hidden;
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Primary Button - Deep Blue with shimmer */
.btn-primary {
  background: var(--color-primary);
  color: var(--color-primary-fg) !important;
  box-shadow: var(--shadow);
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left var(--transition-slow);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-fg);
  color: var(--color-primary) !important;
  border: 1px solid var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.btn-primary:hover:not(:disabled)::before {
  left: 100%;
}

/* Secondary/Outline Button */
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-secondary) !important;
  border: 1px solid var(--color-secondary);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-primary);
  color: var(--color-primary-fg) !important;
  border-color: var(--color-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Danger Button */
.btn-danger {
  background: var(--color-secondary-light);
  color: var(--color-secondary) !important;
}

.btn-danger:hover:not(:disabled) {
  background: var(--color-secondary);
  color: var(--color-secondary-fg) !important;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Ghost Button */
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted) !important;
  border: 1px solid var(--color-border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--color-primary-light);
  color: var(--color-primary) !important;
  border-color: var(--color-primary);
}

.btn-ghost.btn-active {
  background: var(--color-primary-light);
  color: var(--color-primary) !important;
  border-color: var(--color-primary);
}

/* Record Button */
.btn-record {
  background: var(--color-secondary);
  color: white !important;
  box-shadow: 0 4px 15px rgba(185, 19, 30, 0.3);
}

.btn-record:hover:not(:disabled) {
  background: var(--color-secondary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(185, 19, 30, 0.4);
}

/* Stop Button */
.btn-stop {
  background: #374151;
  color: white !important;
}

.btn-stop:hover:not(:disabled) {
  background: #1f2937;
}

/* QR Button - Purple accent */
.btn-qr {
  background: linear-gradient(135deg, rgba(140, 5, 219, 0.1) 0%, rgba(27, 39, 122, 0.1) 100%);
  color: var(--color-accent-purple) !important;
  border: 1px solid rgba(140, 5, 219, 0.2);
}

.btn-qr:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--color-accent-purple) 0%, var(--color-primary) 100%);
  color: white !important;
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(140, 5, 219, 0.3);
}

/* Upload Button */
.btn-upload {
  background: var(--color-surface-alt);
  color: var(--color-text) !important;
  border: 1px solid var(--color-border);
  cursor: pointer;
}

.btn-upload:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary) !important;
}

/* Small action buttons (copy, clear) */
.btn-action {
  font-size: 0.75rem;
  padding: 0.3rem 0.75rem;
  font-weight: 500;
}

/* Full-width button */
.btn-block {
  width: 100%;
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
}

/* ============================================
   WORKSPACE - AUDIO CONTROLS PANEL
   ============================================ */
.audio-panel {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.97) 0%, rgba(248, 250, 252, 0.95) 100%);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-primary);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* ============================================
   MODE SELECTOR
   ============================================ */
.mode-selector {
  display: flex;
  background: var(--color-primary-light);
  padding: 3px;
}

.mode-btn {
  padding: 0.4rem 1rem;
  font-family: var(--font-accent);
  font-size: 0.8125rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-btn.active {
  background: var(--color-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.mode-btn:not(.active):hover {
  color: var(--color-primary);
}

/* ============================================
   SECTION CARDS (medical-card style)
   ============================================ */
.section-card {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.97) 0%, rgba(248, 250, 252, 0.95) 100%);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: all var(--transition-normal);
  position: relative;
}

.section-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(27, 39, 122, 0.01) 0%, rgba(185, 19, 30, 0.01) 100%);
  pointer-events: none;
}

.section-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  border-left-color: var(--color-secondary);
}

.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.625rem;
}

.section-title {
  font-family: var(--font-heading);
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--color-text);
}

.section-content {
  min-height: 60px;
  padding: 0.75rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text);
  white-space: pre-wrap;
  line-height: 1.6;
}

textarea.section-editable {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  outline: none;
  overflow: hidden;
  border-radius: 0 0 0.5rem 0.5rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea.section-editable:focus {
  border-color: var(--color-primary, #6366f1);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

textarea.section-editable::placeholder {
  color: var(--color-text-muted, #9ca3af);
  font-style: italic;
}

.section-content[contenteditable="true"] {
  border-radius: 0 0 0.5rem 0.5rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.section-content[contenteditable="true"]:focus {
  border-color: var(--color-primary, #6366f1);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.section-content[contenteditable="true"]:empty::before {
  content: attr(data-placeholder);
  color: var(--color-text-muted, #9ca3af);
  font-style: italic;
  pointer-events: none;
}

.section-footer {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

/* ============================================
   PROCESSING INDICATORS
   ============================================ */
.processing-bar {
  background: var(--color-primary-light);
  border: 1px solid rgba(27, 39, 122, 0.15);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.processing-bar .spinner {
  border-color: rgba(27, 39, 122, 0.2);
  border-top-color: var(--color-primary);
}

.processing-bar .text {
  font-family: var(--font-accent);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-primary);
}

.error-bar {
  background: var(--color-error-light);
  border: 1px solid rgba(220, 38, 38, 0.15);
  border-left: 4px solid var(--color-error);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.error-bar .text {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: #991b1b;
}

/* ============================================
   SPINNER
   ============================================ */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(27, 39, 122, 0.2);
  border-radius: 50%;
  border-top-color: var(--color-primary);
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

.spinner-white {
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: white;
}

/* ============================================
   QR MODAL
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-card {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(24px);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-primary);
  box-shadow: var(--shadow-xl);
  padding: 2rem;
  max-width: 24rem;
  width: 100%;
  margin: 1rem;
  animation: fadeInScale 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--color-text);
}

/* ============================================
   BMI WIDGET
   ============================================ */
.bmi-input {
  width: 5.5rem;
  padding: 0.4rem 0.5rem;
  font-size: 0.875rem;
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  transition: all var(--transition-fast);
}

.bmi-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(27, 39, 122, 0.08);
  outline: none;
}

.bmi-result {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-primary-light);
  border-left: 3px solid var(--color-primary);
  font-family: var(--font-accent);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-primary);
}

/* ============================================
   STANDARD PARAGRAPHS
   ============================================ */
.paragraph-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.paragraph-label:hover {
  color: var(--color-primary);
}

/* ============================================
   BOTTOM ACTIONS
   ============================================ */
.bottom-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.75rem;
}

/* ============================================
   LINK STYLES
   ============================================ */
.link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.link:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

/* ============================================
   RECORDING INDICATOR
   ============================================ */
.recording-dot {
  width: 0.75rem;
  height: 0.75rem;
  background: white;
  display: inline-block;
}

.recording-pulse {
  color: var(--color-secondary);
  font-family: var(--font-accent);
  font-size: 0.875rem;
  font-weight: 600;
  animation: pulse 1.5s ease-in-out infinite;
}

/* ============================================
   MOBILE CAPTURE PAGE
   ============================================ */
.mobile-header {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
  color: white;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(27, 39, 122, 0.3);
}

.mobile-header h1 {
  font-family: var(--font-heading);
  font-size: 1.125rem;
  font-weight: 700;
  color: white;
}

.mobile-header .timer {
  font-family: var(--font-accent);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.75);
}

.record-circle {
  width: 6rem;
  height: 6rem;
  border-radius: 50%;
  background: var(--color-secondary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 25px rgba(185, 19, 30, 0.4);
  transition: all var(--transition-normal);
}

.record-circle:hover {
  background: var(--color-secondary-hover);
  transform: scale(1.05);
  box-shadow: 0 8px 30px rgba(185, 19, 30, 0.5);
}

.animate-pulse-red {
  animation: pulseRed 1.5s infinite;
}

@keyframes pulseRed {
  0%, 100% { box-shadow: 0 0 0 0 rgba(185, 19, 30, 0.4); }
  50% { box-shadow: 0 0 0 14px rgba(185, 19, 30, 0); }
}

/* ============================================
   EXPIRED PAGE
   ============================================ */
.expired-container {
  text-align: center;
  padding: 2rem;
}

.expired-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

.expired-title {
  font-family: var(--font-heading);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.expired-text {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* ============================================
   ANIMATIONS
   ============================================ */
.animate-fade-in {
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ============================================
   PAGE WRAPPER
   ============================================ */
.page-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   WORKSPACE HEADER
   ============================================ */
.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.workspace-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
}

/* ============================================
   DIVIDER
   ============================================ */
.divider {
  color: var(--color-border-strong);
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.02);
}

::-webkit-scrollbar-thumb {
  background: rgba(27, 39, 122, 0.15);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(27, 39, 122, 0.3);
}

/* ============================================
   SELECTION
   ============================================ */
::selection {
  background: rgba(27, 39, 122, 0.15);
  color: var(--color-primary);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .workspace-header {
    flex-direction: column;
    align-items: stretch;
  }

  .bottom-actions {
    flex-direction: column;
  }

  .bottom-actions .btn {
    width: 100%;
  }

  .section-card:hover {
    transform: translateY(-1px);
  }

  .auth-card {
    padding: 1.75rem;
  }
}

@media (max-width: 480px) {
  .page-content {
    padding: 1rem 0.75rem;
  }

  .audio-panel {
    padding: 1rem;
  }

  .section-card {
    padding: 1rem;
  }
}

/* ============================================
   TAILWIND UTILITY REPLACEMENTS
   ============================================ */

/* Display */
.hidden { display: none !important; }
.flex { display: flex; }

/* Flex Direction & Wrap */
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 0%; }

/* Alignment */
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

/* Gap */
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

/* Margin */
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mt-auto { margin-top: auto; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* Padding */
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }

/* Sizing */
.w-full { width: 100%; }
.w-10 { width: 2.5rem; }
.h-10 { height: 2.5rem; }
.min-h-screen { min-height: 100vh; }
.max-w-5xl { max-width: 64rem; }

/* Typography */
.text-center { text-align: center; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.whitespace-pre-wrap { white-space: pre-wrap; }

/* Colors */
.text-white { color: #ffffff; }
.text-gray-500 { color: #6b7280; }
.text-gray-600 { color: #4b5563; }
.text-gray-700 { color: #374151; }
.bg-white { background-color: #ffffff; }
.bg-gray-50 { background-color: #f9fafb; }

/* Borders */
.border { border: 1px solid #e5e7eb; }
.border-t { border-top: 1px solid #e5e7eb; }
.border-gray-200 { border-color: #e5e7eb; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-md { border-radius: 0.375rem; }

/* Spacing between children */
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-4 > * + * { margin-top: 1rem; }

/* ============================================
   PANEL ADMIN
   ============================================ */

/* Panel header with breadcrumbs */
.panel-header {
  margin-bottom: 1.5rem;
}

.panel-breadcrumb {
  font-family: var(--font-accent);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Stats grid */
.panel-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.panel-stat-card {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.97) 0%, rgba(248, 250, 252, 0.95) 100%);
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-primary);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  text-align: center;
}

.panel-stat-label {
  font-family: var(--font-accent);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.375rem;
}

.panel-stat-value {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-primary);
}

/* Tables */
.panel-table-wrapper {
  overflow-x: auto;
}

.panel-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-body);
  font-size: 0.875rem;
}

.panel-table th {
  font-family: var(--font-accent);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.75rem 0.75rem;
  text-align: left;
  border-bottom: 2px solid var(--color-border);
  background: var(--color-surface-alt);
}

.panel-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}

.panel-table tbody tr:hover {
  background: var(--color-primary-light);
}

.panel-table-total td {
  background: var(--color-surface-alt);
  border-top: 2px solid var(--color-border-strong);
  font-weight: 600;
}

/* Badges */
.badge {
  display: inline-block;
  font-family: var(--font-accent);
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  letter-spacing: 0.02em;
}

.badge-success {
  background: var(--color-success-light);
  color: var(--color-success);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.badge-danger {
  background: var(--color-error-light);
  color: var(--color-error);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.badge-info {
  background: var(--color-info-light);
  color: var(--color-info);
  border: 1px solid rgba(8, 145, 178, 0.2);
}

.badge-purple {
  background: rgba(140, 5, 219, 0.08);
  color: var(--color-accent-purple);
  border: 1px solid rgba(140, 5, 219, 0.2);
}

.badge-neutral {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

/* Info grid (user detail) */
.panel-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.panel-info-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.panel-info-label {
  font-family: var(--font-accent);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.panel-info-value {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--color-text);
}

/* ============================================
   CUPS SELECTOR (Descripciones Quirurgicas)
   ============================================ */

.cups-dropdown {
  position: relative;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  z-index: 100;
}

.cups-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--color-border-light, #f1f5f9);
  transition: background 0.15s;
}

.cups-item:hover {
  background: var(--color-primary-light, #eef0ff);
}

.cups-item.cups-selected {
  background: var(--color-primary-light, #eef0ff);
  opacity: 0.6;
  pointer-events: none;
}

.cups-item:last-child {
  border-bottom: none;
}

.cups-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover, #141e66) 100%);
  color: #fff;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: var(--font-body);
  line-height: 1.3;
}

.cups-chip strong {
  font-weight: 700;
}

.cups-chip-remove {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.15rem;
  transition: color 0.15s;
}

.cups-chip-remove:hover {
  color: #fff;
}

.form-select {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.9375rem;
  font-family: var(--font-body);
  color: var(--color-text);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: auto;
}

.form-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(27, 39, 122, 0.1);
}

/* ============================================
   PRINT
   ============================================ */
@media print {
  body {
    background: white !important;
  }

  .audio-panel, .bottom-actions, .btn-action {
    display: none !important;
  }

  .section-card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
}

/* ============================================
   DATOS PREVIOS PANELS
   ============================================ */
.previous-panel {
  margin-bottom: 12px;
}

.previous-panel summary {
  cursor: pointer;
  padding: 8px;
  background: var(--color-surface, #f3f4f6);
  border-radius: 6px;
}

.previous-panel summary .badge {
  color: var(--color-text-muted, #6b7280);
  margin-left: 6px;
  font-weight: normal;
}

.previous-panel-actions {
  display: flex;
  gap: 8px;
  padding: 8px 0;
}

.previous-panel-actions .btn {
  padding: 4px 8px;
  cursor: pointer;
  background: var(--color-primary, #3b82f6);
  color: white;
  border-radius: 4px;
  border: none;
  font-size: 12px;
}

/* Toggle del label del boton segun el estado HTMX:
 * por defecto se ve "Subir desde PC" (idle); durante el request HTTP
 * el form padre recibe la clase .htmx-request y mostramos "Subiendo..." */
.previous-panel-actions .btn-label-busy { display: none; }
.previous-panel-actions form.htmx-request .btn-label-idle { display: none; }
.previous-panel-actions form.htmx-request .btn-label-busy {
  display: inline;
  opacity: 0.85;
}
.previous-panel-actions form.htmx-request .btn { cursor: progress; }

/* Help tip (?) icon + tooltip on hover/focus */
.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #6b7280;
  color: white;
  font-size: 10px;
  font-weight: bold;
  margin-left: 6px;
  cursor: help;
  user-select: none;
  position: relative;
  vertical-align: middle;
}
.help-tip:focus { outline: 2px solid var(--color-primary, #3b82f6); }
.help-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  background: #1f2937;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: normal;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  width: 240px;
  z-index: 1000;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.help-tip:hover::after,
.help-tip:focus::after {
  opacity: 1;
  visibility: visible;
}

.previous-item-card {
  padding: 8px;
  margin-bottom: 6px;
  background: white;
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 6px;
}

.previous-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.previous-item-fecha {
  font-weight: 600;
  font-size: 12px;
}

.previous-item-titulo {
  flex-grow: 1;
  color: var(--color-text-muted, #6b7280);
}

.previous-item-actions button {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.6;
  padding: 2px 4px;
}

.previous-item-actions button:hover {
  opacity: 1;
}

.previous-item-body {
  font-size: 13px;
  line-height: 1.4;
  color: var(--color-text, #374151);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 6px;
  color: white;
  z-index: 9999;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  animation: toast-slide-in 0.2s ease-out;
}

.toast-success {
  background: #10b981;
}

.toast-error {
  background: #ef4444;
}

@keyframes toast-slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ============================================
   FENESTRADO APP - feature styles
   ============================================ */
.header { max-width: 980px; margin: 1.5rem auto 1rem; padding: 0 1.5rem; }
.header h1 { font-size: 1.6rem; color: var(--color-primary); }
.subtitle { color: var(--color-text-muted); font-size: 0.95rem; }

.footer {
  max-width: 980px; margin: 3rem auto 2rem; padding: 1rem 1.5rem;
  color: var(--color-text-muted); font-size: 0.85rem; border-top: 1px solid var(--color-border);
}

.case-form {
  max-width: 980px; margin: 0 auto; padding: 1.5rem;
  display: grid; gap: 1.5rem;
  background: var(--color-surface);
  box-shadow: var(--shadow);
  border: 1px solid var(--color-border);
}
.case-form fieldset { border: 1px solid var(--color-border); padding: 1rem; }
.case-form legend { font-family: var(--font-heading); font-weight: 600; padding: 0 0.5rem; color: var(--color-primary); }

.cylinder { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.case-form label { display: flex; flex-direction: column; font-size: 0.9rem; color: var(--color-text); gap: 0.25rem; }
.case-form input[type="number"], .case-form input[type="text"] {
  padding: 0.5rem 0.6rem; border: 1px solid var(--color-border-strong);
  font-family: var(--font-body); font-size: 0.95rem; background: white;
}
.case-form input:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.case-form .check { flex-direction: row; align-items: center; gap: 0.5rem; }

#fenestration-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
#fenestration-table th, #fenestration-table td { padding: 0.4rem; text-align: left; }
#fenestration-table th { font-family: var(--font-heading); font-size: 0.8rem; color: var(--color-text-muted); }
#fenestration-table input { width: 100%; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.55rem 1.1rem; font-family: var(--font-accent); font-weight: 600;
  font-size: 0.9rem; border: 1px solid transparent; cursor: pointer;
  transition: all var(--transition-fast); text-decoration: none;
}
.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary { background: var(--color-surface); color: var(--color-primary); border-color: var(--color-primary); }
.btn-secondary:hover { background: var(--color-primary-light); }
.btn-ghost { background: transparent; color: var(--color-error); border: none; font-size: 1.2rem; }

.actions { display: flex; gap: 1rem; align-items: center; }
.spinner { color: var(--color-text-muted); font-size: 0.85rem; display: none; }
.spinner.htmx-request, .htmx-request .spinner { display: inline; }

.errors:empty { display: none; }
.errors ul { list-style: none; padding: 0.75rem 1rem; background: var(--color-error-light); color: #7f1d1d; border-left: 4px solid var(--color-error); }
.errors li { padding: 0.15rem 0; }

.result-panel {
  max-width: 980px; margin: 0 auto; padding: 1.5rem;
  background: var(--color-surface); box-shadow: var(--shadow);
  display: grid; gap: 1.25rem;
}
.summary { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1.5rem; font-size: 0.9rem; }
.summary dt { font-weight: 600; color: var(--color-text-muted); }
#viewer { width: 100%; height: 480px; background: var(--color-surface-alt); border: 1px solid var(--color-border); }

.viewer-legend {
  display: flex; flex-wrap: wrap; gap: 1rem 1.25rem;
  margin: -0.25rem 0 0;
  font-family: var(--font-accent); font-size: 0.8rem;
  color: var(--color-text-muted);
}
.viewer-legend__item { display: inline-flex; align-items: center; gap: 0.4rem; }
.viewer-legend__dot {
  display: inline-block; width: 0.65rem; height: 0.65rem; border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}

.vessel-name { font-family: var(--font-heading); font-weight: 700; color: var(--color-primary); text-align: left; padding: 0.4rem; min-width: 4rem; }
.hint { font-family: var(--font-body); font-weight: 400; color: var(--color-text-muted); font-size: 0.8rem; margin-left: 0.5rem; }

/* ============================================
   GONIÓMETRO — angular measurement modal
   ============================================ */
.goniometro-modal[hidden] { display: none; }

.goniometro-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}

.goniometro-modal__card {
  background: var(--color-surface);
  width: min(960px, 100%);
  max-height: 90vh;
  display: grid; grid-template-rows: auto 1fr auto;
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-primary);
  box-shadow: var(--shadow-xl);
}

.goniometro-modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
}

.goniometro-modal__title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--color-primary);
}

.goniometro-modal__close {
  background: transparent; border: none; cursor: pointer;
  font-size: 1.25rem; color: var(--color-text-muted);
  padding: 0.25rem 0.5rem;
}
.goniometro-modal__close:hover { color: var(--color-text); }

.goniometro-modal__body {
  padding: 1rem 1.25rem;
  display: grid; gap: 0.75rem;
  overflow: auto;
}

.goniometro-dropzone {
  border: 2px dashed var(--color-border-strong);
  background: var(--color-surface-alt);
  padding: 3rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.goniometro-dropzone:hover,
.goniometro-dropzone:focus,
.goniometro-dropzone.is-dragover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
  outline: none;
}

.goniometro-canvas-wrap {
  position: relative;
  display: flex;
  justify-content: center;
}
.goniometro-canvas-wrap[hidden] { display: none; }
.goniometro-canvas {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  width: auto;
  height: auto;
  background: #0b0c10;
  cursor: crosshair;
  touch-action: none;  /* required for Pointer Events drag on touch devices */
  box-shadow: 0 0 0 1px rgba(245, 230, 200, 0.06);
}

.goniometro-banner {
  min-height: 1.25em;
  font-family: var(--font-accent);
  font-size: 0.875rem;
  color: var(--color-text);
}
.goniometro-banner.is-warn { color: var(--color-warning); }
.goniometro-banner.is-error { color: var(--color-error); }

.goniometro-readout {
  display: flex; flex-wrap: wrap; gap: 1.25rem;
  font-family: var(--font-accent); font-size: 0.875rem;
  color: var(--color-text);
}
.goniometro-readout strong { color: var(--color-primary); }
.goniometro-readout__offset { color: var(--color-warning); }

.goniometro-modal__footer {
  display: flex; justify-content: flex-end; gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--color-border);
}

/* Trigger button + badge inside the form row */
.frow-measure {
  display: flex; align-items: center; gap: 0.5rem;
  white-space: nowrap;
}
.goniometro-trigger.is-measured .goniometro-trigger-label::before {
  content: "📐 Re-medir";
}
.goniometro-trigger.is-measured .goniometro-trigger-label {
  font-size: 0;  /* hide the "📐 Medir" default text when re-measured */
}
.goniometro-trigger.is-measured .goniometro-trigger-label::before {
  font-size: 0.9rem;
}

.goniometro-badge[hidden] { display: none; }
.goniometro-badge {
  font-family: var(--font-accent);
  font-size: 0.8125rem;
  color: var(--color-success);
  background: var(--color-success-light);
  padding: 0.15rem 0.5rem;
  border: 1px solid rgba(5, 150, 105, 0.2);
}
