/* ═══════════════════════════════════════════
   CONEXO POSTVENTAS — Styles
   ═══════════════════════════════════════════ */

:root {
  --green: #1a8a3f;
  --green-light: #22c55e;
  --green-dark: #0f6b2f;
  --gold: #c9a84c;
  --navy: #0f172a;
  --navy-light: #1e293b;
  --dark: #0a0f1a;
  --white: #f8fafc;
  --gray: #94a3b8;
  --gray-dark: #475569;
  --red: #ef4444;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--dark); color: var(--white); min-height: 100vh; }
a { color: var(--green-light); text-decoration: none; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }

/* ── TOPBAR ── */
.topbar {
  background: var(--navy);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky; top: 0; z-index: 100;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { display: flex; align-items: baseline; gap: 0.25rem; }
.logo-conexo { font-size: 1.4rem; font-weight: 800; color: var(--white); }
.logo-postventas { font-size: 1rem; font-weight: 500; color: var(--green-light); }
.nav-link { color: var(--gray); padding: 0.5rem 1rem; border-radius: 8px; transition: all 0.2s; font-size: 0.9rem; }
.nav-link:hover, .nav-link.active { color: var(--white); background: rgba(255,255,255,0.06); }
.nav-admin { border: 1px solid var(--navy-light); }

/* ── CLIENT HERO ── */
.hero-client {
  background: linear-gradient(135deg, var(--navy) 0%, var(--dark) 100%);
  padding: 4rem 0 3rem;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.hero-client h1 { font-size: 2.2rem; font-weight: 700; color: var(--white); margin-bottom: 0.5rem; }
.hero-client p { color: var(--gray); font-size: 1.05rem; max-width: 600px; margin: 0 auto; }

/* ── FORM CARD ── */
.section-form, .section-status { padding: 3rem 0; }
.card-form {
  background: var(--navy);
  border-radius: var(--radius);
  padding: 2.5rem;
  border: 1px solid rgba(255,255,255,0.06);
  max-width: 800px;
  margin: 0 auto;
}
.card-form h2 { font-size: 1.4rem; margin-bottom: 0.25rem; }
.form-subtitle { color: var(--gray); font-size: 0.9rem; margin-bottom: 1.5rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label { font-size: 0.85rem; font-weight: 500; color: var(--gray); }
.field input, .field select, .field textarea {
  background: var(--dark);
  border: 1px solid var(--navy-light);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  color: var(--white);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--green-light);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.15);
}
.full-width { grid-column: 1 / -1; }

.checkbox-field { margin: 1rem 0; }
.checkbox-label { display: flex; align-items: flex-start; gap: 0.6rem; cursor: pointer; color: var(--gray); font-size: 0.85rem; }
.checkbox-label input { margin-top: 0.15rem; width: 18px; height: 18px; accent-color: var(--green-light); }

/* ── BUTTONS ── */
.btn-primary, .btn-secondary {
  padding: 0.8rem 1.8rem;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}
.btn-primary {
  background: var(--green);
  color: var(--white);
  width: 100%;
}
.btn-primary:hover { background: var(--green-dark); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-secondary {
  background: var(--navy-light);
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.1);
}
.btn-secondary:hover { background: var(--navy); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

/* ── STATUS MESSAGES ── */
.status-msg {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  white-space: pre-line;
  font-size: 0.9rem;
}
.status-success { background: rgba(34,197,94,0.1); border: 1px solid var(--green-light); color: var(--green-light); }
.status-error { background: rgba(239,68,68,0.1); border: 1px solid var(--red); color: var(--red); }

/* ── CONSULTA ESTADO ── */
.status-consulta { display: flex; gap: 0.5rem; margin-top: 1rem; }
.input-id { flex: 1; background: var(--dark); border: 1px solid var(--navy-light); border-radius: 8px; padding: 0.7rem 0.9rem; color: var(--white); font-family: inherit; }
.consulta-card { background: var(--navy-light); border-radius: 8px; padding: 1.5rem; }
.consulta-card h3 { margin-bottom: 1rem; }
.consulta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; font-size: 0.9rem; }
.historial-details { margin-top: 1rem; cursor: pointer; }
.historial-details summary { color: var(--green-light); font-weight: 500; }
.historial-item { padding: 0.5rem 0; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 0.85rem; }

/* ── ADMIN AUTH ── */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 2rem;
}
.auth-card {
  background: var(--navy); border-radius: var(--radius);
  padding: 2.5rem; width: 100%; max-width: 400px;
  border: 1px solid rgba(255,255,255,0.06);
}
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-sub { color: var(--gray); font-size: 0.9rem; margin-top: 0.3rem; }
.auth-error { color: var(--red); font-size: 0.85rem; margin-bottom: 1rem; text-align: center; }

/* ── ADMIN HEADER ── */
.admin-header {
  background: var(--navy); border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky; top: 0; z-index: 100;
}
.admin-header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; height: 64px; max-width: 1400px; margin: 0 auto;
}
.admin-user { display: flex; align-items: center; gap: 1rem; font-size: 0.9rem; }
.user-role { color: var(--green-light); background: rgba(34,197,94,0.1); padding: 0.15rem 0.6rem; border-radius: 4px; font-size: 0.75rem; }
.btn-logout { background: transparent; border: 1px solid var(--red); color: var(--red); padding: 0.4rem 1rem; border-radius: 6px; cursor: pointer; font-family: inherit; font-size: 0.8rem; }
.btn-logout:hover { background: rgba(239,68,68,0.1); }

