/****************************************************
 * OTF-PRO — Design System Global
 * - Tabs
 * - Cards
 * - Acordeones
 * - Botones
 * - Modales
 * - Formularios
 * - Imagen/Recibos (zoom)
 *
 * Se aplica a:
 * - Estado General (Dashboard Presupuesto)
 * - Ingresos
 * - Gastos
 * - Listas, Recibos, etc. (cuando integremos)
 ****************************************************/

/* ==========
   PALETA BASE
   ========== */

:root {
  --otf-bg: #050816;
  --otf-bg-soft: #0b1020;
  --otf-bg-elevated: #141a2f;

  --otf-primary: #4f46e5;
  --otf-primary-soft: rgba(79, 70, 229, 0.12);
  --otf-primary-strong: #3730a3;

  --otf-accent: #f97316;
  --otf-accent-soft: rgba(249, 115, 22, 0.15);

  --otf-success: #22c55e;
  --otf-warning: #eab308;
  --otf-danger: #ef4444;

  --otf-border-subtle: rgba(148, 163, 184, 0.25);
  --otf-border-strong: rgba(148, 163, 184, 0.6);

  --otf-text-main: #e5e7eb;
  --otf-text-muted: #9ca3af;
  --otf-text-soft: #6b7280;

  --otf-radius-lg: 16px;
  --otf-radius-md: 12px;
  --otf-radius-pill: 999px;

  --otf-shadow-soft: 0 12px 30px rgba(15, 23, 42, 0.7);
  --otf-shadow-card: 0 10px 25px rgba(15, 23, 42, 0.6);

  --otf-transition-fast: 0.15s ease-out;
  --otf-transition: 0.2s ease-out;
}

/* ==========
   APP WRAPPER
   ========== */

#otf-presupuesto-app {
  color: var(--otf-text-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: radial-gradient(
      circle at top,
      rgba(79, 70, 229, 0.25),
      transparent 55%
    ),
    radial-gradient(
      circle at bottom,
      rgba(249, 115, 22, 0.18),
      transparent 50%
    ),
    var(--otf-bg);
  padding: 1.2rem 0.9rem 2.5rem;
  border-radius: 1.5rem;
  box-shadow: var(--otf-shadow-soft);
  position: relative;
  overflow: hidden;
}

/* peq. efecto de “border glow” interno */
#otf-presupuesto-app::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 1.5rem;
  border: 1px solid rgba(148, 163, 184, 0.15);
  pointer-events: none;
}

/* para contenedores internos reutilizables */
.otf-section {
  background: linear-gradient(
      135deg,
      rgba(15, 23, 42, 0.9),
      rgba(15, 23, 42, 0.98)
    );
  border-radius: 1.25rem;
  padding: 1.4rem 1.1rem;
  border: 1px solid var(--otf-border-subtle);
  box-shadow: var(--otf-shadow-card);
  margin-top: 0.85rem;
}

/* ==========
   TABS (Estado General / Ingresos / Gastos)
   ========== */

.otf-tabs-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  position: relative;
  margin-bottom: 1rem;
}

/* Botón individual de tab */
.otf-tab-btn {
  position: relative;
  z-index: 1;
  flex: 1;
  border: none;
  background: transparent;
  color: var(--otf-text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.6rem 0.2rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: color var(--otf-transition-fast);
}

/* iconito opcional dentro del tab */
.otf-tab-btn i,
.otf-tab-btn .otf-tab-icon {
  font-size: 1rem;
  opacity: 0.9;
}

/* Tab activa */
.otf-tab-btn.is-active {
  color: #f9fafb;
}

/* Indicador deslizante */
.otf-tab-indicator {
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 33%;
  border-radius: 999px;
  background: linear-gradient(
    135deg,
    rgba(79, 70, 229, 0.4),
    rgba(249, 115, 22, 0.4)
  );
  box-shadow: 0 0 18px rgba(129, 140, 248, 0.8);
  transition: transform var(--otf-transition);
}

/* Posiciones por data-index (0,1,2) */
.otf-tab-indicator[data-pos="0"] {
  transform: translateX(0%);
}
.otf-tab-indicator[data-pos="1"] {
  transform: translateX(100%);
}
.otf-tab-indicator[data-pos="2"] {
  transform: translateX(200%);
}

/* Hover */
.otf-tab-btn:hover {
  color: #e5e7eb;
}

/* ==========
   SUMMARY CARDS (Estado General, totales Ingresos/Gastos)
   ========== */

.otf-summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}

.otf-card {
  position: relative;
  border-radius: var(--otf-radius-lg);
  padding: 0.9rem 0.95rem;
  background: radial-gradient(
      circle at top right,
      rgba(79, 70, 229, 0.35),
      transparent 55%
    ),
    radial-gradient(
      circle at bottom left,
      rgba(15, 23, 42, 0.95),
      rgba(15, 23, 42, 1)
    );
  border: 1px solid rgba(148, 163, 184, 0.45);
  box-shadow: var(--otf-shadow-card);
  overflow: hidden;
}

