/* 
 * Control de Gastos - Mobile First CSS
 * Bootstrap 5 + Custom Styles
 */

:root {
  /* Colores principales */
  --primary: #00dba8;
  --secondary: #00c29a;
  --success: #27ae60;
  --danger: #e74c3c;
  --warning: #f39c12;
  --info: #17a2b8;
  
  /* Fondos */
  --bg-light: #f8f9fa;
  --bg-card: #ffffff;
  --bg-gradient: linear-gradient(135deg, #00dba8 0%, #26d0ce 50%, #00b894 100%);
  
  /* Texto */
  --text-dark: #2c3e50;
  --text-muted: #6c757d;
  
  /* Mobile-first */
  --mobile-safe: #ffffff;
  --touch-target: 48px;
  --border-radius: 12px;
  
  /* Sombras */
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
  --shadow-lg: 0 8px 25px rgba(0,0,0,0.2);
}

/* BODY Y LAYOUT GENERAL */
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-light);
  color: var(--text-dark);
  line-height: 1.6;
  padding-bottom: 80px; /* Espacio para bottom navigation */
}

.container-fluid {
  padding: 0 15px;
}

/* HEADER */
.app-header {
  background: var(--bg-gradient);
  color: white;
  padding: 20px 0;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
}

.app-header h1 {
  font-weight: 700;
  font-size: 1.5rem;
  margin: 0;
  text-align: center;
}

.app-header .subtitle {
  text-align: center;
  opacity: 0.9;
  font-size: 0.9rem;
  margin-top: 5px;
}

/* CARDS MOBILE-FIRST */
.card {
  border: none;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  background: var(--bg-card);
}

.card-header {
  background: #666666;
  color: white;
  border-radius: var(--border-radius) var(--border-radius) 0 0 !important;
  padding: 15px 20px;
  border: none;
}

.card-header h5 {
  margin: 0;
  font-weight: 600;
  font-size: 1.1rem;
}

.card-body {
  padding: 20px;
}

/* FORMULARIOS MOBILE-OPTIMIZED */
.form-control, .form-select {
  min-height: var(--touch-target);
  border-radius: 8px;
  border: 2px solid #e9ecef;
  font-size: 16px; /* Evita zoom en iOS */
  padding: 12px 16px;
  transition: all 0.3s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

.form-label {
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: 20px;
}

/* BOTONES TOUCH-FRIENDLY */
.btn {
  min-height: var(--touch-target);
  border-radius: 8px;
  font-weight: 600;
  padding: 12px 24px;
  font-size: 16px;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, #00dba8 0%, #26d0ce 50%, #00b894 100%);
  border-color: var(--primary);
  border: none;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #00c29a 0%, #1ac7c4 50%, #009a7b 100%);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 219, 168, 0.3);
}

.btn-success {
  background: var(--success);
  border-color: var(--success);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
}

.btn-lg {
  padding: 16px 32px;
  font-size: 18px;
  min-height: 56px;
}

/* BOTTOM NAVIGATION */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #dee2e6;
  padding: 10px 0;
  z-index: 1000;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.bottom-nav .nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.bottom-nav .nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-muted);
  padding: 8px;
  border-radius: 8px;
  transition: all 0.3s ease;
  min-width: 60px;
}

.bottom-nav .nav-link:hover,
.bottom-nav .nav-link.active {
  color: var(--primary);
  background: rgba(44, 62, 80, 0.1);
}

.bottom-nav .nav-link i {
  font-size: 1.2rem;
  margin-bottom: 4px;
}

.bottom-nav .nav-link span {
  font-size: 0.75rem;
  font-weight: 500;
}

/* DASHBOARD ESPECÍFICO - FASE 2 */
.dashboard-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: all 0.3s ease;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.dashboard-card.total {
    background: var(--bg-gradient);
    color: white;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.dashboard-card.total::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="75" cy="75" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="50" cy="10" r="0.5" fill="rgba(255,255,255,0.1)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    pointer-events: none;
}

.dashboard-card .stat-item {
    position: relative;
    z-index: 1;
}

.dashboard-card .amount {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 10px 0 5px 0;
    line-height: 1;
}

.dashboard-card .label {
    font-size: 0.9rem;
    opacity: 0.9;
    font-weight: 500;
}

.dashboard-card .sublabel {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 2px;
}

.dashboard-card .count {
    font-size: 0.8rem;
    margin-top: 5px;
    opacity: 0.7;
}

/* GRÁFICOS RESPONSIVE */
.chart-container {
    position: relative;
    height: 300px;
    margin: 20px 0;
}

.chart-container canvas {
    max-height: 100% !important;
}