/* ── KPI CARDS ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi-card {
  background: var(--navy); border-radius: var(--radius); padding: 1.25rem;
  border: 1px solid rgba(255,255,255,0.06); text-align: center;
}
.kpi-value { font-size: 2rem; font-weight: 700; color: var(--green-light); }
.kpi-label { font-size: 0.8rem; color: var(--gray); margin-top: 0.3rem; }

/* ── CHARTS ── */
.charts-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
@media (max-width: 900px) { .charts-row { grid-template-columns: 1fr; } }
.chart-card {
  background: var(--navy); border-radius: var(--radius); padding: 1.25rem;
  border: 1px solid rgba(255,255,255,0.06);
}
.chart-card h3 { font-size: 0.95rem; margin-bottom: 1rem; color: var(--gray); }
.chart-visual { display: flex; flex-direction: column; gap: 0.5rem; }
.bar-row { display: flex; align-items: center; gap: 0.6rem; }
.bar-label { font-size: 0.75rem; min-width: 80px; color: var(--gray); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 22px; background: var(--dark); border-radius: 4px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s; }
.bar-value { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); font-size: 0.75rem; font-weight: 600; color: var(--white); }

/* ── ALERTAS ── */
.alertas-section { margin-bottom: 1.5rem; }
.alertas-title { color: var(--red); margin-bottom: 0.75rem; }
.alerta-item { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 1rem; font-size: 0.85rem; }
.alerta-roja { background: rgba(239,68,68,0.1); border: 1px solid var(--red); }
.alerta-amarilla { background: rgba(245,158,11,0.1); border: 1px solid var(--yellow); }

/* ── TABLE ── */
.table-section { margin-bottom: 3rem; }
.table-actions { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.table-actions h3 { flex: 1; }
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid rgba(255,255,255,0.06); }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th { background: var(--navy); padding: 0.75rem; text-align: left; color: var(--gray); font-weight: 500; border-bottom: 1px solid rgba(255,255,255,0.06); }
td { padding: 0.75rem; border-bottom: 1px solid rgba(255,255,255,0.03); }
tr:hover td { background: rgba(255,255,255,0.02); }

