/* =============================================================================
   Myo-Rep Calculator - Modern Dark Theme
   A clean, professional design with consistent styling
   ============================================================================= */

/* CSS Variables - Design Tokens */
:root {
  /* Colors */
  --color-primary: #00d4ff;
  --color-primary-dark: #00a6c4;
  --color-accent: #35CDE3;
  --color-success: #4ade80;
  --color-warning: #fbbf24;
  --color-error: #fb7185;
  --color-info: #60a5fa;
  
  /* Backgrounds */
  --bg-dark: #0a0f14;
  --bg-card: #111921;
  --bg-card-hover: #1a242f;
  --bg-input: rgba(255, 255, 255, 0.03);
  --bg-input-focus: rgba(255, 255, 255, 0.06);
  
  /* Text */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(0, 212, 255, 0.15);
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  
  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

/* =============================================================================
   Base Styles
   ============================================================================= */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg-dark);
  background-image: 
    radial-gradient(ellipse at 20% 0%, rgba(0, 212, 255, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(53, 205, 227, 0.03) 0%, transparent 50%);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 700;
  line-height: 1.2;
}

.brand-font {
  font-family: 'Bebas Neue', Arial, sans-serif;
  letter-spacing: 2px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--color-accent); }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }

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

a:hover {
  color: var(--color-accent);
}

/* =============================================================================
   Layout Components
   ============================================================================= */

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.card:hover {
  border-color: var(--border-hover);
}

.card-glass {
  background: rgba(17, 25, 33, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* =============================================================================
   Form Elements
   ============================================================================= */

input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  width: 100%;
  transition: all var(--transition-fast);
  outline: none;
}

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

input:focus, select:focus, textarea:focus {
  background: var(--bg-input-focus);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

select option {
  background: var(--bg-dark);
  color: var(--text-primary);
}

/* Input with icon wrapper */
.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group .icon {
  position: absolute;
  left: 14px;
  font-size: 1.25rem;
  pointer-events: none;
  opacity: 0.7;
}

.input-group input {
  padding-left: 44px;
}

/* =============================================================================
   Buttons
   ============================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

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

/* Primary Button */
.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: #001219;
  box-shadow: 0 4px 16px rgba(0, 212, 255, 0.25);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 212, 255, 0.35);
}

/* Premium Button */
.btn-premium {
  background: linear-gradient(135deg, #ffd166, #ff9f1c);
  color: #111;
  box-shadow: 0 4px 16px rgba(255, 209, 102, 0.25);
}

.btn-premium:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(255, 209, 102, 0.35);
}

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

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-input);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* Danger Button */
.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.3);
}

/* Small Button */
.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}

/* =============================================================================
   Status Badges & Pills
   ============================================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-premium {
  background: linear-gradient(135deg, #ffd166, #ff9f1c);
  color: #111;
}

.badge-free {
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.badge-success {
  background: rgba(74, 222, 128, 0.15);
  color: var(--color-success);
}

/* =============================================================================
   Toast Notifications
   ============================================================================= */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 360px;
  max-width: calc(100vw - 40px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideIn 0.3s ease;
}

.toast.success { border-left: 4px solid var(--color-success); }
.toast.error { border-left: 4px solid var(--color-error); }
.toast.warning { border-left: 4px solid var(--color-warning); }
.toast.info { border-left: 4px solid var(--color-info); }

.toast .msg {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.toast .close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 1.1rem;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.toast .close:hover {
  opacity: 1;
}

.toast.hide {
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.02);
  }
}

/* =============================================================================
   Modal System
   ============================================================================= */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.modal-root.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(20px);
  transition: transform var(--transition-base);
  box-shadow: var(--shadow-lg);
}

.modal-root.active .modal-content {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 1.5rem;
}

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

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

/* =============================================================================
   Calculator Section
   ============================================================================= */

.calculator-card {
  background: linear-gradient(180deg, var(--bg-card) 0%, rgba(17, 25, 33, 0.8) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.calculator-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.calculator-form .btn-primary {
  grid-column: 1 / -1;
}

/* =============================================================================
   Plan Result Card
   ============================================================================= */

.plan-card {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.05), rgba(53, 205, 227, 0.03));
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: var(--radius-lg);
  padding: 28px;
  position: relative;
  overflow: hidden;
}

.plan-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
}

.plan-card h2 {
  font-size: 1.75rem;
  margin-bottom: 16px;
  color: var(--color-primary);
}

