/* ============================================================
   FibraGest — Hoja de estilos principal
   ============================================================ */

/* --- Variables ------------------------------------------- */
:root {
  --primary:        #0066cc;
  --primary-dark:   #004fa3;
  --primary-light:  #3385d6;
  --secondary:      #00b4d8;
  --success:        #22c55e;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --info:           #0ea5e9;
  --sidebar-bg:     #0a0f1e;
  --sidebar-hover:  #131b2e;
  --sidebar-active: #1a2744;
  --sidebar-border: rgba(255,255,255,.07);
  --sidebar-text:   #94a3b8;
  --sidebar-text-active: #ffffff;
  --topbar-bg:      #ffffff;
  --body-bg:        #f0f4f8;
  --card-bg:        #ffffff;
  --border-color:   #e2e8f0;
  --text-primary:   #1e293b;
  --text-secondary: #64748b;
  --sidebar-w:      265px;
  --topbar-h:       64px;
  --radius:         10px;
  --shadow:         0 1px 3px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.06);
  --shadow-md:      0 4px 16px rgba(0,0,0,.10);
}

/* --- Reset & Base ---------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--body-bg);
  color: var(--text-primary);
  line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

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

/* --- Sidebar ---------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 1000;
  transition: transform .3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--sidebar-border);
  background: #fff;
}
.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}
.sidebar-logo-text { color: #fff; font-weight: 700; font-size: 1rem; line-height: 1.2; }
.sidebar-logo-sub  { color: var(--sidebar-text); font-size: .7rem; font-weight: 400; }

.sidebar-user {
  padding: 14px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-avatar {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .85rem;
  flex-shrink: 0;
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name  { color: #fff; font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role  { color: var(--sidebar-text); font-size: .7rem; }

.sidebar-nav { padding: 10px 0; flex: 1; }

.sidebar-section-title {
  padding: 10px 20px 4px;
  color: var(--sidebar-text);
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--sidebar-text);
  transition: background .15s, color .15s;
  font-size: .855rem;
  border-left: 3px solid transparent;
}
.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.sidebar-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  border-left-color: var(--primary);
}
.sidebar-link i { width: 18px; text-align: center; font-size: .9rem; }
.sidebar-link .badge-count {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .65rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

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

/* --- Topbar ----------------------------------------------- */
.topbar {
  position: fixed;
  top: 0; left: var(--sidebar-w);
  right: 0; height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  z-index: 900;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.topbar-title { font-size: 1.05rem; font-weight: 600; color: var(--text-primary); }
.topbar-right  { display: flex; align-items: center; gap: 14px; }
.topbar-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary);
  font-size: 1rem; padding: 6px 8px; border-radius: 6px;
  transition: background .15s, color .15s;
}
.topbar-btn:hover { background: var(--body-bg); color: var(--text-primary); }
.topbar-user-badge {
  display: flex; align-items: center; gap: 8px;
  font-size: .85rem; color: var(--text-secondary);
}
.topbar-avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .75rem;
}

/* --- Main content ----------------------------------------- */
.main-content {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  flex: 1;
  min-height: 100vh;
}
.page-content { padding: 28px 28px; }

/* --- Page header ------------------------------------------ */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 1.3rem; font-weight: 700; color: var(--text-primary); }
.page-breadcrumb { font-size: .8rem; color: var(--text-secondary); margin-top: 2px; }

