/* =============================================
   BitácoraEdificio — Estilos globales
   ============================================= */

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

:root {
  --primary: #1D4ED8;
  --primary-dark: #1e40af;
  --secondary: #0891B2;
  --accent: #0e7490;
  --bg: #f0f4f8;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #e2e8f0;
  --text: #1a1a2e;
  --text2: #4b5563;
  --text3: #9ca3af;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.08);

  /* estados */
  --ok: #16a34a;       --ok-bg: #f0fdf4;     --ok-border: #bbf7d0;
  --warn: #d97706;     --warn-bg: #fffbeb;   --warn-border: #fde68a;
  --urg: #dc2626;      --urg-bg: #fef2f2;    --urg-border: #fecaca;
  --pend: #2563eb;     --pend-bg: #eff6ff;   --pend-border: #bfdbfe;
  --info: #0891B2;     --info-bg: #f0fdfa;   --info-border: #99f6e4;

  /* sidebar */
  --sidebar-w: 240px;
}

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

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--text);
  color: white;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .app-name {
  font-size: 17px;
  font-weight: 600;
  color: white;
  margin-bottom: 2px;
}

.sidebar-brand .app-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-section {
  padding: 16px 12px 8px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.65);
  font-size: 14px;
  font-weight: 400;
  transition: all 0.15s;
  cursor: pointer;
  text-decoration: none !important;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: white;
  text-decoration: none;
}

.nav-item.active {
  background: rgba(255,255,255,0.12);
  color: white;
  font-weight: 500;
}

.nav-item .nav-icon { font-size: 18px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 500; color: white; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.45); }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
}

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

.topbar-title { font-size: 17px; font-weight: 600; color: var(--text); }
.topbar-sub   { font-size: 13px; color: var(--text3); margin-top: 1px; }

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

/* ---- Componentes ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}

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

.card-title { font-size: 15px; font-weight: 600; }
.card-sub   { font-size: 13px; color: var(--text3); margin-top: 2px; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Stat cards */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
}

.stat-value { font-size: 28px; font-weight: 600; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text3); }
.stat-trend { font-size: 12px; margin-top: 6px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-ok     { background: var(--ok-bg);   color: var(--ok);   border: 1px solid var(--ok-border); }
.badge-warn   { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border); }
.badge-urg    { background: var(--urg-bg);  color: var(--urg);  border: 1px solid var(--urg-border); }
.badge-pend   { background: var(--pend-bg); color: var(--pend); border: 1px solid var(--pend-border); }
.badge-info   { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-border); }
.badge-gray   { background: #f3f4f6; color: #4b5563; border: 1px solid #e5e7eb; }

.badge-blue   { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-purple { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; }
.badge-teal   { background: #f0fdfa; color: #0f766e; border: 1px solid #99f6e4; }

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  font-family: inherit;
  text-decoration: none !important;
}

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

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface2); }

.btn-danger { background: var(--urg-bg); color: var(--urg); border: 1px solid var(--urg-border); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* Formularios */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,78,216,0.08); }

textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* Tabla */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { background: var(--surface2); font-size: 12px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

/* Checklist items */
.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.checklist-item:last-child { border-bottom: none; }

.check-options { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.check-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid;
  background: transparent;
  font-family: inherit;
  transition: all 0.15s;
}

.check-btn.ok     { border-color: var(--ok-border);   color: var(--ok);   }
.check-btn.ok.sel { background: var(--ok-bg); }
.check-btn.obs    { border-color: var(--warn-border);  color: var(--warn); }
.check-btn.obs.sel{ background: var(--warn-bg); }
.check-btn.urg    { border-color: var(--urg-border);   color: var(--urg);  }
.check-btn.urg.sel{ background: var(--urg-bg); }
.check-btn.na     { border-color: var(--border);       color: var(--text3);}
.check-btn.na.sel { background: var(--surface2); }

.obs-field {
  margin-top: 10px;
  display: none;
}
.obs-field.visible { display: block; }

/* Alertas */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 10px; }
.alert-ok   { background: var(--ok-bg);   border: 1px solid var(--ok-border);   color: var(--ok); }
.alert-warn { background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn); }
.alert-urg  { background: var(--urg-bg);  border: 1px solid var(--urg-border);  color: var(--urg); }
.alert-info { background: var(--pend-bg); border: 1px solid var(--pend-border); color: var(--pend); }

/* Progress bar */
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; background: var(--primary); transition: width 0.3s; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 17px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text3); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--surface2); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab { padding: 8px 16px; font-size: 14px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--text3); font-weight: 500; transition: all 0.15s; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover { color: var(--text); }

/* Responsive */
@media (max-width: 900px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
}

/* Utils */
.d-flex   { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.mt-4 { margin-top: 24px; }
.text-muted { color: var(--text3); font-size: 13px; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.text-sm { font-size: 13px; }
