/* 
 * APP TALLER - ADMIN DASHBOARD DARK THEME
 * Tema oscuro profesional inspirado en Maxton/Metronic/Sneat
 */

/* ===============================================
   VARIABLES CSS Y CONFIGURACIÓN BASE
   =============================================== */
:root {
  /* Colores principales - Tema oscuro */
  --bg-primary: #0F172A;
  --bg-secondary: #1E293B;
  --bg-tertiary: #334155;
  --bg-card: #1E293B;
  --bg-hover: #334155;
  
  /* Colores de acento */
  --accent-blue: #3B82F6;
  --accent-blue-hover: #2563EB;
  --accent-green: #22C55E;
  --accent-green-hover: #16A34A;
  --accent-purple: #8B5CF6;
  --accent-red: #EF4444;
  --accent-orange: #F59E0B;
  
  /* Colores de texto */
  --text-primary: #F8FAFC;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;
  --text-dark: #64748B;
  
  /* Bordes y sombras */
  --border-color: #334155;
  --border-light: #475569;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);
  
  /* Tipografía */
  --font-primary: 'Inter', system-ui, -apple-system, sans-serif;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  
  /* Bordes redondeados */
  --border-radius: 12px;
  --border-radius-lg: 16px;
  --border-radius-sm: 8px;
  
  /* Transiciones */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
  
  /* Sidebar */
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 80px;
  
  /* Header height */
  --header-height: 70px;
}

/* ===============================================
   RESET Y BASE STYLES
   =============================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ===============================================
   LAYOUT PRINCIPAL
   =============================================== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding-top: var(--header-height);
  transition: var(--transition);
  background-color: var(--bg-primary);
  min-height: 100vh;
}

.main-content.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed-width);
}

/* ===============================================
   SIDEBAR
   =============================================== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, #1a252f 100%);
  border-right: 1px solid var(--border-color);
  z-index: 1000;
  transition: var(--transition);
  overflow-y: auto;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: var(--font-weight-bold);
  font-size: 1.25rem;
}

.sidebar-brand {
  font-size: 1.5rem;
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  transition: var(--transition);
}

.sidebar.collapsed .sidebar-brand {
  opacity: 0;
  width: 0;
}

.sidebar-nav {
  padding: 1rem 0;
}

.nav-item {
  margin: 0.25rem 0;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.875rem 1.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition-fast);
  border-radius: 0;
  gap: 0.875rem;
  position: relative;
}

.nav-link:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
  transform: translateX(4px);
}

.nav-link.active {
  color: var(--accent-blue);
  background: linear-gradient(90deg, 
    rgba(59, 130, 246, 0.1) 0%, 
    rgba(59, 130, 246, 0.05) 100%);
  border-right: 3px solid var(--accent-blue);
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent-blue);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-text {
  transition: var(--transition);
}

.sidebar.collapsed .nav-text {
  opacity: 0;
  width: 0;
}

/* Tooltip para sidebar colapsado */
.sidebar.collapsed .nav-link {
  position: relative;
}

.sidebar.collapsed .nav-link:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
  white-space: nowrap;
  margin-left: 0.5rem;
  box-shadow: var(--shadow-md);
  z-index: 1001;
}

/* ===============================================
   HEADER/NAVBAR
   =============================================== */
.header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 999;
  transition: var(--transition);
}

.header.sidebar-collapsed {
  left: var(--sidebar-collapsed-width);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--border-radius-sm);
  transition: var(--transition-fast);
}

.sidebar-toggle:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
}

.header-search {
  position: relative;
  width: 400px;
  max-width: 100%;
}

.search-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px;
  height: 16px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-btn {
  position: relative;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 0.5rem;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.header-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
}

.notification-badge {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  background: var(--accent-red);
  color: white;
  font-size: 0.75rem;
  padding: 0.125rem 0.375rem;
  border-radius: 10px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-dropdown {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition-fast);
}

.user-dropdown:hover {
  background-color: var(--bg-hover);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: var(--font-weight-semibold);
}

.user-info {
  text-align: right;
}

.user-name {
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  font-size: 0.875rem;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===============================================
   AVATARES Y ELEMENTOS VISUALES
   =============================================== */
.avatar-sm {
  width: 40px;
  height: 40px;
}

.avatar-circle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: var(--font-weight-bold);
  font-size: 0.875rem;
  text-transform: uppercase;
}