/* --- Cards ------------------------------------------------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  overflow: hidden;
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card-bg);
}
.card-header h5 {
  font-size: .95rem; font-weight: 600;
  color: var(--text-primary); margin: 0;
}
.card-body  { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  background: #fafbfc;
  border-top: 1px solid var(--border-color);
}

/* --- Stat cards ------------------------------------------- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  padding: 18px 20px;
  display: flex; align-items: center; gap: 14px;
}
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.stat-icon.blue    { background: #dbeafe; color: #1d4ed8; }
.stat-icon.green   { background: #dcfce7; color: #15803d; }
.stat-icon.orange  { background: #fef3c7; color: #b45309; }
.stat-icon.red     { background: #fee2e2; color: #b91c1c; }
.stat-icon.purple  { background: #ede9fe; color: #6d28d9; }
.stat-icon.teal    { background: #ccfbf1; color: #0f766e; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: .78rem; color: var(--text-secondary); margin-top: 3px; }

/* --- Badges / Estado -------------------------------------- */
.badge-estado {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: .75rem; font-weight: 600; white-space: nowrap;
}
.estado-pendiente  { background: #f1f5f9; color: #475569; }
.estado-asignada   { background: #dbeafe; color: #1d4ed8; }
.estado-en_progreso{ background: #fef3c7; color: #b45309; }
.estado-resuelta   { background: #dcfce7; color: #15803d; }
.estado-cerrada    { background: #f1f5f9; color: #94a3b8; }
.estado-vencida    { background: #fee2e2; color: #b91c1c; }

.badge-prioridad {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: .7rem; font-weight: 600;
}
.prio-baja    { background: #f0fdf4; color: #16a34a; }
.prio-media   { background: #fffbeb; color: #d97706; }
.prio-alta    { background: #fff7ed; color: #c2410c; }
.prio-critica { background: #fef2f2; color: #b91c1c; }

/* --- SLA countdown ---------------------------------------- */
.sla-timer {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .82rem; font-weight: 600; padding: 4px 10px;
  border-radius: 6px; transition: background .3s;
}
.sla-ok      { background: #dcfce7; color: #15803d; }
.sla-warning { background: #fef3c7; color: #92400e; }
.sla-danger  { background: #fee2e2; color: #b91c1c; }
.sla-expired { background: #b91c1c; color: #fff; }

/* --- Tables ----------------------------------------------- */
.table-wrapper { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.tbl thead th {
  background: #f8fafc; border-bottom: 2px solid var(--border-color);
  padding: 10px 14px; text-align: left; font-weight: 600;
  color: var(--text-secondary); white-space: nowrap;
}
table.tbl tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: #f8fafc; }
table.tbl .td-actions { display: flex; gap: 6px; }

/* --- Forms ------------------------------------------------ */
.form-label  { font-size: .85rem; font-weight: 600; color: var(--text-primary); margin-bottom: 5px; }
.form-control, .form-select {
  border: 1px solid var(--border-color);
  border-radius: 7px; padding: 9px 12px;
  font-size: .875rem; color: var(--text-primary);
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,102,204,.12);
  outline: none;
}
.form-control.is-invalid { border-color: var(--danger); }
.form-text { font-size: .78rem; color: var(--text-secondary); margin-top: 4px; }

/* --- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 7px;
  font-size: .855rem; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: all .15s;
  text-decoration: none;
}
.btn-primary    { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-secondary  { background: #fff; color: var(--text-primary); border-color: var(--border-color); }
.btn-secondary:hover { background: #f1f5f9; color: var(--text-primary); }
.btn-success    { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #16a34a; color: #fff; }
.btn-danger     { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-danger:hover  { background: #b91c1c; color: #fff; }
.btn-warning    { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-sm { padding: 5px 11px; font-size: .8rem; }
.btn-icon { padding: 7px 9px; }
.btn-outline-primary {
  background: transparent; color: var(--primary); border-color: var(--primary);
}
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

/* --- Map container ---------------------------------------- */
#map, .map-container {
  width: 100%; height: 340px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  z-index: 0;
}
.map-nav-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 6px;
  background: var(--primary); color: #fff;
  font-size: .8rem; font-weight: 600;
  text-decoration: none; transition: background .15s;
}
.map-nav-btn:hover { background: var(--primary-dark); color: #fff; }

/* --- Geocoding autocomplete ------------------------------ */
.geocode-wrapper { position: relative; }
.geocode-results {
  position: absolute; top: 100%; left: 0; right: 0;
  background: #fff; border: 1px solid var(--border-color);
  border-top: none; border-radius: 0 0 7px 7px;
  max-height: 200px; overflow-y: auto;
  z-index: 10; box-shadow: var(--shadow-md);
  display: none;
}
.geocode-results.open { display: block; }
.geocode-item {
  padding: 9px 13px; cursor: pointer;
  font-size: .83rem; border-bottom: 1px solid #f1f5f9;
  transition: background .1s;
}
.geocode-item:hover { background: #f0f4f8; }
.geocode-item:last-child { border-bottom: none; }

/* --- Alerts ----------------------------------------------- */
.alert {
  padding: 12px 16px; border-radius: 7px;
  font-size: .875rem; margin-bottom: 16px; border: 1px solid transparent;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.alert-danger  { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }

/* --- Timeline (historial) --------------------------------- */
.timeline { padding: 0; list-style: none; position: relative; }
.timeline::before {
  content: ''; position: absolute;
  left: 16px; top: 0; bottom: 0;
  width: 2px; background: var(--border-color);
}
.timeline-item { display: flex; gap: 14px; margin-bottom: 18px; position: relative; }
.timeline-dot {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: .85rem; z-index: 1;
  border: 2px solid #fff; box-shadow: 0 0 0 2px var(--border-color);
}
.timeline-dot.blue   { background: #dbeafe; color: #1d4ed8; }
.timeline-dot.green  { background: #dcfce7; color: #15803d; }
.timeline-dot.orange { background: #fef3c7; color: #b45309; }
.timeline-dot.red    { background: #fee2e2; color: #b91c1c; }
.timeline-dot.gray   { background: #f1f5f9; color: #64748b; }
.timeline-content { flex: 1; padding-top: 5px; }
.timeline-meta { font-size: .78rem; color: var(--text-secondary); margin-top: 3px; }

/* --- Modals ----------------------------------------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1050; display: none; }
.modal-backdrop.open { display: block; }
.modal-box {
  background: #fff; border-radius: 12px;
  max-width: 560px; width: 90%; margin: 60px auto;
  padding: 28px; box-shadow: var(--shadow-md);
  position: relative;
}
.modal-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; font-size: 1.2rem;
  cursor: pointer; color: var(--text-secondary);
}

/* --- Filters bar ------------------------------------------ */
.filters-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.filters-bar .form-control,
.filters-bar .form-select { min-width: 160px; }

/* --- Empty state ------------------------------------------ */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-secondary); }
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; opacity: .4; }

/* --- Login page ------------------------------------------- */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0a0f1e 0%, #0d1635 50%, #071028 100%);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 20% 50%, rgba(0,102,204,.15) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(0,180,216,.1) 0%, transparent 50%);
}
.login-card {
  background: rgba(255,255,255,.97);
  border-radius: 16px;
  padding: 44px 40px;
  width: 420px;
  max-width: 95vw;
  box-shadow: 0 24px 64px rgba(0,0,0,.4);
  position: relative; z-index: 1;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-icon {
  width: 56px; height: 56px; background: var(--primary);
  border-radius: 14px; display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 1.5rem; color: #fff; margin-bottom: 12px;
}
.login-logo h1 { font-size: 1.4rem; font-weight: 800; color: var(--text-primary); margin: 0; }
.login-logo p  { color: var(--text-secondary); font-size: .85rem; margin: 4px 0 0; }

/* --- Responsividad ---------------------------------------- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar { left: 0; }
  .page-content { padding: 16px; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
}

/* --- Utilidades ------------------------------------------- */
.text-muted   { color: var(--text-secondary) !important; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-sm  { font-size: .82rem; }
.gap-2  { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 18px; }
.mb-4 { margin-bottom: 24px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.w-100 { width: 100%; }
.rounded { border-radius: var(--radius); }
.overflow-hidden { overflow: hidden; }

/* --- Scrollbar global ------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