/* destello suave */
.otf-card::after {
  content: "";
  position: absolute;
  inset: -30%;
  background: radial-gradient(
    circle at top,
    rgba(148, 163, 184, 0.07),
    transparent 60%
  );
  opacity: 0;
  transition: opacity var(--otf-transition);
  pointer-events: none;
}

.otf-card:hover::after {
  opacity: 1;
}

.otf-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.otf-card-title {
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--otf-text-soft);
}

.otf-card-tag {
  font-size: 0.65rem;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  color: var(--otf-text-muted);
  background: rgba(15, 23, 42, 0.8);
}

.otf-card-value-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.otf-card-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #f9fafb;
}

.otf-card-subvalue {
  font-size: 0.75rem;
  color: var(--otf-text-muted);
}

.otf-card-footnote {
  margin-top: 0.35rem;
  font-size: 0.7rem;
  color: var(--otf-text-soft);
}

/* variantes por tipo */
.otf-card--ingresos {
  border-color: rgba(34, 197, 94, 0.6);
}
.otf-card--gastos {
  border-color: rgba(248, 113, 113, 0.7);
}
.otf-card--ahorro {
  border-color: rgba(52, 211, 153, 0.7);
}

/* ==========
   TITULARES / SECCIONES
   ========== */

.otf-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.otf-section-title span {
  display: inline-flex;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, #4f46e5, #f97316);
  opacity: 0.75;
}

.otf-section-subtitle {
  font-size: 0.75rem;
  color: var(--otf-text-soft);
  margin-bottom: 0.6rem;
}

/* ==========
   LISTAS CON ACORDEÓN (Ingresos / Gastos / Subgastos / Pagos)
   ========== */

.otf-accordion {
  margin-top: 0.55rem;
  border-radius: var(--otf-radius-lg);
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.25);
  overflow: hidden;
}

/* item principal (Ingreso o Tema de Gasto) */
.otf-accordion-item {
  border-bottom: 1px solid rgba(31, 41, 55, 0.9);
}

.otf-accordion-item:last-child {
  border-bottom: none;
}

/* cabecera clickable */
.otf-accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.7rem 0.75rem;
  cursor: pointer;
  background: radial-gradient(
      circle at left,
      rgba(79, 70, 229, 0.12),
      transparent 65%
    ),
    rgba(15, 23, 42, 0.95);
  transition: background var(--otf-transition-fast);
}

.otf-accordion-header:hover {
  background: radial-gradient(
      circle at left,
      rgba(79, 70, 229, 0.18),
      transparent 55%
    ),
    rgba(15, 23, 42, 1);
}

.otf-acc-main {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.otf-acc-title {
  font-size: 0.9rem;
  font-weight: 500;
}

.otf-acc-meta {
  font-size: 0.7rem;
  color: var(--otf-text-soft);
}

/* totales/resumen a la derecha de la cabecera */
.otf-acc-right {
  text-align: right;
  font-size: 0.75rem;
}

.otf-acc-right strong {
  display: block;
  font-size: 0.85rem;
}

/* icono de flecha acordeón */
.otf-acc-arrow {
  margin-left: 0.4rem;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--otf-text-muted);
  transition: transform var(--otf-transition-fast),
    background var(--otf-transition-fast),
    color var(--otf-transition-fast);
}

.otf-accordion-item.is-open .otf-acc-arrow {
  transform: rotate(90deg);
  background: rgba(79, 70, 229, 0.9);
  color: #f9fafb;
}

/* cuerpo */
.otf-accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease-out;
  background: rgba(15, 23, 42, 0.98);
}

/* cuando esté abierto se pondrá altura auto vía JS con contentHeight */
.otf-accordion-body-inner {
  padding: 0.55rem 0.8rem 0.7rem;
  border-top: 1px dashed rgba(55, 65, 81, 0.9);
}

/* listado interno (subgastos/pagos) */
.otf-sublist {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.otf-subitem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: 0.75rem;
  background: radial-gradient(
      circle at left,
      rgba(148, 163, 184, 0.12),
      transparent 70%
    ),
    rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(55, 65, 81, 0.9);
}

.otf-subitem-main {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  font-size: 0.8rem;
}

.otf-subitem-meta {
  font-size: 0.7rem;
  color: var(--otf-text-soft);
}

.otf-subitem-amount {
  text-align: right;
  font-size: 0.8rem;
}

/* badges de estado */
.otf-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.65rem;
  border: 1px solid transparent;
}

.otf-badge-pill {
  border-radius: 999px;
}

.otf-badge-success {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.35);
  color: #bbf7d0;
}

