/* ============================================
   SERVIDOR CENTRAL JOIN - Design System 2.0
   Estilo moderno: sidebar compacto + fondo suave
   ============================================ */

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

:root {
  /* Colores principales */
  --color-bg: #f0f0f8;
  --color-sidebar: #4c35b5;
  --color-sidebar-dark: #3a27a0;
  --color-sidebar-icon: rgba(255,255,255,0.55);
  --color-sidebar-icon-active: #ffffff;
  --color-card: #ffffff;
  --color-surface: #f8f7ff;

  /* Accent */
  --color-purple: #7c4dff;
  --color-purple-light: #ede8ff;
  --color-orange: #ff7043;
  --color-orange-light: #fff3ef;
  --color-green: #26c485;
  --color-green-light: #e8faf3;
  --color-blue: #4285f4;
  --color-blue-light: #e8f0fe;
  --color-amber: #f59e0b;
  --color-amber-light: #fffbeb;
  --color-red: #ef4444;
  --color-red-light: #fef2f2;

  /* Texto */
  --text-primary: #1a1040;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;

  /* Bordes */
  --border: 1px solid #e5e7eb;
  --border-purple: 1px solid rgba(124, 77, 255, 0.25);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Sombras */
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(76, 53, 181, 0.08);
  --shadow-lg: 0 8px 32px rgba(76, 53, 181, 0.12);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.05);

  /* Transiciones */
  --ease: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  background: var(--color-bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1c4e9; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-purple); }

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

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: 72px;
  background: var(--color-sidebar);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
  gap: 6px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  box-shadow: 4px 0 24px rgba(76, 53, 181, 0.25);
}

.sidebar-logo {
  width: 44px;
  height: 44px;
  background: rgba(255,255,255,0.15);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 12px;
  border: 2px solid rgba(255,255,255,0.2);
}

.nav-item {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  transition: var(--ease);
  color: var(--color-sidebar-icon);
  position: relative;
  border: 2px solid transparent;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255,255,255,0.12);
  color: var(--color-sidebar-icon-active);
}

.nav-item.active {
  background: rgba(255,255,255,0.20);
  color: var(--color-sidebar-icon-active);
  border-color: rgba(255,255,255,0.3);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.nav-item .badge-count {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--color-orange);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-sidebar);
}

.nav-item:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 58px;
  top: 50%;
  transform: translateY(-50%);
  background: #1a1040;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 8px;
  pointer-events: none;
  z-index: 999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.sidebar-spacer { flex: 1; }

.sidebar-logout {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  color: rgba(255,255,255,0.55);
  transition: var(--ease);
  border: 2px solid transparent;
}

.sidebar-logout:hover {
  background: rgba(239,68,68,0.25);
  color: #fca5a5;
  border-color: rgba(239,68,68,0.4);
}

/* ==================== MAIN AREA ==================== */
.main-area {
  margin-left: 72px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ==================== TOP BAR ==================== */
.topbar {
  background: var(--color-card);
  border-bottom: var(--border);
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-brand {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.topbar-brand span {
  color: var(--color-purple);
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-surface);
  border: var(--border);
  border-radius: var(--radius-full);
  padding: 8px 16px;
  width: 260px;
  transition: var(--ease);
}

.topbar-search:focus-within {
  border-color: var(--color-purple);
  box-shadow: 0 0 0 3px var(--color-purple-light);
}

.topbar-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.88rem;
  color: var(--text-primary);
  width: 100%;
}

.topbar-search input::placeholder { color: var(--text-muted); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: var(--color-surface);
  border: var(--border);
  cursor: pointer;
  transition: var(--ease);
  color: var(--text-secondary);
}

.topbar-icon-btn:hover {
  background: var(--color-purple-light);
  color: var(--color-purple);
  border-color: var(--color-purple);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--color-surface);
  border: var(--border);
  border-radius: var(--radius-full);
  padding: 6px 14px 6px 6px;
  cursor: pointer;
  transition: var(--ease);
}

.user-pill:hover {
  border-color: var(--color-purple);
  background: var(--color-purple-light);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-purple), #5c35d0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: white;
  flex-shrink: 0;
}

.user-pill-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ==================== CONTENT ==================== */
.main-content {
  flex: 1;
  padding: 28px;
}

/* ==================== HERO WELCOME CARD ==================== */
.welcome-card {
  background: linear-gradient(135deg, #fdf8ff 0%, #fff5f0 100%);
  border: var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  overflow: hidden;
  position: relative;
}

.welcome-card::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(124,77,255,0.08) 0%, transparent 70%);
  border-radius: 50%;
}

.welcome-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.welcome-sub {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
  max-width: 480px;
}

.welcome-tags {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.welcome-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
}

.welcome-tag.purple { background: var(--color-purple-light); color: var(--color-purple); }
.welcome-tag.green  { background: var(--color-green-light); color: var(--color-green); }
.welcome-tag.orange { background: var(--color-orange-light); color: var(--color-orange); }

.welcome-emoji {
  font-size: 4rem;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.12));
}

/* ==================== METRIC CARDS ==================== */
.grid-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--color-card);
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-card);
  transition: var(--ease);
}

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

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

.metric-icon.blue   { background: var(--color-blue-light); }
.metric-icon.green  { background: var(--color-green-light); }
.metric-icon.amber  { background: var(--color-amber-light); }
.metric-icon.purple { background: var(--color-purple-light); }
.metric-icon.rose   { background: var(--color-red-light); }
.metric-icon.orange { background: var(--color-orange-light); }

.metric-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -1px;
}

