/* ===== VARIABLES CSS ===== */
:root {
  --primary-color: #18224C;
  --primary-light: #2a3660;
  --primary-dark: #0f1a3a;
  --secondary-color: #f8f9fa;
  --accent-color: #007bff;
  --success-color: #28a745;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
  --text-dark: #333333;
  --text-light: #666666;
  --border-color: #e9ecef;
  --shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* ===== FUENTE BASE ===== */
* {
  font-family: 'Poppins', sans-serif;
}

body {
  background-color: #f8f9fa;
  color: var(--text-dark);
  font-weight: 400;
}

/* ===== COLORES BOOTSTRAP PERSONALIZADOS ===== */
.bg-primary {
  background-color: var(--primary-color) !important;
}

.text-primary {
  color: var(--primary-color) !important;
}

.btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  font-weight: 300;
}

.btn-primary:hover {
  background-color: var(--primary-light);
  border-color: var(--primary-light);
}

.btn-primary:focus, .btn-primary.focus {
  box-shadow: 0 0 0 0.2rem rgba(24, 34, 76, 0.25);
}

/* ===== NAVBAR ===== */
.navbar {
  background-color: var(--primary-color) !important;
  box-shadow: var(--shadow);
  padding: 0.75rem 1rem;
}

.navbar-brand {
  font-weight: 600;
  color: white !important;
}

.navbar-nav .nav-link {
  color: rgba(255, 255, 255, 0.9) !important;
  font-weight: 300;
  transition: color 0.3s ease;
}

.navbar-nav .nav-link:hover {
  color: white !important;
}

.navbar-toggler {
  border-color: rgba(255, 255, 255, 0.3);
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: 56px;
  bottom: 0;
  left: 0;
  z-index: 100;
  padding: 1rem 0;
  background-color: var(--primary-color) !important;
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.sidebar .nav-link {
  color: rgba(255, 255, 255, 0.8);
  font-weight: 300;
  padding: 0.75rem 1rem;
  border-radius: 0;
  transition: all 0.3s ease;
}

.sidebar .nav-link:hover {
  color: white;
  background-color: var(--primary-light);
}

.sidebar .nav-link.active {
  color: white;
  background-color: var(--primary-light);
  font-weight: 500;
}

.sidebar .nav-link i {
  margin-right: 0.5rem;
  width: 1.2rem;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-top: 56px;
  padding-top: 1.5rem;
}

.content-wrapper {
  min-height: calc(100vh - 120px);
}

/* ===== CARDS ===== */
.card {
  border: none;
  box-shadow: var(--shadow);
  border-radius: 0.5rem;
  transition: box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-header {
  background-color: var(--secondary-color);
  border-bottom: 1px solid var(--border-color);
  font-weight: 500;
  color: var(--primary-color);
}

/* ===== TABLES ===== */
.table {
  font-size: 0.9rem;
}

.table th {
  background-color: var(--primary-color);
  color: white;
  font-weight: 500;
  border: none;
  padding: 0.75rem;
}

.table td {
  padding: 0.75rem;
  vertical-align: middle;
  border-top: 1px solid var(--border-color);
}

.table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(24, 34, 76, 0.02);
}

.table-hover tbody tr:hover {
  background-color: rgba(24, 34, 76, 0.05);
}

/* ===== RESPONSIVE TABLES ===== */
@media (max-width: 768px) {
  .table-responsive-stack tr {
    display: block;
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
    border-radius: 0.5rem;
  }
  
  .table-responsive-stack td {
    display: block;
    text-align: right;
    border: none;
    padding: 0.5rem;
  }
  
  .table-responsive-stack td:before {
    content: attr(data-label) ": ";
    float: left;
    font-weight: 500;
    color: var(--primary-color);
  }
}

/* ===== FORMS ===== */
.form-control {
  border-radius: 0.375rem;
  border: 1px solid var(--border-color);
  font-weight: 300;
}

.form-control:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(24, 34, 76, 0.25);
}

