/* 
 * THORSMEX Design System - Sistema COT
 * Basado en GUIA_DISENO_SISTEMA.md v1.3.2
 * Desarrollado por: THORSMEX SISTEMAS EMPRESARIALES
 */

/* ========================================
   VARIABLES CSS - THORSMEX CORPORATIVO
   ======================================== */

:root {
  /* Azules Corporativos THORSMEX */
  --primary: #003366;
  --primary-light: #004d99;
  --secondary: #0066cc;
  --secondary-light: #3385d6;
  --accent: #00a8e8;
  
  /* Colores de Estado */
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  
  /* Colores Neutros */
  --dark: #1e293b;
  --light: #f8fafc;
  --gray: #64748b;
  --gray-light: #e2e8f0;
  
  /* Sombras */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
  
  /* Navbar */
  --navbar-bg: #2c3e50;
  --navbar-text: #ffffff;
  --navbar-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* ========================================
   TIPOGRAFÍA
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 
               'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 
               'Helvetica Neue', sans-serif;
  font-size: 15px;
  color: var(--dark);
  background-color: var(--light);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   CARDS Y CONTENEDORES
   ======================================== */

.thorsmex-card {
  background: white;
  border: none;
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.thorsmex-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  border-radius: 20px 20px 0 0;
  margin: -24px -24px 24px -24px;
}

.thorsmex-card-title {
  font-size: 1.5rem;
  color: white;
  font-weight: 700;
  margin: 0;
}

/* ========================================
   BOTONES
   ======================================== */

.thorsmex-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  display: inline-block;
  font-family: inherit;
  text-align: center;
}

.thorsmex-btn:hover {
  transform: translateY(-2px);
  text-decoration: none;
}

.thorsmex-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* Botón Primary */
.thorsmex-btn-primary {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary-light) 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

.thorsmex-btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
  box-shadow: 0 6px 16px rgba(0, 102, 204, 0.4);
  color: #ffffff;
}

/* Botón Success */
.thorsmex-btn-success {
  background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.thorsmex-btn-success:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
  color: #ffffff;
}

/* Botón Danger */
.thorsmex-btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.thorsmex-btn-danger:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
  color: #ffffff;
}

/* Botón Info */
.thorsmex-btn-info {
  background: linear-gradient(135deg, var(--info) 0%, #2563eb 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.thorsmex-btn-info:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
  color: #ffffff;
}

/* Botón Secondary */
.thorsmex-btn-secondary {
  background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.thorsmex-btn-secondary:hover {
  background: linear-gradient(135deg, #495057 0%, #343a40 100%);
  box-shadow: 0 6px 16px rgba(108, 117, 125, 0.4);
  color: #ffffff;
}

/* ========================================
   BADGES Y ESTADOS
   ======================================== */

.thorsmex-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Badge Gray (Borrador, Inactivo) */
.thorsmex-badge-gray {
  background: #e5e7eb;
  color: #374151;
}

/* Badge Yellow (Pendiente, En Revisión) */
.thorsmex-badge-yellow {
  background: #fef3c7;
  color: #92400e;
}

/* Badge Green (Aprobado, Comprobado, Exitoso) */
.thorsmex-badge-green {
  background: #d1fae5;
  color: #065f46;
}

/* Badge Red (Rechazado, Vencido, Error) */
.thorsmex-badge-red {
  background: #fee2e2;
  color: #991b1b;
}

/* Badge Blue (Contabilizado, En Comprobación, Info) */
.thorsmex-badge-blue {
  background: #dbeafe;
  color: #1e40af;
}

/* ========================================
   FORMULARIOS
   ======================================== */

.thorsmex-form-group {
  margin-bottom: 1.5rem;
}

.thorsmex-form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--dark);
  font-weight: 600;
  font-size: 14px;
}

.thorsmex-form-group input,
.thorsmex-form-group textarea,
.thorsmex-form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--gray-light);
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.thorsmex-form-group input:focus,
.thorsmex-form-group textarea:focus,
.thorsmex-form-group select:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 4px rgba(0, 102, 204, 0.1);
}

.thorsmex-form-group textarea {
  resize: vertical;
  min-height: 100px;
}

.thorsmex-form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

