:root{
  --primary-pink: #ee95ff;
  --secondary-pink: #ff9ff3;
  --accent: #f368e0;
  --bg: #fff;
  --glass: rgba(255,255,255,0.85);
  --text-dark: #3b2b6a;
  --muted: #a29bfe;
  --success: #00b894;
  --danger: #ff7675;
  --shadow: rgba(108,92,231,0.12);
  --card-padding: 14px;
}

/* Reset */
* { box-sizing: border-box; margin:0; padding:0; }
html,body { height:100%; }

body{
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: linear-gradient(135deg, var(--primary-pink) 0%, var(--secondary-pink) 100%);
  color: var(--text-dark);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  min-height: 100vh;
}

/* Shell */
.app-shell {
  width: 100%;
  max-width: 1200px;
  height: 100%;
}

/* Header */
.app-header {
  margin-bottom: 20px;
  text-align: center;
  width: 100%;
}
.app-header h1 { 
  font-size: clamp(1.4rem, 4vw, 1.8rem); 
  color: #fff; 
  text-shadow: 0 4px 10px rgba(0,0,0,0.12); 
  margin-bottom: 8px;
}
.app-header .subtitle { 
  color: rgba(255,255,255,0.95); 
  font-size: clamp(0.8rem, 3vw, 0.95rem);
}

/* Tabs Navigation - CORREGIDO DEFINITIVAMENTE */
.tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  width: 100%;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.3);
  color: white;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  min-width: 120px;
  flex: 1;
  max-width: 180px;
}

.tab-btn.active {
  background: rgba(255,255,255,0.9);
  color: var(--text-dark);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.tab-btn:hover:not(.active) {
  background: rgba(255,255,255,0.5);
}

/* Tab Content */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Panels */
.panel-card {
  width: 100%;
  background: var(--glass);
  border-radius: 14px;
  padding: var(--card-padding);
  box-shadow: 0 10px 30px var(--shadow);
  text-align: left;
  margin-bottom: 16px;
}

/* form grid - CENTRADO */
.form-grid {
  display: grid;
  grid-template-columns: minmax(140px, 160px) minmax(200px, 250px);
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}
.form-grid label { 
  font-weight:700; 
  font-size:0.85rem; 
  color:var(--text-dark); 
  word-break: break-word;
  text-align: right;
  padding-right: 10px;
}

.form-grid input[type="text"], 
.form-grid input[type="number"], 
.form-grid select {
  padding: 10px 12px; 
  border-radius:8px; 
  border:1px solid rgba(0,0,0,0.1); 
  background:#fff;
  font-size: 0.9rem;
  width: 100%;
}

input[type="number"] {
  width: 100px;
}

/* Centrar contenedores específicos */
#exercises-tab .panel-card,
#routines-tab .panel-card {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* lists */
.small-list { 
  min-height: 120px; 
  max-height:240px; 
  overflow:auto; 
  background:#fff; 
  padding:12px; 
  border-radius:8px; 
  border: 1px solid rgba(0,0,0,0.1);
  width: 100%;
  max-width: 600px;
}
.small-list .item { 
  display:flex; 
  justify-content:space-between; 
  align-items:center; 
  padding:10px; 
  border-bottom:1px solid #eee; 
  gap: 10px;
}
.small-list .item:last-child { border-bottom: none; }

.list { 
  max-height: 320px; 
  overflow:auto; 
  margin-top:16px; 
  width: 100%;
  max-width: 800px;
}
.list .card { 
  background:#fff; 
  padding:14px; 
  border-radius:8px; 
  margin-bottom:10px; 
  display:flex; 
  justify-content:space-between; 
  align-items:center;
  border: 1px solid rgba(0,0,0,0.1);
  gap: 14px;
}

/* buttons */
.btn { 
  padding:10px 14px; 
  border-radius:8px; 
  border:none; 
  cursor:pointer; 
  background:rgba(0,0,0,0.05); 
  font-size: 0.85rem;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.btn.primary { 
  background: linear-gradient(90deg,var(--accent),var(--primary-pink)); 
  color:white; 
  box-shadow: 0 4px 12px rgba(0,0,0,0.1); 
}
.btn.danger { 
  background: linear-gradient(90deg,var(--danger),#ff4d6d); 
  color:white; 
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.form-actions { 
  margin-top:20px; 
  display:flex; 
  gap:10px; 
  justify-content:center; 
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

.list-controls {
  text-align: center;
  margin: 15px 0;
}

.list-controls input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.1);
  width: 100%;
  max-width: 400px;
  margin-bottom: 10px;
}

/* training */
.training-card { text-align:center; }
.training-header { 
  display:flex; 
  justify-content:space-between; 
  align-items:center; 
  gap:16px; 
  margin-bottom:16px; 
  flex-wrap: wrap;
}
.training-display { 
  background: #fff; 
  border-radius:12px; 
  padding:20px; 
  margin-bottom:16px; 
  text-align:center;
  border: 1px solid rgba(0,0,0,0.1);
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}
.timer { 
  font-size:clamp(2.5rem, 10vw, 4rem); 
  font-weight:800; 
  color:var(--text-dark); 
  margin-bottom: 8px;
}
.phase-emoji { 
  font-size:clamp(2rem, 8vw, 3rem); 
  margin-bottom: 8px;
}
.phase-text { 
  font-weight:800; 
  font-size: clamp(1rem, 4vw, 1.2rem);
  margin-bottom: 4px;
}
.phase-subtext { 
  color:var(--muted); 
  font-size: clamp(0.8rem, 3vw, 0.9rem);
}
.counters { 
  display:flex; 
  justify-content:space-around; 
  margin:20px 0; 
  font-weight:700; 
  flex-wrap: wrap; 
  gap: 15px; 
  font-size: clamp(0.8rem, 3vw, 1rem);
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}
.controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 20px 0;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}
.next-info { 
  margin-top:15px; 
  color:var(--muted); 
  font-size: clamp(0.8rem, 3vw, 0.9rem);
}

/* Volume control */
.volume-control {
  margin-top: 20px;
  padding: 15px;
  background: rgba(255,255,255,0.7);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: clamp(0.8rem, 3vw, 0.9rem);
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.volume-control input[type="range"] {
  width: 120px;
}

/* Exercise edit modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: white;
  padding: 25px;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

/* Centrar elementos específicos de rutinas */
#routines-tab .form-grid {
  max-width: 700px;
}

#routineName, #routineDesc {
  max-width: 300px;
}

/* Tiempo estimado del ejercicio */
.exercise-time {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
  margin-top: 4px;
}

/* Fases de ejercicio */
.phases-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 10px 0;
  background: rgba(255,255,255,0.5);
  padding: 10px;
  border-radius: 8px;
}