.form-label {
  font-weight: 500;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

/* ===== BUTTONS ===== */
.btn {
  font-weight: 300;
  border-radius: 0.375rem;
  padding: 0.5rem 1rem;
  transition: all 0.3s ease;
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1.125rem;
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
  background-color: transparent;
  padding: 0;
  margin-bottom: 1rem;
}

.breadcrumb-item a {
  color: var(--primary-color);
  text-decoration: none;
}

.breadcrumb-item.active {
  color: var(--text-light);
}

/* ===== ALERTS ===== */
.alert {
  border: none;
  border-radius: 0.5rem;
  font-weight: 300;
}

.alert-dismissible .btn-close {
  padding: 0.75rem 1rem;
  top: 7px;
}

/* ===== AUTH PAGES ===== */
.auth-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: white;
  border-radius: 1rem;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-width: 400px;
  width: 100%;
}

.auth-header {
  background-color: var(--primary-color);
  color: white;
  padding: 2rem;
  text-align: center;
}

.auth-body {
  padding: 2rem;
}

.auth-logo {
  max-width: 120px;
  height: auto;
  margin-bottom: 1rem;
}

/* ===== DASHBOARD STATS ===== */
.stat-card {
  background: white;
  border-radius: 0.5rem;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease;
}

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

.stat-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: white;
  margin-bottom: 1rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.stat-label {
  color: var(--text-light);
  font-size: 0.875rem;
  font-weight: 300;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar {
    margin-left: -100%;
    transition: margin-left 0.3s ease;
  }
  
  .sidebar.show {
    margin-left: 0;
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .navbar-brand {
    font-size: 1rem;
  }
  
  /* Mobile optimizations */
  .stat-card {
    margin-bottom: 1rem;
  }
  
  .btn-toolbar {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .btn-group {
    width: 100%;
  }
  
  .card-header h5 {
    font-size: 1rem;
  }
  
  /* Hide some columns on mobile */
  .table-responsive .d-none-mobile {
    display: none !important;
  }
  
  /* Stack form controls on mobile */
  .row.g-3 > .col-md-3,
  .row.g-3 > .col-md-4,
  .row.g-3 > .col-md-6 {
    margin-bottom: 1rem;
  }
}

@media (max-width: 576px) {
  .main-content {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  
  .stat-value {
    font-size: 1.5rem;
  }
  
  .btn-group-sm .btn {
    padding: 0.25rem 0.4rem;
    font-size: 0.75rem;
  }
}

/* ===== UTILITIES ===== */
.text-muted-light {
  color: var(--text-light) !important;
}

.bg-light-primary {
  background-color: rgba(24, 34, 76, 0.1) !important;
}

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

.shadow-sm {
  box-shadow: var(--shadow) !important;
}

.shadow-lg {
  box-shadow: var(--shadow-lg) !important;
}

/* ===== LOADING SPINNER ===== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

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

/* ===== GUIDE TOUR STYLES ===== */
.tour-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9998;
}

.tour-highlight {
  position: relative;
  z-index: 9999;
  box-shadow: 0 0 0 4px var(--primary-color), 0 0 0 8px rgba(24, 34, 76, 0.3);
  border-radius: 0.375rem;
}

.tour-tooltip {
  position: absolute;
  background: white;
  border: 2px solid var(--primary-color);
  border-radius: 0.5rem;
  padding: 1rem;
  max-width: 300px;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
}

.tour-tooltip::before {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
}

.tour-tooltip.top::before {
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 10px 10px 0 10px;
  border-color: var(--primary-color) transparent transparent transparent;
}

.tour-tooltip.bottom::before {
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 0 10px 10px 10px;
  border-color: transparent transparent var(--primary-color) transparent;
}

.tour-tooltip.left::before {
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 10px 0 10px 10px;
  border-color: transparent transparent transparent var(--primary-color);
}

.tour-tooltip.right::before {
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 10px 10px 10px 0;
  border-color: transparent var(--primary-color) transparent transparent;
}

.tour-tooltip h6 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.tour-tooltip p {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  line-height: 1.4;
}

.tour-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.tour-progress {
  font-size: 0.8rem;
  color: var(--text-light);
}

.tour-buttons {
  display: flex;
  gap: 0.5rem;
}

.tour-btn {
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  border-radius: 0.25rem;
  border: 1px solid var(--primary-color);
  background: white;
  color: var(--primary-color);
  cursor: pointer;
  transition: all 0.3s ease;
}

.tour-btn:hover {
  background: var(--primary-color);
  color: white;
}

.tour-btn.primary {
  background: var(--primary-color);
  color: white;
}

.tour-btn.primary:hover {
  background: var(--primary-light);
}

/* Tour step indicators */
.tour-step-indicator {
  position: fixed;
  top: 20px;
  right: 20px;
  background: white;
  border: 2px solid var(--primary-color);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--primary-color);
  z-index: 10001;
  box-shadow: var(--shadow-lg);
}


/* ===== LAYOUT STYLES ===== */
/* Sidebar fijo desde arriba */
.sidebar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  height: 100vh !important;
  overflow-y: auto !important;
  z-index: 1000 !important;
  padding-top: 1rem !important;
}

