/* ═══════════════════════════════════════════════════════════════════════════
   CRM Obra Blanca Expo 2026 — CSS puro, inspirado en Frappe Framework
   ═══════════════════════════════════════════════════════════════════════════ */

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

/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
  --font-family:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-size-base: 13px;
  --font-size-sm:   12px;
  --font-size-lg:   15px;
  --font-size-xl:   18px;

  --color-bg:             #f4f5f6;
  --color-surface:        #ffffff;
  --color-border:         #e2e8f0;
  --color-border-dark:    #d1d8dd;
  --color-text:           #1c1c1c;
  --color-text-secondary: #6c7680;
  --color-text-muted:     #98a1ab;

  --color-primary:      #2490ef;
  --color-primary-dark: #1a7fd4;
  --color-primary-bg:   #e8f3fd;

  --color-success:      #28a745;
  --color-success-bg:   #e8f5e9;
  --color-warning:      #f8a100;
  --color-warning-bg:   #fff8e1;
  --color-danger:       #e03636;
  --color-danger-bg:    #fdecea;
  --color-info:         #2490ef;
  --color-info-bg:      #e8f3fd;
  --color-muted:        #6c7680;
  --color-muted-bg:     #f1f3f4;
  --color-dnc:          #7f1d1d;
  --color-dnc-bg:       #fef2f2;
  --color-special:      #6e57e0;
  --color-special-bg:   #ede9fe;

  --sidebar-width: 220px;
  --topbar-height: 48px;
  --border-radius: 6px;
  --border-radius-sm: 4px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06);
  --shadow-md:  0 4px 12px rgba(0,0,0,.1);
  --transition: .15s ease;
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: var(--font-size-base); -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-dark); text-decoration: underline; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ─── Layout: sidebar + main ─────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}
.sidebar-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.2;
}
.sidebar-logo span {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--color-text-muted);
}
.sidebar-nav {
  flex: 1;
  padding: 8px 0;
}
.nav-section {
  padding: 12px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  font-size: 13px;
  color: var(--color-text-secondary);
  border-radius: 0;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-decoration: none !important;
}
.nav-item:hover {
  background: var(--color-bg);
  color: var(--color-text);
  text-decoration: none !important;
}
.nav-item.active {
  background: var(--color-primary-bg);
  color: var(--color-primary);
  font-weight: 500;
}
.nav-item svg {
  width: 16px; height: 16px;
  flex-shrink: 0;
  opacity: .7;
}
.nav-item.active svg { opacity: 1; }
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  font-size: 12px;
  color: var(--color-text-muted);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.sidebar-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--color-primary-bg);
  color: var(--color-primary);
  font-weight: 600;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

/* ─── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-muted);
}
.breadcrumb a { color: var(--color-text-muted); }
.breadcrumb a:hover { color: var(--color-primary); }
.breadcrumb .sep { color: var(--color-border-dark); }
.breadcrumb .current { color: var(--color-text); font-weight: 500; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--color-text-secondary);
}

/* ─── Main content ───────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 24px;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
}
.page-actions {
  display: flex;
  gap: 8px;
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}
.card-body { padding: 18px; }
.card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  border-radius: 0 0 var(--border-radius) var(--border-radius);
}

/* ─── Stat cards ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 500;
  margin-bottom: 6px;
}
.stat-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1;
}
.stat-sub {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 4px;
}
.stat-card.stat-success .stat-value { color: var(--color-success); }
.stat-card.stat-info    .stat-value { color: var(--color-primary); }
.stat-card.stat-danger  .stat-value { color: var(--color-danger); }
.stat-card.stat-warning .stat-value { color: var(--color-warning); }

/* ─── Tablas ─────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--border-radius);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  background: var(--color-bg);
  padding: 9px 14px;
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
tbody td {
  padding: 9px 14px;
  color: var(--color-text);
  vertical-align: middle;
}
tbody td.muted { color: var(--color-text-muted); }
.row-link { cursor: pointer; }

/* ─── Formularios ────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full { grid-column: 1 / -1; }
label {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
}
.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="search"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--color-border-dark);
  border-radius: var(--border-radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  -webkit-appearance: none;
}
.form-control:focus,
input:focus, select:focus, textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(36,144,239,.15);
}
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }
.form-hint { font-size: 11px; color: var(--color-text-muted); }
.form-section {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
  margin-top: 24px;
}
.form-section:first-child { margin-top: 0; }

/* ─── Botones ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--border-radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  text-decoration: none !important;
  white-space: nowrap;
  line-height: 1;
}
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); color:#fff; }
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border-dark);
}
.btn-secondary:hover { background: var(--color-bg); color: var(--color-text); }
.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn-danger:hover { background: #c92a2a; border-color: #c92a2a; color:#fff; }
.btn-ghost {
  background: transparent;
  color: var(--color-primary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--color-primary-bg); }
.btn-icon {
  padding: 6px;
  border-radius: var(--border-radius-sm);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--color-bg); color: var(--color-text); }
.btn svg { width: 14px; height: 14px; }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-success  { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning  { background: var(--color-warning-bg); color: #92600a; }
.badge-danger   { background: var(--color-danger-bg);  color: var(--color-danger); }
.badge-info     { background: var(--color-info-bg);    color: var(--color-info); }
.badge-muted    { background: var(--color-muted-bg);   color: var(--color-muted); }
.badge-dnc      { background: var(--color-dnc-bg);     color: var(--color-dnc); }
.badge-special  { background: var(--color-special-bg); color: var(--color-special); }

/* ─── Alertas ────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--border-radius-sm);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 16px;
}
.alert-success { background: var(--color-success-bg); color: #1a6e29; border-left: 3px solid var(--color-success); }
.alert-danger  { background: var(--color-danger-bg);  color: #a61818; border-left: 3px solid var(--color-danger); }
.alert-warning { background: var(--color-warning-bg); color: #7a5200; border-left: 3px solid var(--color-warning); }
.alert-info    { background: var(--color-info-bg);    color: #1a5fa3; border-left: 3px solid var(--color-info); }

/* ─── Progress bar ───────────────────────────────────────────────────────── */
.progress {
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
  margin: 6px 0;
}
.progress-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  transition: width .4s ease;
}
.progress-bar.success { background: var(--color-success); }
.progress-bar.warning { background: var(--color-warning); }