.otf-badge-warning {
  background: rgba(234, 179, 8, 0.2);
  border-color: rgba(234, 179, 8, 0.5);
  color: #fef08a;
}

.otf-badge-danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fecaca;
}

/* ==========
   BOTONES
   ========== */

.otf-btn {
  border-radius: var(--otf-radius-pill);
  padding: 0.45rem 0.9rem;
  border: none;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: background var(--otf-transition), transform 0.1s ease-out,
    box-shadow var(--otf-transition);
  white-space: nowrap;
}

.otf-btn:active {
  transform: scale(0.97);
}

/* colores */
.otf-btn-primary {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #f9fafb;
  box-shadow: 0 7px 18px rgba(79, 70, 229, 0.45);
}

.otf-btn-primary:hover {
  background: linear-gradient(135deg, #4338ca, #4f46e5);
}

.otf-btn-outline {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.7);
  color: var(--otf-text-main);
}

.otf-btn-outline:hover {
  background: rgba(30, 64, 175, 0.25);
}

.otf-btn-danger {
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: #fef2f2;
}

.otf-btn-ghost {
  background: transparent;
  border: 1px dashed rgba(148, 163, 184, 0.7);
  color: var(--otf-text-muted);
}

.otf-btn-icon {
  border-radius: 999px;
  padding: 0.3rem;
  width: 28px;
  height: 28px;
}

/* contenedor botón flotante arriba-derecha de las secciones */
.otf-section-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-bottom: 0.45rem;
}

/* ==========
   FORMULARIOS (Modales)
   ========== */

.otf-field {
  margin-bottom: 0.65rem;
}

.otf-field label {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--otf-text-soft);
  margin-bottom: 0.2rem;
}

.otf-input,
.otf-select,
.otf-textarea {
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.95);
  color: var(--otf-text-main);
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  transition: border-color var(--otf-transition-fast),
    box-shadow var(--otf-transition-fast),
    background var(--otf-transition-fast);
}

.otf-input:focus,
.otf-select:focus,
.otf-textarea:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.4);
  background: rgba(15, 23, 42, 1);
}

.otf-textarea {
  min-height: 70px;
  resize: vertical;
}

/* inline fields */
.otf-fields-row {
  display: flex;
  gap: 0.6rem;
}

.otf-fields-row .otf-field {
  flex: 1;
}

/* ayuda / hint */
.otf-field-hint {
  font-size: 0.7rem;
  color: var(--otf-text-soft);
  margin-top: 0.15rem;
}

/* ==========
   MODALES
   ========== */

.otf-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.otf-modal-backdrop.is-open {
  display: flex;
}

.otf-modal {
  width: 100%;
  max-width: 420px;
  background: radial-gradient(
      circle at top,
      rgba(79, 70, 229, 0.3),
      transparent 60%
    ),
    rgba(15, 23, 42, 0.98);
  border-radius: 1.25rem;
  border: 1px solid rgba(148, 163, 184, 0.6);
  box-shadow: 0 15px 35px rgba(15, 23, 42, 0.75);
  padding: 1rem 0.9rem 0.85rem;
  position: relative;
}

.otf-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.otf-modal-title {
  font-size: 0.9rem;
  font-weight: 600;
}

.otf-modal-body {
  max-height: 65vh;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.otf-modal-footer {
  margin-top: 0.65rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* botón cerrar modal */
.otf-modal-close {
  border-radius: 999px;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: rgba(15, 23, 42, 0.95);
  color: var(--otf-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  cursor: pointer;
}

/* ==========
   RECIBOS / IMÁGENES (thumb + zoom)
   ========== */

.otf-receipt-thumb {
  margin-top: 0.25rem;
  display: inline-flex;
  flex-direction: column;
  gap: 0.2rem;
  cursor: zoom-in;
}

.otf-receipt-thumb img {
  max-width: 120px;
  max-height: 90px;
  border-radius: 0.7rem;
  border: 1px solid rgba(148, 163, 184, 0.7);
  object-fit: cover;
  transition: transform var(--otf-transition), box-shadow var(--otf-transition);
}

.otf-receipt-thumb img:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.8);
}

/* Modal de zoom de recibo */
.otf-receipt-zoom-img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.8);
  object-fit: contain;
}

/* ==========
   VARIOS PEQUEÑOS
   ========== */

.otf-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  font-size: 0.7rem;
  color: var(--otf-text-muted);
  background: rgba(15, 23, 42, 0.9);
}

.otf-chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--otf-success);
}

/* inputs pequeños tipo checkbox + label */
.otf-inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--otf-text-soft);
}

/* ==========
   RESPONSIVE
   ========== */

@media (min-width: 640px) {
  #otf-presupuesto-app {
    padding: 1.5rem 1.3rem 2.5rem;
  }

  .otf-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .otf-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .otf-section {
    padding: 1.6rem 1.3rem;
  }
}