/* Ancho del sidebar responsive */
@media (min-width: 992px) {
  .sidebar {
    width: 16.666667% !important; /* LG: 2/12 columnas */
  }
}

@media (max-width: 991.98px) {
  .sidebar {
    width: 25% !important; /* MD: 3/12 columnas */
  }
}

@media (max-width: 767.98px) {
  .sidebar {
    width: 250px !important; /* Ancho fijo en móvil */
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  
  .sidebar.show {
    transform: translateX(0);
  }
}

/* Navbar fijo arriba derecha */
.navbar-container {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1020;
}

@media (min-width: 992px) {
  .navbar-container {
    width: calc(100% - 16.666667%); /* LG: resto después del sidebar */
    left: 16.666667%;
  }
}

@media (max-width: 991.98px) {
  .navbar-container {
    width: calc(100% - 25%); /* MD: resto después del sidebar */
    left: 25%;
  }
}

@media (max-width: 767.98px) {
  .navbar-container {
    width: 100%;
    left: 0;
  }
}

.navbar-right {
  position: relative;
  width: 100%;
}

/* Main content con margen correcto */
.main-content {
  margin-top: 60px !important;
  padding: 20px !important;
}

@media (min-width: 992px) {
  .main-content {
    margin-left: 16.666667% !important; /* LG: sidebar 2/12 */
  }
}

@media (max-width: 991.98px) {
  .main-content {
    margin-left: 25% !important; /* MD: sidebar 3/12 */
  }
}

@media (max-width: 767.98px) {
  .main-content {
    margin-left: 0 !important; /* Sin margen en móvil */
  }
}

.sidebar-logo img {
  max-height: 120px;
  width: auto;
}

/* ===== DASHBOARD CHARTS STYLES ===== */
#cashFlowChart, #categoryChart, #budgetChart {
  max-height: 300px !important;
  height: 300px !important;
}

.card-body canvas {
  width: 100% !important;
  max-height: 300px !important;
}

/* Botones de categoría */
.btn-group .btn {
  transition: all 0.3s ease;
}

.btn-group .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* ===== BUDGET DISTRIBUTION CALENDAR STYLES ===== */
.calendar-grid {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.calendar-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  margin-bottom: 1px;
}

.calendar-day-header {
  padding: 8px 4px;
  text-align: center;
  font-weight: 600;
  background-color: var(--primary-color);
  color: white;
  font-size: 0.875rem;
}

.calendar-body {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background-color: #dee2e6;
}

.calendar-day {
  background-color: white;
  min-height: 120px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.calendar-day.empty {
  background-color: #f8f9fa;
  min-height: 60px;
}

.calendar-day.weekend {
  background-color: #f8f9fa;
}

.calendar-day.weekday {
  background-color: white;
}

.day-number {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 4px;
  text-align: center;
  color: var(--primary-color);
}

.calendar-day.weekend .day-number {
  color: #6c757d;
}

.day-inputs {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.day-inputs input {
  font-size: 0.75rem;
  padding: 2px 4px;
  height: auto;
}

/* Responsive calendar */
@media (max-width: 768px) {
  .calendar-day {
    min-height: 80px;
  }
  
  .day-inputs input {
    font-size: 0.7rem;
    padding: 1px 2px;
  }
  
  .calendar-day-header {
    padding: 6px 2px;
    font-size: 0.75rem;
  }
}

@media (max-width: 576px) {
  .calendar-day {
    min-height: 60px;
  }
  
  .day-number {
    font-size: 0.75rem;
    margin-bottom: 2px;
  }
}
