/* Estilos básicos unificados para toda la aplicación */
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ====== HEADER BÁSICO ====== */
.header-basico {
  background: #ffffff !important;
  border-bottom: 1px solid #dee2e6;
  margin: 0;
  position: relative;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.avatar-header {
  width: 50px;
  height: 50px;
  background: #f8f9fa;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #dee2e6;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.header-info {
  opacity: 1;
  transition: opacity 0.2s ease;
}

.header-info .badge {
  background: #e9ecef !important;
  color: #495057 !important;
  border: 1px solid #dee2e6;
}

/* Componentes del header */
.notification-badge {
  font-size: 0.75em;
}

.notifications-dropdown {
  min-width: 300px;
  max-width: min(92vw, 420px);
  max-height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
}

.notifications-dropdown .dropdown-item {
  white-space: normal;
}

.user-avatar {
  width: 32px;
  height: 32px;
  object-fit: cover;
}

.user-dropdown {
  min-width: 200px;
}

/* ====== BOTONES BÁSICOS ====== */
.btn-basico {
  background: #ffffff;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  padding: 8px 12px;
  font-weight: 500;
  transition: all 0.2s ease-in-out;
  color: #495057;
}

.btn-basico:hover {
  background: #f8f9fa;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  color: #495057;
}

/* ====== CARDS BÁSICOS ====== */
.card {
  border-radius: 0.75rem;
  transition: transform 0.2s ease-in-out;
}

.card:hover {
  transform: translateY(-1px);
}

/* ====== BADGES ====== */
.badge {
  font-size: 0.75rem;
}

/* ====== ICONOS ====== */
.h3 .bi {
  margin-right: 0.5rem;
}

.small i {
  width: 16px;
  text-align: center;
  opacity: 0.7;
}

/* ====== NAV PILLS ====== */
.nav-pills .nav-link {
  border-radius: 0.5rem;
  transition: all 0.2s ease-in-out;
}

.nav-pills .nav-link:hover {
  transform: translateY(-1px);
}

.nav-pills .nav-link.active {
  background-color: #0d6efd;
}

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

.table th {
  font-weight: 600;
  border-top: none;
}

.table td {
  vertical-align: middle;
}

/* ====== DROPDOWNS ====== */
.user-dropdown-menu {
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  overflow: hidden;
  margin-top: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.user-dropdown-menu .dropdown-item {
  padding: 12px 16px;
  transition: all 0.2s ease;
  color: #495057;
  border-radius: 0.375rem;
  margin: 2px;
}

.user-dropdown-menu .dropdown-item i {
  width: 20px;
  text-align: center;
  margin-right: 8px;
  opacity: 0.7;
}

/* Estilos para dropdowns toggle */
.dropdown-toggle::after {
  transition: transform 0.2s;
}

.dropdown-toggle[aria-expanded="true"]::after {
  transform: rotate(180deg);
}

.hover-light:hover {
  background: #f8f9fa;
  border-left: 3px solid #0d6efd;
  color: #2c3e50;
}

.hover-danger:hover {
  background: #f8d7da;
  border-left: 3px solid #dc3545;
  color: #721c24;
}

/* ====== NOTIFICACIONES ====== */
.animate-pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(220, 53, 69, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
  }
}

.notification-item {
  transition: background-color 0.2s ease, color 0.2s ease;
  border-radius: 0.375rem;
  margin: 4px 0;
  color: #2c3e50;
  overflow-wrap: anywhere;
}

.notification-item:hover {
  background: transparent;
  transform: none !important;
}

.notification-item .notification-message {
  display: block;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.notification-item strong {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* ====== SIDEBAR ====== */
.sidebar {
  width: 250px;
  min-height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar .nav-link {
  border-radius: .5rem;
  padding: .5rem .75rem;
  border-left: 3px solid transparent;
}

.sidebar .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-left-color: #ffc107;
}

.sidebar .nav-link:active,
.sidebar .nav-link.active {
  background-color: rgba(255, 255, 255, 0.15);
  border-left-color: #ffc107;
}

.sidebar .nav-heading {
  letter-spacing: .04em;
}

/* Header del sidebar */
.sidebar-header {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #6c757d;
  text-align: center;
}

.sidebar-fire-icon {
  font-size: 2rem;
}

.sidebar-subtitle {
  font-size: 0.75rem;
}

.sidebar-group-title {
  font-size: 0.7rem;
  letter-spacing: 0.5px;
  color: #adb5bd;
}

.sidebar-nav-link {
  transition: all 0.2s;
}

.sidebar-nav-icon {
  width: 18px;
}

.sidebar-nav-text {
  font-size: 0.9rem;
}

/* ====== LIST GROUP ====== */
.list-group-item {
  transition: all 0.2s ease-in-out;
  border-radius: 0.375rem !important;
  margin-bottom: 0.5rem;
}

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

.list-group-item:last-child {
  margin-bottom: 0;
}

.list-group-item .bi {
  transition: transform 0.2s ease;
}

.list-group-item:hover .bi-chevron-right {
  transform: translateX(4px);
}

/* ====== CONTENIDO PRINCIPAL ====== */
.flex-grow-1 {
  background: #ffffff;
}

/* ====== ALERTAS ====== */
.alert {
  margin: 0;
  border-radius: 0.375rem;
}

/* ====== FORMULARIOS ====== */
.card .form-control {
  border-radius: 0.375rem;
}

.card .btn {
  border-radius: 0.375rem;
  font-weight: 500;
}

/* Optimizaciones para formularios móviles */
.form-row {
  margin-bottom: 1rem;
}

.form-row > .col,
.form-row > [class*="col-"] {
  margin-bottom: 1rem;
}

/* Grupos de formularios responsivos */
@media (max-width: 768px) {
  .form-row .col-md-6,
  .form-row .col-lg-4,
  .form-row .col-lg-3 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* Botones de formulario móviles */
.form-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

@media (min-width: 576px) {
  .form-actions {
    flex-direction: row;
    justify-content: flex-end;
  }
}

.form-actions .btn {
  width: 100%;
}

@media (min-width: 576px) {
  .form-actions .btn {
    width: auto;
    min-width: 120px;
  }
}

/* Campos de archivo móviles */
.form-control[type="file"] {
  font-size: 0.9rem;
  padding: 0.5rem;
}

@media (max-width: 576px) {
  .form-control[type="file"] {
    padding: 0.75rem;
    font-size: 16px; /* Evitar zoom */
  }
}

/* Checkboxes y radios móviles */
.form-check {
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  border-radius: 0.375rem;
  transition: background-color 0.2s;
}

.form-check:hover {
  background-color: #f8f9fa;
}

@media (max-width: 576px) {
  .form-check-input {
    width: 20px;
    height: 20px;
    margin-top: 0.25rem;
  }
  
  .form-check-label {
    font-size: 0.95rem;
    margin-left: 0.5rem;
  }
}

/* Selects móviles */
.form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m1 6 7 7 7-7'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
  padding-right: 2.5rem;
}

@media (max-width: 576px) {
  .form-select {
    font-size: 16px;
    padding: 0.75rem 2.5rem 0.75rem 0.75rem;
    min-height: 44px;
  }
}

/* Textareas móviles */
textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

@media (max-width: 576px) {
  textarea.form-control {
    min-height: 120px;
    font-size: 16px;
    padding: 0.75rem;
  }
}

/* Inputs numéricos móviles */
input[type="number"].form-control {
  padding-right: 3rem;
}

@media (max-width: 576px) {
  input[type="number"].form-control {
    font-size: 16px;
    padding: 0.75rem 3rem 0.75rem 0.75rem;
    min-height: 44px;
  }
}

/* Fechas móviles */
input[type="date"].form-control,
input[type="time"].form-control,
input[type="datetime-local"].form-control {
  cursor: pointer;
}

@media (max-width: 576px) {
  input[type="date"].form-control,
  input[type="time"].form-control,
  input[type="datetime-local"].form-control {
    font-size: 16px;
    padding: 0.75rem;
    min-height: 44px;
  }
}

/* Validación de formularios móvil */
.invalid-feedback {
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

@media (max-width: 576px) {
  .invalid-feedback {
    font-size: 0.9rem;
    margin-top: 0.5rem;
  }
}

/* Grupos de inputs móviles */
.input-group {
  margin-bottom: 1rem;
}

@media (max-width: 576px) {
  .input-group .form-control {
    font-size: 16px;
    min-height: 44px;
  }
  
  .input-group-text {
    font-size: 16px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .input-group > * {
    border-radius: 0 !important;
  }
  
  .input-group > *:first-child {
    border-top-left-radius: 0.375rem !important;
    border-bottom-left-radius: 0.375rem !important;
  }
  
  .input-group > *:last-child {
    border-top-right-radius: 0.375rem !important;
    border-bottom-right-radius: 0.375rem !important;
  }
}

/* ====== GALERÍAS DE IMÁGENES ====== */
.card .card-img-top {
  transition: transform 0.3s ease;
}

.card:hover .card-img-top {
  transform: scale(1.05);
}

/* ====== BADGES EN ICONOS ====== */
.badge .bi {
  margin-right: 4px;
}

/* ====== HOVER EN FILAS DE TABLA ====== */
.table tbody tr:hover {
  background-color: #f8f9fa;
}

/* ====== HEADERS DE LIST GROUP ====== */
.list-group-item h6 {
  font-weight: 600;
  color: #2c3e50;
}

/* ====== TEXTO DESCRIPTIVO ====== */
.list-group-item small {
  font-size: 0.85rem;
}

/* ====== RESPONSIVE CONSISTENTE ====== */
/* Tablets (768px - 1024px) */
@media (max-width: 1200px) {
  .header-info {
    font-size: 0.9rem;
  }
}

@media (max-width: 992px) {
  .header-info {
    font-size: 0.8rem;
  }
  
  .sidebar {
    width: 200px;
  }
  
  .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* Tablets pequeñas y móviles grandes */
@media (max-width: 768px) {
  .header-info {
    display: none;
  }
  
  .avatar-header {
    width: 40px !important;
    height: 40px !important;
  }
  
  .btn-basico {
    padding: 6px 10px;
    font-size: 0.875rem;
  }
  
  /* Sidebar colapsable para tablets */
  .sidebar {
    position: fixed;
    top: 0;
    left: -250px;
    width: 250px;
    height: 100vh;
    z-index: 1050;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  }
  
  .sidebar.show {
    left: 0;
  }
  
  /* Overlay para sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
  }
  
  .sidebar-overlay.show {
    display: block;
  }
  
  /* Botón toggle para sidebar */
  .sidebar-toggle {
    display: block !important;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1060;
    background: #0d6efd;
    color: white;
    border: none;
    border-radius: 0.5rem;
    padding: 0.5rem;
    font-size: 1.2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  }
  
  /* Ajustar contenido principal */
  .flex-grow-1 {
    margin-left: 0 !important;
  }
  
  /* Header responsive */
  .header-basico .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  body.has-sidebar-toggle .header-basico .container-fluid {
    padding-left: 4rem;
  }
  
  /* Tablas responsive */
  .table-responsive {
    border-radius: 0.375rem;
  }
  
  /* Cards en móviles */
  .card {
    margin-bottom: 1rem;
  }
  
  /* Formularios */
  .form-row > .col,
  .form-row > [class*="col-"] {
    margin-bottom: 1rem;
  }
}

/* Móviles */
@media (max-width: 576px) {
  .avatar-header {
    width: 35px !important;
    height: 35px !important;
  }
  
  .btn-basico {
    padding: 4px 8px;
    font-size: 0.8rem;
  }
  
  /* Header más compacto */
  .header-basico .container-fluid {
    padding: 0.5rem 3rem 0.5rem 1rem;
  }
  
  .header-basico h1 {
    font-size: 1.1rem !important;
  }
  
  .header-basico .text-muted {
    font-size: 0.75rem !important;
  }
  
  /* Sidebar toggle más pequeño */
  .sidebar-toggle {
    top: 0.75rem;
    left: 0.75rem;
    padding: 0.375rem;
    font-size: 1rem;
  }
  
  /* Botones de notificación y usuario */
  .btn-basico i {
    font-size: 0.9rem;
  }
  
  /* Dropdowns más pequeños */
  .notifications-dropdown {
    min-width: 280px;
    max-width: 90vw;
  }
  
  .user-dropdown {
    min-width: 180px;
  }
  
  /* Container padding reducido */
  .container-fluid {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
  
  /* Tablas - hacer scroll horizontal */
  .table {
    font-size: 0.8rem;
  }
  
  .table th,
  .table td {
    padding: 0.5rem 0.25rem;
  }
  
  /* Formularios móviles */
  .form-control {
    font-size: 0.9rem;
  }
  
  .form-label {
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
  }
  
  /* Cards móviles */
  .card-body {
    padding: 1rem 0.75rem;
  }
  
  /* Botones en cards */
  .card .btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
  }
}

/* Móviles muy pequeños */
@media (max-width: 400px) {
  /* Header ultra compacto */
  .header-basico h1 {
    font-size: 1rem !important;
  }
  
  .header-basico .text-muted {
    display: none;
  }
  
  /* Sidebar ajuste */
  .sidebar {
    width: 280px;
    left: -280px;
  }
  
  /* Botones más pequeños */
  .btn-basico {
    padding: 3px 6px;
    font-size: 0.75rem;
  }
  
  /* Tablas más compactas */
  .table {
    font-size: 0.75rem;
  }
  
  .table th,
  .table td {
    padding: 0.375rem 0.125rem;
  }
}

/* Orientación landscape en móviles */
@media (max-height: 500px) and (orientation: landscape) {
  .sidebar {
    height: 100vh;
    overflow-y: auto;
  }
  
  .sidebar-header {
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
  }
  
  .sidebar .nav-link {
    padding: 0.375rem 0.75rem;
  }
}

/* Mejoras para touch en dispositivos móviles */
@media (hover: none) and (pointer: coarse) {
  .btn-basico {
    min-height: 44px;
    min-width: 44px;
  }
  
  .nav-link {
    min-height: 44px;
  }
  
  .dropdown-item {
    padding: 12px 16px;
    min-height: 44px;
  }
  
  /* Espaciado extra para facilitar touch */
  .table td {
    padding: 0.75rem 0.5rem;
  }
  
  .form-control {
    min-height: 44px;
  }
  
  .form-select {
    min-height: 44px;
  }
}
