/* ═══════════════════════════════════════════════════
   Harinas Elizondo — Sistema de Certificados de Calidad
   Estilos globales
   ═══════════════════════════════════════════════════ */

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

/* ── Variables ── */
:root {
  --gold:        #C9973A;
  --gold-light:  #E8B84B;
  --gold-dark:   #9A7228;
  --sidebar-bg:  #0F1117;
  --sidebar-w:   260px;
  --card-bg:     #1C1F2E;
  --body-bg:     #12141F;
  --surface:     #1E2133;
  --border:      rgba(255,255,255,0.07);
  --text:        #E8ECF0;
  --text-muted:  #8891A4;
  --success:     #2ECC71;
  --danger:      #E74C3C;
  --warning:     #F39C12;
  --info:        #3498DB;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 4px 24px rgba(0,0,0,0.35);
  --transition:  0.22s ease;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--body-bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  font-size: 14px;
}

/* ═══════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(201, 151, 58, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(201, 151, 58, 0.08) 0%, transparent 50%),
    linear-gradient(135deg, #0A0C14 0%, #12141F 50%, #0E1018 100%);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(201,151,58,0.06) 0%, transparent 70%);
  top: -200px; left: -200px;
  animation: pulse-glow 6s ease-in-out infinite;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(201,151,58,0.04) 0%, transparent 70%);
  bottom: -100px; right: -100px;
  animation: pulse-glow 8s ease-in-out infinite reverse;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

.login-box {
  background: rgba(28, 31, 46, 0.9);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(201, 151, 58, 0.2);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.03);
  position: relative;
  z-index: 1;
  animation: slide-up 0.5s ease;
}

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

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(201,151,58,0.3);
}

.login-logo h1 {
  font-family: 'Poppins', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.login-logo p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

/* ── Form Controls ── */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

.form-control {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px 16px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,151,58,0.12);
  background: rgba(255,255,255,0.06);
}

.form-control::placeholder { color: rgba(136,145,164,0.6); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #fff;
  box-shadow: 0 4px 16px rgba(201,151,58,0.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(201,151,58,0.45);
  color: #fff;
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: rgba(255,255,255,0.07);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.11);
  color: var(--text);
}