@media (max-width: 576px) {
    .chart-container {
        height: 250px;
        margin: 15px 0;
    }
    
    .dashboard-card .amount {
        font-size: 1.8rem;
    }
    
    .dashboard-card {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .chart-container {
        height: 280px;
    }
}

/* ESTADÍSTICAS Y MÉTRICAS */
.stat-box {
    padding: 15px;
    background: rgba(52, 152, 219, 0.05);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.stat-box:hover {
    background: rgba(52, 152, 219, 0.1);
    transform: translateY(-1px);
}

.stat-number {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* TOP GASTOS */
.ranking-number {
    min-width: 35px;
}

.ranking-number .badge {
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
}

/* ACTIVIDAD RECIENTE */
.gasto-item-mini {
    transition: background-color 0.2s ease;
    min-height: 80px;
    display: flex;
    align-items: center;
}

.gasto-item-mini:hover {
    background-color: rgba(52, 152, 219, 0.05);
}

.gasto-item-mini .detalle {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 150px;
}

/* ACCIONES RÁPIDAS MEJORADAS */
.action-card {
    transition: all 0.3s ease;
    border-radius: 12px;
    min-height: 100px;
    position: relative;
    overflow: hidden;
}

.action-card::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 0.5s ease;
}

.action-card:hover::before {
    left: 100%;
}

.action-card:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-lg);
}

.action-card i {
    transition: transform 0.3s ease;
}

.action-card:hover i {
    transform: scale(1.1);
}

/* PROGRESS BAR PERSONALIZADA */
.progress {
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    border-radius: 10px;
    transition: width 1s ease-in-out;
}

/* BOTONES DE GRÁFICO */
.btn-group .btn {
    border-radius: 6px !important;
    margin: 0 1px;
}

.btn-group .btn.active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 2px 4px rgba(44, 62, 80, 0.3);
}

/* ANIMACIONES ESPECÍFICAS */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.fade-in {
    animation: slideInUp 0.6s ease-out;
}

.scale-in {
    animation: fadeInScale 0.5s ease-out;
}

/* FLOATING ACTION MEJORADO */
.floating-action {
    position: fixed;
    bottom: 90px;
    right: 20px;
    z-index: 1000;
}

.floating-action .btn {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(52, 152, 219, 0.4);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.floating-action .btn:hover {
    animation: none;
    transform: scale(1.1);
}

/* RESPONSIVE GRID MEJORADO */
@media (max-width: 576px) {
    .dashboard-cards {
        display: grid;
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-number {
        font-size: 1.2rem;
    }
    
    .chart-container {
        height: 220px;
    }
    
    .action-card {
        min-height: 80px;
    }
    
    .gasto-item-mini .detalle {
        max-width: 100px;
    }
}

@media (min-width: 768px) {
    .dashboard-cards {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 20px;
    }
    
    .floating-action {
        display: none;
    }
}

@media (min-width: 992px) {
    .chart-container {
        height: 320px;
    }
    
    .dashboard-card .amount {
        font-size: 2.5rem;
    }
}

/* MODO OSCURO (preparación futura) */
@media (prefers-color-scheme: dark) {
    .dashboard-card {
        background: #2c3e50;
        color: white;
    }
    
    .stat-box {
        background: rgba(255,255,255,0.1);
    }
    
    .gasto-item-mini:hover {
        background-color: rgba(255,255,255,0.05);
    }
}

/* TOOLTIPS PERSONALIZADOS */
[data-bs-toggle="tooltip"] {
    cursor: help;
}

/* LOADING STATES */
.loading-chart {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    background: linear-gradient(45deg, #f8f9fa, #e9ecef, #f8f9fa);
    background-size: 400% 400%;
    animation: gradient 3s ease infinite;
    border-radius: var(--border-radius);
}

@keyframes gradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* EFECTOS ESPECIALES */
.sparkle {
    position: relative;
    overflow: hidden;
}

.sparkle::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,215,0,0.4), transparent);
    animation: sparkle 3s ease-in-out infinite;
}

@keyframes sparkle {
    0% { left: -100%; }
    50% { left: 100%; }
    100% { left: 100%; }
}/* TIPO DE GASTO CARDS */
.tipo-card {
  border-left: 4px solid;
  transition: transform 0.3s ease;
}

.tipo-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* LISTA DE GASTOS */
.gasto-item {
  border-left: 4px solid;
  padding: 15px;
  margin-bottom: 10px;
  background: white;
  border-radius: 0 8px 8px 0;
  box-shadow: var(--shadow-sm);
}

.gasto-item .fecha {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.gasto-item .detalle {
  font-weight: 600;
  margin: 5px 0;
}

.gasto-item .importe {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

.gasto-item .tipo {
  font-size: 0.8rem;
  background: rgba(0,0,0,0.1);
  padding: 2px 8px;
  border-radius: 12px;
  display: inline-block;
}

/* ALERTAS */
.alert {
  border: none;
  border-radius: 8px;
  margin-bottom: 20px;
}

.alert i {
  margin-right: 8px;
}

/* ESTADOS VACÍOS */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 20px;
  opacity: 0.5;
}

.empty-state h5 {
  margin-bottom: 10px;
}

.empty-state p {
  margin-bottom: 20px;
}

/* LOADING */
.loading {
  text-align: center;
  padding: 40px 20px;
}

.spinner-border {
  color: var(--primary);
}

/* RESPONSIVE ADJUSTMENTS */
@media (max-width: 576px) {
  .container-fluid {
    padding: 0 10px;
  }
  
  .card-body {
    padding: 15px;
  }
  
  .app-header {
    padding: 15px 0;
  }
  
  .app-header h1 {
    font-size: 1.3rem;
  }
  
  .dashboard-card .amount {
    font-size: 1.7rem;
  }
  
  .btn {
    width: 100%;
    margin-bottom: 10px;
  }
}

@media (min-width: 768px) {
  body {
    padding-bottom: 0;
  }
  
  .bottom-nav {
    display: none;
  }
  
  .desktop-nav {
    display: block !important;
  }
  
  .dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
  }
  
  .btn {
    width: auto;
    display: inline-flex;
  }
}