.metric-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ==================== CARDS ==================== */
.card {
  background: var(--color-card);
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-sub {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Alias para compatibilidad */
.glass-card {
  background: var(--color-card);
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--ease);
}

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

/* ==================== STATUS DOTS ==================== */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.green { background: var(--color-green); box-shadow: 0 0 6px var(--color-green); }
.status-dot.amber { background: var(--color-amber); box-shadow: 0 0 6px var(--color-amber); }
.status-dot.red   { background: var(--color-red);   box-shadow: 0 0 6px var(--color-red); }

/* ==================== TABLES ==================== */
.table-container {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: var(--border);
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.custom-table th {
  background: var(--color-surface);
  color: var(--text-secondary);
  padding: 12px 16px;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  border-bottom: var(--border);
}

.custom-table td {
  padding: 13px 16px;
  border-bottom: var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

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

.custom-table tr:hover td { background: #fafafa; }

/* ==================== BADGES ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-active     { background: var(--color-green-light); color: #059669; }
.badge-pending    { background: var(--color-amber-light); color: #d97706; }
.badge-rejected   { background: var(--color-red-light);   color: var(--color-red); }
.badge-deactivated{ background: #f3f4f6; color: #6b7280; }
.badge-expired    { background: #f3f4f6; color: #9ca3af; }
.badge-matriz     { background: var(--color-purple-light); color: var(--color-purple); }
.badge-master     { background: var(--color-blue-light);   color: var(--color-blue); }
.badge-normal     { background: var(--color-green-light);  color: var(--color-green); }

/* ==================== PRODUCT CHIPS ==================== */
.product-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.79rem;
}

.product-venta    { background: #e8f0fe; color: #1a73e8; }
.product-checador { background: #e6f9f1; color: #1a8f5e; }
.product-backup   { background: #f0e8ff; color: #7c4dff; }

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.87rem;
  cursor: pointer;
  transition: var(--ease);
  border: 1.5px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-purple);
  color: white;
  box-shadow: 0 4px 14px rgba(124,77,255,0.35);
}
.btn-primary:hover {
  background: #6c3de8;
  box-shadow: 0 6px 20px rgba(124,77,255,0.5);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--color-green);
  color: white;
  box-shadow: 0 4px 14px rgba(38,196,133,0.3);
}
.btn-success:hover { background: #1db57a; }

.btn-danger {
  background: var(--color-red);
  color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-warning {
  background: var(--color-amber);
  color: white;
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: #e5e7eb;
}
.btn-outline:hover {
  background: var(--color-purple-light);
  color: var(--color-purple);
  border-color: var(--color-purple);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.79rem;
  border-radius: var(--radius-sm);
}

/* ==================== FORMS ==================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
  background: var(--color-surface);
  border: var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: var(--ease);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--color-purple);
  box-shadow: 0 0 0 3px var(--color-purple-light);
  background: white;
}

.form-input.error, .form-select.error {
  border-color: var(--color-red);
  box-shadow: 0 0 0 3px var(--color-red-light);
}

.error-text { color: var(--color-red); font-size: 0.78rem; font-weight: 500; }

/* ==================== MODALS ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 16, 64, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background: white;
  border: var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 32px 64px rgba(76,53,181,0.2);
  padding: 28px;
  position: relative;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ==================== CERTIFICATE ==================== */
.certificate-preview {
  background: #ffffff;
  color: #1e293b;
  border-radius: var(--radius-md);
  padding: 2.5rem;
  border: 8px double #1e3a8a;
  position: relative;
  font-family: 'Inter', sans-serif;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.cert-watermark {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 5rem;
  font-weight: 900;
  color: rgba(30, 58, 138, 0.04);
  pointer-events: none;
  white-space: nowrap;
}

/* ==================== SECTION TITLES ==================== */
.section-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.section-sub {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* ==================== APPROVAL CARD ==================== */
.approval-card {
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .main-area { margin-left: 60px; }
  .topbar-search { width: 180px; }
  .main-content { padding: 16px; }
}

@media (max-width: 640px) {
  .topbar-search { display: none; }
  .welcome-emoji { display: none; }
  .grid-metrics { grid-template-columns: repeat(2, 1fr); }
}

/* ==================== SYSTEM REPORT & ACTION BUTTONS ==================== */
.btn-whatsapp {
  background: #25d366;
  color: white !important;
  border-color: #25d366;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
}
.btn-whatsapp:hover {
  background: #1eb954;
  border-color: #1eb954;
}

.report-system-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.report-tab-btn {
  padding: 10px 20px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  background: var(--color-card);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--ease);
}

.report-tab-btn:hover {
  background: var(--color-surface);
  color: var(--text-primary);
  border-color: #cbd5e1;
}

.report-tab-btn.active {
  background: var(--color-sidebar);
  color: #ffffff;
  border-color: var(--color-sidebar);
  box-shadow: 0 4px 14px rgba(76, 53, 181, 0.25);
}

.report-tab-btn.active.tab-checador {
  background: #059669;
  border-color: #059669;
}

.report-tab-btn.active.tab-backup {
  background: #7c4dff;
  border-color: #7c4dff;
}

.report-tab-btn.active.tab-venta {
  background: #2563eb;
  border-color: #2563eb;
}

.badge-vigente {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.badge-por-vencer {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-vencida {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* ==================== PRINT STYLES ==================== */
@media print {
  body * {
    visibility: hidden !important;
  }
  #printable-certificate, #printable-certificate *,
  #printable-report, #printable-report * {
    visibility: visible !important;
  }
  #printable-certificate, #printable-report {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 24px;
    box-shadow: none !important;
    background: #ffffff !important;
    color: #0f172a !important;
  }
  .no-print {
    display: none !important;
  }
}