.search-box {
  position: relative;
}

.search-box .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px;
  height: 16px;
  z-index: 2;
}

.search-input {
  padding-left: 40px !important;
  background-color: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

.search-input:focus {
  border-color: var(--accent-blue) !important;
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25) !important;
  background-color: var(--bg-secondary) !important;
}

/* ===============================================
   CONTENT WRAPPER
   =============================================== */
.content-wrapper {
  padding: 2rem;
  min-height: calc(100vh - var(--header-height));
}

.page-header {
  margin-bottom: 2rem;
}

.breadcrumb-container {
  margin-bottom: 1rem;
}

.breadcrumb {
  background: none;
  padding: 0;
  margin: 0;
  font-size: 0.875rem;
}

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

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

.breadcrumb-item + .breadcrumb-item::before {
  content: "›";
  color: var(--text-muted);
  margin: 0 0.5rem;
}

.page-title {
  font-size: 2rem;
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* ===============================================
   CARDS Y COMPONENTES
   =============================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
}

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

.card-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
}

.card-title {
  font-size: 1.125rem;
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0;
}

.card-body {
  padding: 1.5rem;
}

/* Cards estadísticas */
.stat-card {
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(59, 130, 246, 0.05) 100%);
  border: 1px solid rgba(59, 130, 246, 0.2);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
}

.stat-value {
  font-size: 2.5rem;
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.stat-change {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.5rem;
  font-size: 0.875rem;
}

.stat-change.positive {
  color: var(--accent-green);
}

.stat-change.negative {
  color: var(--accent-red);
}

/* ===============================================
   BOTONES
   =============================================== */
.btn {
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-blue-hover));
  color: white;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-success {
  background: linear-gradient(135deg, var(--accent-green), var(--accent-green-hover));
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

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

/* ===============================================
   FORMULARIOS
   =============================================== */
.form-control {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  transition: var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background: var(--bg-secondary);
}

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

/* ===============================================
   TABLAS
   =============================================== */
.table-responsive {
  border-radius: var(--border-radius);
  overflow: hidden;
}

.table {
  background: var(--bg-card);
  margin: 0;
}

.table thead th {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: var(--font-weight-semibold);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem;
}

.table tbody td {
  background: var(--bg-card);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem;
}

.table tbody tr:hover {
  background: var(--bg-hover);
}

/* ===============================================
   FOOTER
   =============================================== */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 1.5rem 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ===============================================
   RESPONSIVE
   =============================================== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.show {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .header-search {
    display: none;
  }
  
  .content-wrapper {
    padding: 1rem;
  }
}

/* ===============================================
   MODALES Y FORMULARIOS OSCUROS
   =============================================== */
.modal-content {
  background-color: var(--bg-secondary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--border-radius) !important;
  box-shadow: var(--shadow-lg) !important;
}

.modal-header {
  background-color: var(--bg-tertiary) !important;
  border-bottom: 1px solid var(--border-color) !important;
  color: var(--text-primary) !important;
}

.modal-title {
  color: var(--text-primary) !important;
  font-weight: var(--font-weight-semibold) !important;
}

.modal-body {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
}

.modal-footer {
  background-color: var(--bg-tertiary) !important;
  border-top: 1px solid var(--border-color) !important;
}

/* Botón cerrar del modal */
.btn-close {
  filter: invert(1) grayscale(100%) brightness(200%) !important;
  opacity: 0.8 !important;
}

.btn-close:hover {
  opacity: 1 !important;
}

/* Formularios oscuros */
.form-label {
  color: var(--text-primary) !important;
  font-weight: var(--font-weight-medium) !important;
  margin-bottom: 0.5rem !important;
}

.form-control {
  background-color: var(--bg-primary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--border-radius-sm) !important;
  color: var(--text-primary) !important;
  transition: var(--transition-fast) !important;
}

.form-control:focus {
  background-color: var(--bg-primary) !important;
  border-color: var(--accent-blue) !important;
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25) !important;
  color: var(--text-primary) !important;
}

.form-control::placeholder {
  color: var(--text-muted) !important;
  opacity: 0.8 !important;
}

.form-control:disabled {
  background-color: var(--bg-tertiary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-muted) !important;
  opacity: 0.6 !important;
}