.phase-item {
  text-align: center;
  padding: 5px;
}

.phase-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.phase-value {
  font-weight: bold;
  color: var(--text-dark);
}

@media (min-width: 1200px) {
  .app-shell {
    min-height: auto;
    max-width: 1400px;
  }
  
  .form-grid {
    grid-template-columns: 160px minmax(250px, 300px);
    gap: 15px;
  }
  
  .panel-card {
    padding: 25px;
  }
  
  .training-display {
    max-width: 600px;
  }
  
  /* Asegurar que los tabs sean visibles en pantallas grandes */
  .tabs {
    flex-wrap: nowrap;
    gap: 15px;
  }
  
  .tab-btn {
    min-width: 180px;
    font-size: 1rem;
    padding: 14px 25px;
  }
}

/* responsive - SOLO AJUSTES ESPECÍFICOS PARA MÓVILES */
@media (max-width: 768px){
  body {
    padding: 12px;
    align-items: flex-start;
  }
  
  .app-shell {
    min-height: auto;
  }
  
  .tabs { 
    gap: 8px;
  }
  
  .tab-btn { 
    width: 100%; 
    max-width: 300px;
    min-width: auto;
  }
  
  .form-grid { 
    grid-template-columns: 1fr; 
    gap: 15px;
    text-align: center;
  }
  
  .form-grid label {
    text-align: center;
    padding-right: 0;
    margin-bottom: -10px;
  }
  
  .form-grid input[type="text"], 
  .form-grid input[type="number"],
  .form-grid select {
    max-width: 100%;
    width: 100%;
  }
  
  input[type="number"] {
    width: 100%;
    max-width: 150px;
    margin: 0 auto;
  }
  
  .training-header { 
    flex-direction: column; 
    text-align: center;
  }
  
  .counters { 
    flex-direction: row;
    justify-content: space-between;
    gap: 10px;
  }
  
  .controls {
    flex-direction: column;
    align-items: center;
  }
  
  .controls .btn {
    width: 100%;
    max-width: 250px;
  }
  
  .volume-control {
    flex-direction: column;
    gap: 10px;
  }
  
  .volume-control input[type="range"] {
    width: 200px;
  }
  
  .small-list .item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .small-list .item > div:last-child {
    align-self: stretch;
    text-align: center;
  }
  
  .list .card {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }
  
  .phases-grid {
    grid-template-columns: 1fr;
  }
}

/* Utility classes */
.text-center { text-align: center; }
.mt-2 { margin-top: 20px; }
.mb-2 { margin-bottom: 20px; }

.app-footer {
  text-align: center;
  margin-top: 20px;
  color: rgba(255,255,255,0.8);
}

.strong {
  font-weight: bold;
}

.time-overview {
  text-align: right;
}

hr {
  border: none;
  border-top: 1px solid rgba(0,0,0,0.1);
  margin: 20px 0;
}