/* ====================================================
   CIC SISTEMA — Estilos globales
   ==================================================== */

:root {
  /* Paleta CIC */
  --cic-primary: #0f172a;
  --cic-primary-light: #1e293b;
  --cic-accent: #f97316;
  --cic-accent-dark: #ea580c;
  --cic-bg: #f8fafc;
  --cic-surface: #ffffff;
  --cic-border: #e2e8f0;
  --cic-text: #0f172a;
  --cic-text-muted: #64748b;
  --cic-success: #10b981;
  --cic-warning: #f59e0b;
  --cic-danger: #ef4444;
  --cic-info: #3b82f6;

  /* Espaciado y forma */
  --cic-radius: 10px;
  --cic-radius-sm: 6px;
  --cic-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --cic-shadow: 0 4px 12px -2px rgb(15 23 42 / 0.08);
  --cic-shadow-lg: 0 10px 30px -10px rgb(15 23 42 / 0.2);
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--cic-bg);
  color: var(--cic-text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

/* ======================= LOGIN ======================= */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  padding: 20px;
}

.login-card {
  background: var(--cic-surface);
  border-radius: var(--cic-radius);
  box-shadow: var(--cic-shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.login-brand {
  text-align: center;
  margin-bottom: 30px;
}

.login-brand .logo {
  width: 60px;
  height: 60px;
  margin: 0 auto 12px;
  background: var(--cic-primary);
  color: white;
  border-radius: var(--cic-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.login-brand h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--cic-text);
}

.login-brand p {
  font-size: 13px;
  color: var(--cic-text-muted);
  margin: 0;
}

/* ======================= LAYOUT ADMIN ======================= */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--cic-primary);
  color: #cbd5e1;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand .logo {
  width: 34px;
  height: 34px;
  background: var(--cic-accent);
  border-radius: var(--cic-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: white;
  font-size: 14px;
  letter-spacing: -0.02em;
}

.sidebar-brand .name {
  font-weight: 700;
  color: white;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.sidebar-brand .subtitle {
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  padding: 12px 0;
}

.sidebar-section {
  padding: 12px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #475569;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 13.5px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.04);
  color: white;
}

.sidebar-nav a.active {
  background: rgba(249, 115, 22, 0.1);
  color: var(--cic-accent);
  border-left-color: var(--cic-accent);
}

.sidebar-nav a.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.sidebar-nav a .icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
}

.sidebar-nav a .badge {
  margin-left: auto;
  background: #334155;
  color: #94a3b8;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}

.main-content {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--cic-surface);
  border-bottom: 1px solid var(--cic-border);
  padding: 14px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
  color: var(--cic-text);
}

.topbar .user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

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

.topbar .user-info {
  text-align: right;
  line-height: 1.2;
}

.topbar .user-info .name { font-weight: 600; }
.topbar .user-info .role { font-size: 11px; color: var(--cic-text-muted); text-transform: uppercase; }

.btn-logout {
  background: transparent;
  border: 1px solid var(--cic-border);
  padding: 6px 12px;
  border-radius: var(--cic-radius-sm);
  font-size: 12px;
  cursor: pointer;
  color: var(--cic-text-muted);
}
.btn-logout:hover { background: var(--cic-bg); color: var(--cic-danger); }

.content {
  padding: 30px;
  flex: 1;
}

/* ======================= CARDS ======================= */
.card {
  background: var(--cic-surface);
  border: 1px solid var(--cic-border);
  border-radius: var(--cic-radius);
  box-shadow: var(--cic-shadow-sm);
}

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

.card-header h2 {
  font-size: 16px;
  margin: 0;
  font-weight: 600;
}

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

.card-body { padding: 24px; }

/* ======================= BUTTONS ======================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--cic-radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--cic-primary);
  color: white;
}
.btn-primary:hover { background: var(--cic-primary-light); }

.btn-accent {
  background: var(--cic-accent);
  color: white;
}
.btn-accent:hover { background: var(--cic-accent-dark); }

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

.btn-danger {
  background: var(--cic-danger);
  color: white;
}
.btn-danger:hover { filter: brightness(0.9); }

.btn-sm { padding: 6px 10px; font-size: 12px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ======================= FORMS ======================= */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--cic-text);
}

.form-group label .required { color: var(--cic-danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--cic-border);
  border-radius: var(--cic-radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--cic-surface);
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--cic-accent);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-help {
  font-size: 11.5px;
  color: var(--cic-text-muted);
  margin-top: 4px;
}

/* ======================= TABLES ======================= */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cic-text-muted);
  border-bottom: 1px solid var(--cic-border);
  background: var(--cic-bg);
}

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

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

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

.table .actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ======================= BADGES ======================= */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #e2e8f0; color: #475569; }
.badge-accent { background: #ffedd5; color: #c2410c; }

/* ======================= MODALS ======================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

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

.modal {
  background: var(--cic-surface);
  border-radius: var(--cic-radius);
  box-shadow: var(--cic-shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.modal-header h3 { margin: 0; font-size: 16px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--cic-text-muted);
  padding: 0;
  line-height: 1;
}

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--cic-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ======================= TOAST ======================= */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--cic-surface);
  border-left: 4px solid var(--cic-info);
  border-radius: var(--cic-radius-sm);
  box-shadow: var(--cic-shadow-lg);
  padding: 12px 16px;
  min-width: 260px;
  font-size: 13px;
  animation: toastIn 0.2s ease-out;
}

.toast.success { border-left-color: var(--cic-success); }
.toast.danger { border-left-color: var(--cic-danger); }
.toast.warning { border-left-color: var(--cic-warning); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ======================= UTILIDADES ======================= */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--cic-text-muted);
}

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

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--cic-text);
  margin: 0 0 6px;
}

.empty-state p { font-size: 13px; margin: 0 0 16px; }

.alert {
  padding: 12px 16px;
  border-radius: var(--cic-radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

.text-muted { color: var(--cic-text-muted); }
.text-sm { font-size: 12px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }

/* Responsive básico */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}