/* ========================================
   TABLAS
   ======================================== */

.thorsmex-table-container {
  overflow-x: auto;
  border-radius: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.thorsmex-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 14px;
}

.thorsmex-table thead {
  background: linear-gradient(135deg, var(--light) 0%, var(--gray-light) 100%);
  color: var(--primary);
}

.thorsmex-table th {
  padding: 16px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  color: var(--primary);
}

.thorsmex-table td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid var(--gray-light);
}

.thorsmex-table tbody tr {
  transition: background-color 0.2s;
}

.thorsmex-table tbody tr:hover {
  background-color: var(--light);
}

.thorsmex-table tbody tr:last-child td {
  border-bottom: none;
}

/* ========================================
   ESTADÍSTICAS Y MÉTRICAS
   ======================================== */

.thorsmex-stat-card {
  background: white;
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

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

.thorsmex-stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transform: translate(30px, -30px);
}

.thorsmex-stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0;
  color: white;
}

.thorsmex-stat-label {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-bottom: 0.5rem;
  color: white;
}

.thorsmex-stat-change {
  font-size: 0.8rem;
  opacity: 0.8;
  color: white;
}

/* Gradientes para tarjetas de estadísticas */
.thorsmex-stat-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
}

.thorsmex-stat-success {
  background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
  color: white;
}

.thorsmex-stat-info {
  background: linear-gradient(135deg, var(--info) 0%, #2563eb 100%);
  color: white;
}

.thorsmex-stat-warning {
  background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
  color: white;
}

/* ========================================
   NAVBAR THORSMEX
   ======================================== */

.thorsmex-navbar {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: var(--navbar-text);
  box-shadow: var(--shadow-lg);
  padding: 0.75rem 0;
}

.thorsmex-navbar-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1rem;
}

.thorsmex-navbar-brand {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--navbar-text);
  text-decoration: none;
  display: flex;
  align-items: center;
}

.thorsmex-navbar-brand:hover {
  color: var(--navbar-text);
  text-decoration: none;
  transform: scale(1.02);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.thorsmex-navbar-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.thorsmex-navbar-link {
  color: var(--navbar-text);
  text-decoration: none;
  font-weight: 500;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  margin: 0 0.25rem;
}

.thorsmex-navbar-link:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--navbar-text);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.thorsmex-navbar-link.active {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.35) 100%);
  color: var(--navbar-text);
  font-weight: 600;
  box-shadow: 0 2px 12px rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.thorsmex-navbar-link.btn {
  border: none;
  background: transparent;
}

.thorsmex-navbar-link.btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border: none;
}

/* Espaciado mejorado para elementos de navegación */
.navbar-nav {
  gap: 0.75rem;
}

.navbar-nav .nav-link {
  padding: 0.75rem 1.25rem !important;
  margin: 0 0.25rem;
  border-radius: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.navbar-nav .nav-link.active {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.35) 100%) !important;
  color: var(--navbar-text) !important;
  font-weight: 600;
  box-shadow: 0 2px 12px rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Navbar Toggler */
.navbar-toggler {
  border: none;
  padding: 0.25rem 0.5rem;
  color: var(--navbar-text);
  background: transparent;
}

.navbar-toggler:focus {
  box-shadow: none;
}

.navbar-toggler i {
  font-size: 1.2rem;
}

/* Dropdown Menus */
.dropdown-menu {
  border: none;
  box-shadow: var(--shadow-lg);
  border-radius: 12px;
  padding: 0.5rem 0;
  margin-top: 0.5rem;
  min-width: 180px;
  background: white;
}

.dropdown-item {
  padding: 0.5rem 1rem;
  color: var(--dark);
  border-radius: 8px;
  margin: 0 0.5rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
}

.dropdown-item:hover {
  background: linear-gradient(135deg, rgba(0, 51, 102, 0.1) 0%, rgba(0, 102, 204, 0.1) 100%);
  color: var(--primary);
}

.dropdown-item.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
}

.dropdown-item i {
  width: 16px;
  text-align: center;
}

