:root {
  /* Core Palette - Enterprise Professional */
  --bg-main: #f8fafc;
  --sidebar-bg: #0f172a; /* Slate 900 */
  --sidebar-text: #94a3b8; /* Slate 400 */
  --sidebar-active: #ffffff;
  --sidebar-accent: #334155; /* Slate 700 */
  
  --primary: #2563eb; /* Blue 600 */
  --primary-hover: #1d4ed8;
  --secondary: #64748b; /* Slate 500 */
  
  --card-bg: #ffffff;
  --panel-bg: rgba(255, 255, 255, 0.8);
  --border-color: #e2e8f0;
  
  --text-main: #1e293b; /* Slate 800 */
  --text-muted: #64748b; /* Slate 500 */
  
  --status-open: #2563eb;
  --status-progress: #ea580c; /* Orange 600 */
  --status-resolved: #16a34a; /* Green 600 */
  --status-closed: #475569; /* Slate 600 */
  
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  /* Premium Gradients */
  --grad-primary: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  --grad-surface: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.7) 100%);

  /* Backward Compatibility Fixes */
  --bg-color: var(--bg-main);
  --accent-color: var(--primary);
  --accent-hover: var(--primary-hover);
  --panel-bg-solid: #ffffff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
}

/* Premium Sidebar System */
.sidebar {
  width: 280px;
  background-color: var(--sidebar-bg);
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  margin-bottom: 3rem;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  letter-spacing: -0.02em;
}

.logo-text span {
  color: #60a5fa;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 1rem;
}

.nav-item {
  padding: 0.85rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
}

.nav-item i {
  font-size: 1.25rem;
}

.nav-item:hover {
  background-color: var(--sidebar-accent);
  color: var(--sidebar-active);
}

.nav-item.active {
  background-color: rgba(37, 99, 235, 0.15);
  color: var(--sidebar-active);
}

.nav-item.active i {
  color: #60a5fa;
}

/* Premium Main Content */
.main-content {
  flex: 1;
  margin-left: 280px;
  padding: 2.5rem 4rem;
  background-color: var(--bg-main);
  min-height: 100vh;
  transition: all 0.3s ease;
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.page-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.025em;
}

/* Grid Layout for Forms and KB */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 2rem;
  align-items: start;
}

/* Tabs Management */
.tab-content {
  display: none !important;
}

.tab-content.active {
  display: block !important;
}

/* Glass Panel */
.panel {
  background: var(--grad-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 2rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.panel:hover {
  box-shadow: var(--shadow-md);
}

.panel-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-color);
  color: var(--text-main);
  transition: all 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background-color: #fff;
}

textarea.form-control {
  resize: vertical;
  min-height: 120px;
}