.plan-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}

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

.plan-item-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.plan-item-value {
  font-size: 1.1rem;
  font-weight: 600;
}

.plan-hint {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  font-style: italic;
  color: var(--text-secondary);
}

/* Premium Overlay */
.premium-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, rgba(10, 15, 20, 0), rgba(10, 15, 20, 0.95));
  padding: 32px 16px 16px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
}

.premium-cta {
  text-align: center;
  padding: 24px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
}

.premium-cta h3 {
  margin-bottom: 8px;
}

.premium-cta p {
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* =============================================================================
   Log Entries
   ============================================================================= */

.log-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.log-entry {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: all var(--transition-fast);
}

.log-entry:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.log-info {
  flex: 1;
}

.log-exercise {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.log-meta {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.log-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.log-actions {
  display: flex;
  gap: 8px;
}

.log-actions .btn {
  padding: 8px 12px;
  font-size: 0.85rem;
}

/* =============================================================================
   Unit Toggle
   ============================================================================= */

.unit-toggle {
  display: inline-flex;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  padding: 4px;
  border: 1px solid var(--border-subtle);
}

.unit-toggle a {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.unit-toggle a[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: #001219;
}

.unit-toggle a:hover:not([aria-pressed="true"]) {
  color: var(--text-primary);
}

/* =============================================================================
   Account Bubble
   ============================================================================= */

.account-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.account-bubble:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

/* =============================================================================
   Tutorial Button
   ============================================================================= */

.tutorial-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-fast);
  z-index: 100;
}

.tutorial-btn:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.tutorial-btn svg {
  width: 24px;
  height: 24px;
  stroke: #001219;
}

/* =============================================================================
   Premium Features Card
   ============================================================================= */

.premium-card {
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.05), rgba(255, 159, 28, 0.03));
  border: 1px solid rgba(255, 209, 102, 0.2);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.premium-card h3 {
  color: #ffd166;
  margin-bottom: 12px;
}

.premium-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px 0;
}

.premium-list li {
  padding: 8px 0;
  padding-left: 24px;
  position: relative;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.premium-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: #ffd166;
  font-weight: bold;
}

/* =============================================================================
   Social Links
   ============================================================================= */

.social-links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.social-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-weight: 500;
  transition: color var(--transition-fast);
}

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

.social-link svg {
  width: 24px;
  height: 24px;
}

/* =============================================================================
   Login Card
   ============================================================================= */

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.login-card .form-group {
  margin-bottom: 16px;
}

.login-card .btn-primary {
  width: 100%;
  padding: 14px 24px;
  font-size: 1rem;
}

/* =============================================================================
   Help Tooltip
   ============================================================================= */

.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: help;
  margin-left: 8px;
}

.help-btn:hover {
  background: var(--bg-input-focus);
  color: var(--color-primary);
}

/* =============================================================================
   Header Section
   ============================================================================= */

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.header-left h1 {
  font-size: 3rem;
  margin-bottom: 4px;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.header-meta img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* =============================================================================
   Error Pages
   ============================================================================= */

.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.error-content h1 {
  font-size: 6rem;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 16px;
}

.error-content p {
  color: var(--text-muted);
  font-size: 1.2rem;
  margin-bottom: 24px;
}

/* =============================================================================
   Responsive Design
   ============================================================================= */

@media (max-width: 768px) {
  :root {
    font-size: 15px;
  }

  .header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-left h1 {
    font-size: 2.5rem;
  }

  .header-right {
    align-items: stretch;
    flex-direction: row;
    justify-content: space-between;
  }

  .calculator-form {
    grid-template-columns: 1fr;
  }

  .log-entry {
    flex-direction: column;
    align-items: stretch;
  }

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

  .toast-container {
    left: 16px;
    right: 16px;
    width: auto;
  }

  .modal-content {
    padding: 20px;
    margin: 16px;
  }
}

@media (max-width: 480px) {
  .header-left h1 {
    font-size: 2rem;
  }

  .card {
    padding: 16px;
  }

  .calculator-card {
    padding: 20px;
  }

  .social-links {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* =============================================================================
   Print Styles
   ============================================================================= */

@media print {
  body {
    background: white;
    color: black;
  }

  .no-print,
  .toast-container,
  .modal-root,
  .tutorial-btn {
    display: none !important;
  }

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

/* =============================================================================
   Utility Classes
   ============================================================================= */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.no-select {
  user-select: none;
  -webkit-user-select: none;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