/* Badge para carrito */
.navbar .badge {
  font-size: 0.7rem;
  padding: 0.25rem 0.4rem;
  border-radius: 50%;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* User Avatar */
.navbar .rounded-circle {
  border: 2px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s;
}

.navbar .rounded-circle:hover {
  border-color: rgba(255, 255, 255, 0.6);
  transform: scale(1.05);
}

/* ========================================
   ESTADOS Y MENSAJES
   ======================================== */

.thorsmex-alert {
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-size: 14px;
}

.thorsmex-alert-success {
  background-color: #d1fae5;
  color: #065f46;
  border-left: 4px solid var(--success);
}

.thorsmex-alert-danger {
  background-color: #fee2e2;
  color: #991b1b;
  border-left: 4px solid var(--danger);
}

.thorsmex-alert-warning {
  background-color: #fef3c7;
  color: #92400e;
  border-left: 4px solid var(--warning);
}

.thorsmex-alert-info {
  background-color: #dbeafe;
  color: #1e40af;
  border-left: 4px solid var(--info);
}

.thorsmex-loading {
  text-align: center;
  padding: 2rem;
  color: var(--gray);
}

.thorsmex-empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--gray);
}

.thorsmex-empty-state h3 {
  margin-bottom: 0.5rem;
  color: var(--primary);
  font-weight: 600;
}

/* ========================================
   SCROLLBAR PERSONALIZADO
   ======================================== */

/* Webkit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #bdc3c7;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #95a5a6;
}

/* Firefox */
* {
  scrollbar-color: #bdc3c7 #f1f1f1;
  scrollbar-width: thin;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
  .thorsmex-navbar-content {
    flex-direction: column;
    gap: 1rem;
    padding: 0 1rem;
  }

  .thorsmex-navbar-links {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
    width: 100%;
  }

  .thorsmex-navbar-link {
    width: 100%;
    justify-content: center;
    padding: 0.75rem;
  }

  .thorsmex-form-actions {
    flex-direction: column;
  }

  .thorsmex-btn {
    width: 100%;
  }

  .thorsmex-card {
    padding: 16px;
  }

  .thorsmex-card-header {
    padding: 16px;
    margin: -16px -16px 16px -16px;
  }

  .thorsmex-stat-number {
    font-size: 2rem;
  }

  /* Navbar collapse específico */
  .navbar-collapse {
    margin-top: 1rem;
  }

  .navbar-nav {
    width: 100%;
  }

  .nav-item {
    width: 100%;
  }

  .thorsmex-navbar-link.nav-link {
    width: 100%;
    text-align: center;
    padding: 0.75rem 1rem;
    margin: 0.25rem 0;
    border-radius: 8px;
  }

  .dropdown-menu {
    width: 100%;
    margin-top: 0.25rem;
  }

  /* Ocultar textos en móvil para navbar compacta */
  .d-none.d-lg-inline {
    display: none !important;
  }
}

@media (max-width: 576px) {
  .thorsmex-main-content {
    padding: 1rem 0.5rem;
  }

  .thorsmex-navbar-content {
    padding: 0 0.5rem;
  }

  .thorsmex-navbar-brand {
    font-size: 1.2rem;
  }

  .thorsmex-navbar-brand img {
    height: 32px !important;
  }

  /* Navbar más compacta en móvil */
  .thorsmex-navbar {
    padding: 0.5rem 0;
  }

  .thorsmex-navbar-link {
    font-size: 0.9rem;
    padding: 0.5rem;
  }

  .dropdown-menu {
    font-size: 0.9rem;
  }
}

/* ========================================
   UTILIDADES
   ======================================== */

.thorsmex-text-primary { color: var(--primary) !important; }
.thorsmex-text-secondary { color: var(--secondary) !important; }
.thorsmex-text-success { color: var(--success) !important; }
.thorsmex-text-danger { color: var(--danger) !important; }
.thorsmex-text-warning { color: var(--warning) !important; }
.thorsmex-text-info { color: var(--info) !important; }
.thorsmex-text-gray { color: var(--gray) !important; }

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

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

.thorsmex-rounded { border-radius: 12px !important; }
.thorsmex-rounded-lg { border-radius: 20px !important; }

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

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

/* ========================================
   LAYOUT PRINCIPAL
   ======================================== */

.thorsmex-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--light);
}

.thorsmex-main-content {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 768px) {
  .thorsmex-main-content {
    padding: 1rem;
  }
}