/* ─── Filtros ────────────────────────────────────────────────────────────── */
.filters {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.filter-group { display: flex; flex-direction: column; gap: 3px; min-width: 140px; }
.filter-group label { font-size: 11px; color: var(--color-text-muted); }
.filter-group input,
.filter-group select { padding: 5px 8px; font-size: 12px; }
.filter-actions { display: flex; gap: 6px; margin-left: auto; align-self: flex-end; }

/* ─── Paginación ─────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 4px;
  padding: 14px 18px;
  justify-content: center;
  flex-wrap: wrap;
}
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--border-radius-sm);
  font-size: 12px;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  text-decoration: none !important;
}
.page-link:hover { border-color: var(--color-primary); color: var(--color-primary); }
.page-link.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ─── Modales (Alpine.js) ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-md);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 14px; font-weight: 600; }
.modal-body  { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ─── Login page ─────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
}
.login-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}
.login-sub {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 24px;
}
.login-otp-code {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 16px 0;
}
.otp-digit {
  width: 44px;
  height: 52px;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  border: 2px solid var(--color-border-dark);
  border-radius: var(--border-radius-sm);
  letter-spacing: 2px;
}
.otp-digit:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(36,144,239,.15);
}

/* ─── Detalle de contacto ─────────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}
.detail-field { margin-bottom: 12px; }
.detail-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 2px;
}
.detail-value {
  font-size: 13px;
  color: var(--color-text);
}

/* ─── Timeline de eventos ────────────────────────────────────────────────── */
.timeline { margin-top: 8px; }
.timeline-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 12px;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
  margin-top: 4px;
  flex-shrink: 0;
}
.timeline-time { color: var(--color-text-muted); white-space: nowrap; }
.timeline-text { color: var(--color-text); flex: 1; }

/* ─── Upload area ────────────────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--color-border-dark);
  border-radius: var(--border-radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
}
.upload-icon { font-size: 40px; margin-bottom: 12px; opacity: .4; }
.upload-text { font-size: 14px; font-weight: 500; color: var(--color-text); }
.upload-hint { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }

/* ─── Indicador de carga ─────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Reporte público ────────────────────────────────────────────────────── */
.report-header {
  text-align: center;
  padding: 32px 0 24px;
}
.report-title { font-size: 24px; font-weight: 600; }
.report-sub { font-size: 14px; color: var(--color-text-secondary); margin-top: 4px; }
.chart-container { position: relative; height: 280px; }

/* ─── Setup page ─────────────────────────────────────────────────────────── */
.setup-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
}
.setup-step:last-child { border-bottom: none; }
.setup-step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--color-primary-bg);
  color: var(--color-primary);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.setup-step-num.ok { background: var(--color-success-bg); color: var(--color-success); }
.setup-step-num.err { background: var(--color-danger-bg); color: var(--color-danger); }

/* ─── Utilities ──────────────────────────────────────────────────────────── */
.text-muted     { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-sm        { font-size: var(--font-size-sm); }
.text-xs        { font-size: 11px; }
.text-center    { text-align: center; }
.text-right     { text-align: right; }
.text-bold      { font-weight: 600; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 18px; }
.mb-4 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.w-full { width: 100%; }
.hidden { display: none; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.code-block {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  padding: 10px 12px;
  overflow-x: auto;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .filters { flex-direction: column; }
  .filter-actions { width: 100%; justify-content: flex-start; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .btn-mobile-hide { display: none; }
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--color-text);
  }
}
@media (min-width: 769px) {
  .mobile-menu-btn { display: none; }
}