.btn-danger {
  background: rgba(231,76,60,0.15);
  color: #E74C3C;
  border: 1px solid rgba(231,76,60,0.25);
}
.btn-danger:hover { background: rgba(231,76,60,0.25); color: #E74C3C; }

.btn-success {
  background: rgba(46,204,113,0.15);
  color: #2ECC71;
  border: 1px solid rgba(46,204,113,0.25);
}
.btn-success:hover { background: rgba(46,204,113,0.25); color: #2ECC71; }

.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-full { width: 100%; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); }

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-error { background: rgba(231,76,60,0.12); border: 1px solid rgba(231,76,60,0.25); color: #E74C3C; }
.alert-success { background: rgba(46,204,113,0.12); border: 1px solid rgba(46,204,113,0.25); color: #2ECC71; }
.alert-warning { background: rgba(243,156,18,0.12); border: 1px solid rgba(243,156,18,0.25); color: #F39C12; }
.alert-info { background: rgba(52,152,219,0.12); border: 1px solid rgba(52,152,219,0.25); color: #3498DB; }

/* ═══════════════════════════════════════════
   LAYOUT — SIDEBAR + MAIN
   ═══════════════════════════════════════════ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: transparent; 
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; 
}

.brand-icon img {
    width: 100%;    
    height: 100%;
    object-fit: cover; 
    border-radius: 4px;
}

.sidebar-brand .brand-text {
  font-family: 'Poppins', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-brand .brand-sub {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 12px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(201,151,58,0.15), rgba(201,151,58,0.08));
  color: var(--gold-light);
  border: 1px solid rgba(201,151,58,0.15);
}

.nav-item .nav-icon {
  width: 20px; height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--gold);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
}

.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  margin-top: 4px;
  width: 100%;
  border: none;
  background: none;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}
.logout-btn:hover { background: rgba(231,76,60,0.1); color: #E74C3C; }

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.topbar-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

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

.page-content {
  padding: 32px;
  flex: 1;
}

/* ═══════════════════════════════════════════
   CARDS & STATS
   ═══════════════════════════════════════════ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), border-color var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(201,151,58,0.25);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  opacity: 0.06;
  transform: translate(30px, -30px);
}

.stat-card.gold::before { background: var(--gold); }
.stat-card.green::before { background: var(--success); }
.stat-card.blue::before { background: var(--info); }
.stat-card.red::before { background: var(--danger); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.gold { background: rgba(201,151,58,0.15); }
.stat-icon.green { background: rgba(46,204,113,0.15); }
.stat-icon.blue { background: rgba(52,152,219,0.15); }
.stat-icon.red { background: rgba(231,76,60,0.15); }

.stat-info { flex: 1; }

.stat-value {
  font-size: 28px;
  font-weight: 800;
  font-family: 'Poppins', sans-serif;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

/* ═══════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════ */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table thead th {
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table tbody tr {
  transition: background var(--transition);
}

.data-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text);
  vertical-align: middle;
}

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

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-activo { background: rgba(46,204,113,0.15); color: #2ECC71; }
.badge-inactivo { background: rgba(243,156,18,0.15); color: #F39C12; }
.badge-baja { background: rgba(231,76,60,0.15); color: #E74C3C; }
.badge-consulta { background: rgba(52,152,219,0.15); color: #3498DB; }
.badge-transaccion { background: rgba(201,151,58,0.15); color: var(--gold-light); }
.badge-normal { background: rgba(46,204,113,0.15); color: #2ECC71; }
.badge-alto { background: rgba(231,76,60,0.15); color: #E74C3C; }
.badge-bajo { background: rgba(52,152,219,0.15); color: #3498DB; }

/* ── Actions ── */
.table-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ═══════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-group { margin-bottom: 0; }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238891A4' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

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

.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
}

.form-check-input {
  width: 18px; height: 18px;
  accent-color: var(--gold);
  cursor: pointer;
}

.form-check-label {
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

/* ═══════════════════════════════════════════
   FILTROS Y BÚSQUEDA
   ═══════════════════════════════════════════ */
.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  max-width: 400px;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
}

.search-input-wrapper input {
  padding-left: 38px;
}

/* ═══════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 20px;
}

/* ═══════════════════════════════════════════
   BREADCRUMB
   ═══════════════════════════════════════════ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
  list-style: none;
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.breadcrumb a:hover { color: var(--gold-light); }

.breadcrumb .separator { opacity: 0.4; }

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

/* ═══════════════════════════════════════════
   MODALS (confirmación)
   ═══════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-overlay.show { display: flex; }

.modal-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: slide-up 0.3s ease;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.modal-body {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ═══════════════════════════════════════════
   CERTIFICATE PREVIEW
   ═══════════════════════════════════════════ */
.cert-preview-card {
  background: linear-gradient(135deg, rgba(201,151,58,0.05), rgba(201,151,58,0.02));
  border: 1px solid rgba(201,151,58,0.2);
  border-radius: var(--radius);
  padding: 32px;
}

.cert-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(201,151,58,0.2);
}

.cert-title {
  font-family: 'Poppins', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--gold-light);
}

.cert-num {
  font-size: 12px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════
   DASHBOARD RECENT ACTIVITY
   ═══════════════════════════════════════════ */
.activity-list { display: flex; flex-direction: column; gap: 12px; }

.activity-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: background var(--transition);
}

.activity-item:hover { background: rgba(255,255,255,0.03); }

.activity-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.activity-dot.gold { background: var(--gold); }
.activity-dot.green { background: var(--success); }
.activity-dot.blue { background: var(--info); }

.activity-text { flex: 1; font-size: 13px; }
.activity-time { font-size: 11px; color: var(--text-muted); }

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 12px 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-box { padding: 32px 24px; }
}

/* ── Utilities ── */
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-4 { margin-bottom: 16px !important; }
.mb-8 { margin-bottom: 32px !important; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.text-muted { color: var(--text-muted) !important; }
.text-gold { color: var(--gold-light) !important; }
.text-sm { font-size: 12px !important; }
.font-bold { font-weight: 700 !important; }
.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