/* Select oscuro */
.form-select {
  background-color: var(--bg-primary) !important;
  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='%23cbd5e1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m1 6 7 7 7-7'/%3e%3c/svg%3e") !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--border-radius-sm) !important;
  color: var(--text-primary) !important;
}

.form-select:focus {
  background-color: var(--bg-primary) !important;
  border-color: var(--accent-blue) !important;
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25) !important;
}

/* Textarea oscuro */
textarea.form-control {
  resize: vertical !important;
  min-height: 80px !important;
}

/* Checkboxes y radios */
.form-check-input {
  background-color: var(--bg-primary) !important;
  border: 1px solid var(--border-color) !important;
}

.form-check-input:checked {
  background-color: var(--accent-blue) !important;
  border-color: var(--accent-blue) !important;
}

.form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25) !important;
}

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

/* Texto de ayuda */
.form-text {
  color: var(--text-muted) !important;
}

/* Estados de validación */
.is-invalid {
  border-color: var(--accent-red) !important;
}

.is-valid {
  border-color: var(--accent-green) !important;
}

.invalid-feedback {
  color: var(--accent-red) !important;
}

.valid-feedback {
  color: var(--accent-green) !important;
}

/* Input groups */
.input-group-text {
  background-color: var(--bg-tertiary) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-secondary) !important;
}

/* Dropdowns oscuros */
.dropdown-menu {
  background-color: var(--bg-secondary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--border-radius) !important;
  box-shadow: var(--shadow-md) !important;
}

.dropdown-item {
  color: var(--text-primary) !important;
  transition: var(--transition-fast) !important;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background-color: var(--bg-hover) !important;
  color: var(--text-primary) !important;
}

.dropdown-item.active {
  background-color: var(--accent-blue) !important;
  color: white !important;
}

.dropdown-divider {
  border-top: 1px solid var(--border-color) !important;
}

.dropdown-header {
  color: var(--text-secondary) !important;
}

/* SweetAlert2 tema oscuro */
.swal2-popup {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color) !important;
}

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

.swal2-content {
  color: var(--text-secondary) !important;
}

.swal2-input,
.swal2-textarea {
  background-color: var(--bg-primary) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-primary) !important;
}

.swal2-input::placeholder,
.swal2-textarea::placeholder {
  color: var(--text-muted) !important;
}

/* ===============================================
   PAGINACIÓN Y BADGES OSCUROS
   =============================================== */
.pagination .page-link {
  background-color: var(--bg-secondary) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-primary) !important;
  transition: var(--transition-fast) !important;
}

.pagination .page-link:hover {
  background-color: var(--bg-hover) !important;
  border-color: var(--border-light) !important;
  color: var(--text-primary) !important;
}

.pagination .page-item.active .page-link {
  background-color: var(--accent-blue) !important;
  border-color: var(--accent-blue) !important;
  color: white !important;
}

.pagination .page-item.disabled .page-link {
  background-color: var(--bg-tertiary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-muted) !important;
  opacity: 0.6 !important;
}

/* Badges mejorados */
.badge {
  font-weight: var(--font-weight-medium) !important;
  padding: 0.375rem 0.75rem !important;
  font-size: 0.75rem !important;
  border-radius: var(--border-radius-sm) !important;
}

.badge.bg-info {
  background-color: var(--accent-blue) !important;
  color: white !important;
}

.badge.bg-success {
  background-color: var(--accent-green) !important;
  color: white !important;
}

.badge.bg-warning {
  background-color: var(--accent-orange) !important;
  color: white !important;
}

.badge.bg-danger {
  background-color: var(--accent-red) !important;
  color: white !important;
}

.badge.bg-secondary {
  background-color: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
}

/* ===============================================
   UTILIDADES
   =============================================== */
.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-blue { color: var(--accent-blue) !important; }
.text-green { color: var(--accent-green) !important; }
.text-red { color: var(--accent-red) !important; }

.bg-primary { background-color: var(--bg-primary) !important; }
.bg-secondary { background-color: var(--bg-secondary) !important; }
.bg-card { background-color: var(--bg-card) !important; }

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

/* Animaciones */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.fade-in { animation: fadeIn 0.3s ease; }
.slide-in-right { animation: slideInRight 0.3s ease; }