/* UTILIDADES */
.text-currency {
  font-family: 'Courier New', monospace;
  font-weight: 600;
}

.bg-pattern {
  background: linear-gradient(135deg, #00dba8 0%, #26d0ce 50%, #00b894 100%);
  background-image: 
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.15) 1px, transparent 0);
  background-size: 20px 20px;
}

/* Clase para gradiente turquesa */
.bg-gradient-turquoise {
  background: linear-gradient(135deg, #00dba8 0%, #26d0ce 50%, #00b894 100%) !important;
}

/* Override Bootstrap bg-primary con gradiente */
.bg-primary {
  background: linear-gradient(135deg, #00dba8 0%, #26d0ce 50%, #00b894 100%) !important;
}

/* Estilos específicos para botones de tipo de gráfico */
.btn-outline-primary {
  color: white !important;
  border-color: white !important;
  background-color: transparent !important;
}

.btn-outline-primary:hover {
  color: white !important;
  background-color: rgba(255, 255, 255, 0.1) !important;
  border-color: white !important;
}

.btn-outline-primary.active {
  color: white !important;
  background-color: rgba(255, 255, 255, 0.2) !important;
  border-color: white !important;
}

.btn-outline-primary:focus {
  color: white !important;
  background-color: rgba(255, 255, 255, 0.1) !important;
  border-color: white !important;
  box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25) !important;
}

/* Override específico para botones de tipo de gráfico - Dashboard */
.chart-type-buttons .btn-outline-primary {
  color: #6c757d !important;
  border-color: #dee2e6 !important;
  background-color: white !important;
}

.chart-type-buttons .btn-outline-primary:hover {
  color: #00dba8 !important;
  background-color: rgba(0, 219, 168, 0.1) !important;
  border-color: #00dba8 !important;
}

.chart-type-buttons .btn-outline-primary.active,
.chart-type-buttons .btn-outline-primary.active:hover,
.chart-type-buttons .btn-outline-primary.active:focus {
  color: white !important;
  background: linear-gradient(135deg, #00dba8 0%, #26d0ce 50%, #00b894 100%) !important;
  border-color: #00dba8 !important;
  box-shadow: 0 2px 8px rgba(0, 219, 168, 0.3) !important;
}

/* Botones de PDF con color rosa personalizado */
.btn-success {
  background: linear-gradient(135deg, #ff49dd 0%, #e91e63 50%, #ad1457 100%) !important;
  border: none !important;
  color: white !important;
}

.btn-success:hover {
  background: #e640c7 !important;
  border-color: #e640c7 !important;
  color: white !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 73, 221, 0.3) !important;
}

.btn-success:focus {
  background: #e640c7 !important;
  border-color: #e640c7 !important;
  color: white !important;
  box-shadow: 0 0 0 0.2rem rgba(255, 73, 221, 0.25) !important;
}

.btn-success:active {
  background: #d137b4 !important;
  border-color: #d137b4 !important;
  color: white !important;
}

.fade-in {
  animation: fadeIn 0.5s ease-in;
}

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

/* OVERRIDE ESPECÍFICO PARA BOTONES DE GRÁFICO - PRIORIDAD MÁXIMA */
.card .chart-type-buttons .btn-outline-primary.btn-sm {
  color: #6c757d !important;
  border-color: #dee2e6 !important;
  background-color: white !important;
}

.card .chart-type-buttons .btn-outline-primary.btn-sm:hover {
  color: #00dba8 !important;
  background-color: rgba(0, 219, 168, 0.1) !important;
  border-color: #00dba8 !important;
}

.card .chart-type-buttons .btn-outline-primary.btn-sm.active,
.card .chart-type-buttons .btn-outline-primary.active,
.card .chart-type-buttons .btn.btn-outline-primary.active {
  color: white !important;
  background: linear-gradient(135deg, #00dba8 0%, #26d0ce 50%, #00b894 100%) !important;
  border-color: #00dba8 !important;
  box-shadow: 0 2px 8px rgba(0, 219, 168, 0.3) !important;
}

/* PRINT STYLES */
@media print {
  .bottom-nav,
  .desktop-nav,
  .btn,
  .alert {
    display: none !important;
  }
  
  body {
    background: white;
    padding: 0;
  }
  
  .card {
    box-shadow: none;
    border: 1px solid #dee2e6;
  }
}