.btn {
  display: inline-block;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  text-align: center;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.btn-primary {
  background-color: var(--accent-color);
  color: #fff;
  width: 100%;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Knowledge Base & Search Smart System */
.search-container-premium {
  position: relative;
  display: flex;
  align-items: center;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 50px;
  padding: 0 1rem;
  transition: all 0.3s ease;
  width: 100%;
  max-width: 400px;
}

.search-container-premium:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.search-icon-inside {
  color: var(--text-muted);
  font-size: 1.1rem;
}

.search-input-premium {
  border: none;
  background: transparent;
  padding: 0.75rem 0.5rem;
  width: 100%;
  outline: none;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-main);
}

.kb-section {
  background: linear-gradient(145deg, #ffffff, #f9f9fb);
  border-left: 4px solid var(--primary);
}

.kb-search-container {
  position: relative;
  margin-bottom: 1.5rem;
}

.kb-icon {
  position: absolute;
  top: 50%;
  left: 1rem;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.kb-input {
  padding-left: 2.5rem;
}

.kb-suggestions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.kb-card {
  padding: 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.kb-card:hover {
  border-color: var(--text-muted);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.kb-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kb-badge {
  font-size: 0.7rem;
  padding: 0.25rem 0.75rem;
  background-color: #f1f5f9;
  border-radius: 20px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  display: inline-block;
}

.kb-card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Tablas Maestras Mejoradas */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 1rem;
}

.data-table th {
  text-align: left;
  padding: 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-color);
}

.data-table td {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid #f0f0f2;
  font-size: 0.9rem;
  vertical-align: middle;
}

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

/* Agrupación y Hover */
.catalog-row {
  transition: background-color 0.2s ease;
}

.catalog-row:hover {
  background-color: #fcfcfd;
}

.action-trigger {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.catalog-row:hover .action-trigger {
  opacity: 1;
}

.action-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
  font-size: 1.1rem;
}

.action-icon:hover {
  background: #f0f0f2;
  color: var(--text-main);
}

.action-delete:hover {
  color: #dc2626;
  background: #fef2f2;
}

.group-line {
  color: var(--text-muted);
  font-weight: 400;
  opacity: 0.5;
}

/* Premium Toast System */
.toast {
  position: fixed;
  top: 2rem;
  right: 2rem;
  min-width: 320px;
  background: white;
  color: var(--text-main);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  transform: translateX(120%);
  transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 2000;
  border-left: 6px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 1rem;
  font-weight: 600;
}

.toast.show {
  transform: translateX(0);
}

.toast-error {
  border-left-color: #ef4444;
  background: #fef2f2;
}

.toast-success {
  border-left-color: #10b981;
  background: #f0fdf4;
}

/* Status Tabs Monitor */
.status-tabs-container {
  display: flex;
  background: #f1f5f9;
  padding: 0.25rem;
  border-radius: 10px;
  gap: 0.25rem;
}
.status-tab {
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s ease;
}
.status-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.5);
}
.status-tab.active {
  background: white;
  color: var(--accent-color);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* KPI System */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.kpi-card {
  background: white;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  transition: transform 0.2s, box-shadow 0.2s;
}

/* Premium Modals */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: white;
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.close-btn {
  background: #f1f5f9;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.close-btn:hover {
  background: #e2e8f0;
  color: var(--text-main);
  transform: rotate(90deg);
}

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

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.kpi-info h3 {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Specific KPI Colors - Refined for Professionalism */
.kpi-stations .kpi-icon { background: #f1f5f9; color: #475569; }
.kpi-open .kpi-icon { background: #fffbeb; color: #d97706; }
.kpi-resolved .kpi-icon { background: #f0fdf4; color: #16a34a; }

/* Pagination Styles */
.pagination-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: white;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pagination-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #f0f7ff;
}

.pagination-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

/* Glass Panels */
.premium-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-lg);
  padding: 2rem;
}

/* User Profile Widget */
.user-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem;
  background: white;
  border-radius: 50px;
  border: 1px solid var(--border-color);
  padding-right: 0.75rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 600;
}

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

/* Responsive Overrides */
@media (max-width: 900px) {
  .sidebar { width: 80px; padding: 2rem 0.5rem; }
  .logo-text, .nav-item span { display: none; }
  .main-content { margin-left: 80px; padding: 1.5rem; }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { 
    display: none; 
  }
  .main-content { 
    margin-left: 0; 
    padding: 1rem; 
    padding-bottom: 5rem; /* Space for bottom nav */
  }
  
  .top-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  /* Bottom Navigation for Mobile */
  .mobile-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    height: 64px;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    padding: 0 1rem;
  }
  
  /* Mobile Drawer Sidebar */
  .sidebar.mobile-active {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    z-index: 2000;
    box-shadow: 20px 0 50px rgba(0,0,0,0.2);
    animation: slideInLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Show labels when drawer is active */
  .sidebar.mobile-active .nav-item span, 
  .sidebar.mobile-active .logo-text {
    display: inline !important;
  }

  /* Overlay backdrop */
  .menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1500;
    animation: fadeIn 0.3s ease;
  }

  .menu-overlay.active {
    display: block;
  }

  @keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
  }
  
  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 600;
    flex: 1;
  }
  
  .mobile-nav-item i {
    font-size: 1.5rem;
  }
  
  .mobile-nav-item.active {
    color: var(--primary);
  }

  /* Table to Cards Conversion */
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td {
    display: block;
    width: 100%;
  }
  
  .data-table tr {
    background: white;
    margin-bottom: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 1rem;
  }
  
  .data-table td {
    border: none;
    padding: 0.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
  }
  
  .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    text-align: left;
    margin-right: 1rem;
  }

  /* Custom Ticket Card logic */
  .ticket-card {
    padding: 1rem !important;
  }
}

/* Hide mobile nav by default */
.mobile-nav { display: none; }
