/* ==========================================================================
   Calculadora de Porcentajes - Estilos Modernos y Responsivos
   ========================================================================== */

:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-heading: 'Outfit', 'Inter', sans-serif;

  /* Tema oscuro por defecto (Midnight Slate & Vibrant Blue) */
  --bg-app: #080c14;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --bg-input: #0f172a;
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-focus: #38bdf8;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #38bdf8;
  --primary-glow: rgba(56, 189, 248, 0.25);
  --accent: #ff8507;
  --success: #10b981;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: #ffffff;
  --bg-input: #ffffff;
  --border-glass: rgba(0, 0, 0, 0.08);
  --border-focus: #0284c7;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --primary: #0284c7;
  --primary-glow: rgba(2, 132, 199, 0.2);
  --accent: #ea580c;
  --success: #059669;
  color-scheme: light;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-wrapper {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* Hero */
.tool-hero {
  margin-bottom: 2rem;
}

.tool-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 0.85rem;
}

.tool-hero h2 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.tool-hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 800px;
}

/* Tabs Grid */
.percent-tabs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.percent-tab {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  min-height: 44px;
}

.percent-tab:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--primary);
}

.percent-tab.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 4px 14px var(--primary-glow);
}

/* Tarjetas de cálculo */
.percent-cards-container {
  margin-bottom: 2rem;
}

.calc-box {
  display: none;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  animation: fadeIn 0.3s ease;
}

.calc-box.active {
  display: block;
}

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

.calc-header {
  margin-bottom: 1.5rem;
}

.calc-tag {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.35rem;
  display: inline-block;
}

.calc-header h3 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  color: var(--text-main);
}

/* Inputs */
.calc-inputs-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (max-width: 640px) {
  .calc-inputs-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

.input-unit-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.input-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.input-field-wrap {
  display: flex;
  align-items: center;
  position: relative;
  width: 100%;
}

.form-input {
  width: 100%;
  min-height: 48px;
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 1.15rem;
  padding: 0.6rem 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  -moz-appearance: textfield;
}

.form-input::-webkit-outer-spin-button,
.form-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.form-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.unit-suffix {
  position: absolute;
  right: 1rem;
  font-family: var(--font-main);
  font-weight: 700;
  color: var(--text-muted);
  pointer-events: none;
}

/* Result Box */
.calc-result-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

[data-theme="light"] .calc-result-box {
  background: #f8fafc;
}

.result-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.result-value-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.result-number {
  font-family: var(--font-mono);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.result-number.text-success {
  color: var(--success);
}

.btn-copy-res {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 40px;
}

.btn-copy-res:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.result-formula {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-glass);
}

/* Historial */
.percent-history-section {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.history-header h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: var(--text-main);
}

.btn-sm-ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.2s;
}

.btn-sm-ghost:hover {
  color: var(--accent);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.empty-history-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Edu Grid */
.percent-edu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .percent-edu-grid {
    grid-template-columns: 1fr;
  }
}

.edu-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.edu-card h4 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.edu-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.edu-card code {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  color: var(--primary);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.modal-card h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.modal-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.btn-primary {
  width: 100%;
  min-height: 44px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary:hover {
  opacity: 0.9;
}