.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 500; }
.badge-red { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-yellow { background: rgba(245,158,11,0.15); color: var(--yellow); }
.badge-gray { background: rgba(148,163,184,0.1); color: var(--gray); }
.estado-EnEvaluacion { background: rgba(59,130,246,0.15); color: var(--blue); }
.estado-VisitaProgramada { background: rgba(245,158,11,0.15); color: var(--yellow); }
.estado-IntervencionPlaneada { background: rgba(139,92,246,0.15); color: var(--purple); }
.estado-IntervencionProceso { background: rgba(34,197,94,0.15); color: var(--green-light); }
.estado-Cerrado { background: rgba(34,197,94,0.2); color: var(--green-light); }
.estado-FueraGarantia { background: rgba(239,68,68,0.1); color: var(--red); }

/* ── FOOTER ── */
.footer { text-align: center; padding: 2rem; color: var(--gray-dark); font-size: 0.8rem; border-top: 1px solid rgba(255,255,255,0.06); }

/* ── TABS ── */
.admin-tabs { display: flex; gap: 0.25rem; }
.tab-btn { background: transparent; border: none; color: var(--gray); padding: 0.5rem 1rem; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 0.85rem; font-weight: 500; transition: all 0.2s; }
.tab-btn:hover { background: rgba(255,255,255,0.06); color: var(--white); }
.tab-btn.active { background: var(--green); color: var(--white); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 4rem 2rem; background: var(--navy); border-radius: var(--radius); border: 1px dashed rgba(255,255,255,0.1); }
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { color: var(--white); margin-bottom: 0.5rem; }
.empty-state p { color: var(--gray); font-size: 0.9rem; }
.empty-state a { color: var(--green-light); }
.empty-chart { color: var(--gray-dark); font-size: 0.8rem; text-align: center; padding: 1rem; }

/* ── COUNT BADGE ── */
.count-badge { color: var(--gray); font-size: 0.85rem; font-weight: 400; }

/* ── FILTER GROUP ── */
.filter-group { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.filter-group select, .filter-group input { background: var(--dark); border: 1px solid var(--navy-light); border-radius: 6px; padding: 0.4rem 0.6rem; color: var(--white); font-family: inherit; font-size: 0.8rem; }
.filter-group input { min-width: 180px; }

/* ── MODAL ── */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1rem; backdrop-filter: blur(4px); }
.modal-content { background: var(--navy); border-radius: var(--radius); width: 100%; max-width: 900px; max-height: 90vh; overflow-y: auto; border: 1px solid rgba(255,255,255,0.1); }
.modal-lg { max-width: 960px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1.25rem 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.06); }
.modal-header h3 { font-size: 1.1rem; }
.modal-close { background: none; border: none; color: var(--gray); font-size: 1.5rem; cursor: pointer; padding: 0 0.5rem; }
.modal-close:hover { color: var(--white); }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid rgba(255,255,255,0.06); display: flex; justify-content: flex-end; gap: 0.75rem; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width:768px) { .modal-grid { grid-template-columns: 1fr; } }
.modal-col h4 { font-size: 0.9rem; color: var(--green-light); margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid rgba(255,255,255,0.06); }
.modal-field { margin-bottom: 0.75rem; }
.modal-field label { display: block; font-size: 0.75rem; color: var(--gray); margin-bottom: 0.2rem; font-weight: 500; }
.modal-field input, .modal-field select, .modal-field textarea { width: 100%; background: var(--dark); border: 1px solid var(--navy-light); border-radius: 6px; padding: 0.55rem 0.7rem; color: var(--white); font-family: inherit; font-size: 0.85rem; }
.modal-field input:focus, .modal-field select:focus, .modal-field textarea:focus { outline: none; border-color: var(--green-light); }
.modal-field .readonly { opacity: 0.7; cursor: default; }
.modal-field-row { display: flex; gap: 0.75rem; }
.modal-field .half { flex: 1; }
.modal-field .third { flex: 1; }

/* ── TIMELINE ── */
.timeline-section { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,0.06); }
.timeline-section h4 { font-size: 0.9rem; color: var(--gray); margin-bottom: 1rem; }
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--navy-light); }
.timeline-item { position: relative; padding-bottom: 1rem; }
.timeline-dot { position: absolute; left: -1.35rem; top: 0.25rem; width: 12px; height: 12px; border-radius: 50%; background: var(--green-light); border: 2px solid var(--navy); }
.timeline-content { font-size: 0.8rem; }
.timeline-date { color: var(--gray-dark); font-size: 0.7rem; }
.timeline-action { color: var(--white); margin: 0.15rem 0; }
.timeline-detail { color: var(--gray); }
.timeline-user { color: var(--gray-dark); font-size: 0.7rem; font-style: italic; }

/* ── CIERRE SECTION ── */
.cierre-section { margin-top: 1.5rem; padding: 1rem; background: rgba(34,197,94,0.05); border-radius: 8px; border: 1px solid rgba(34,197,94,0.15); }
.cierre-section h4 { color: var(--green-light); margin-bottom: 0.75rem; }
