/* ============================================================
   COTIZADOR ARQUITECTÓNICO — Estilos Globales
   ============================================================ */

/* ---------- Variables ---------- */
:root {
  --black:       #0a0a0a;
  --dark:        #111118;
  --dark-card:   #16161f;
  --dark-border: rgba(201,168,76,.18);
  --gold:        #c9a84c;
  --gold-light:  #e0c070;
  --gold-dim:    rgba(201,168,76,.15);
  --white:       #f5f3ee;
  --white-dim:   rgba(245,243,238,.7);
  --muted:       #72728a;
  --radius:      14px;
  --radius-sm:   8px;
  --shadow:      0 8px 40px rgba(0,0,0,.5);
  --transition:  .3s cubic-bezier(.4,0,.2,1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--black);
  color: var(--white);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--dark); }
::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 3px; }

/* ---------- Tipografía ---------- */
h1,h2,h3,h4 { font-family: 'Playfair Display', Georgia, serif; line-height: 1.2; }
a { color: var(--gold); text-decoration: none; transition: opacity var(--transition); }
a:hover { opacity: .75; }

/* ---------- Utility ---------- */
.text-gold   { color: var(--gold); }
.text-muted  { color: var(--muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.gap-1  { gap: .5rem; }
.gap-2  { gap: 1rem; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ============================================================
   Componentes base
   ============================================================ */

/* ---------- Card ---------- */
.card {
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-radius: var(--radius);
  padding: 2rem;
}
.card-sm { padding: 1.25rem; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1.75rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  letter-spacing: .03em;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--gold);
  color: var(--black);
}
.btn-primary:hover {
  background: var(--gold-light);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(201,168,76,.35);
}
.btn-outline {
  background: transparent;
  color: var(--gold);
  border: 1.5px solid var(--gold);
}
.btn-outline:hover {
  background: var(--gold-dim);
  transform: translateY(-1px);
}
.btn-ghost {
  background: transparent;
  color: var(--white-dim);
  border: 1.5px solid rgba(255,255,255,.12);
}
.btn-ghost:hover { background: rgba(255,255,255,.06); }
.btn-danger {
  background: #8b2020;
  color: #fff;
}
.btn-danger:hover { background: #a02828; }
.btn-sm { padding: .45rem 1rem; font-size: .8rem; }
.btn-lg { padding: 1rem 2.5rem; font-size: 1rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Formularios ---------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.form-label {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 600;
}
.form-control {
  background: rgba(255,255,255,.05);
  border: 1.5px solid rgba(255,255,255,.1);
  border-radius: var(--radius-sm);
  color: var(--white);
  font-size: .9375rem;
  padding: .7rem 1rem;
  transition: border-color var(--transition), background var(--transition);
  width: 100%;
  font-family: inherit;
  outline: none;
}
.form-control::placeholder { color: var(--muted); }
.form-control:focus {
  border-color: var(--gold);
  background: rgba(201,168,76,.06);
}
.form-control.error { border-color: #e05252; }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control option { background: var(--dark-card); color: var(--white); }

.field-error {
  font-size: .78rem;
  color: #e05252;
  display: none;
}
.field-error.visible { display: block; }

/* ---------- Badges de estado ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .85rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.badge-received  { background: rgba(100,100,200,.15); color: #8a8ad0; }
.badge-received::before { background: #8a8ad0; }
.badge-process   { background: rgba(200,168,76,.15); color: var(--gold); }
.badge-process::before { background: var(--gold); animation: pulse 1.5s infinite; }
.badge-done      { background: rgba(50,180,100,.15); color: #40c070; }
.badge-done::before { background: #40c070; }

@keyframes pulse {
  0%,100% { transform: scale(1); opacity:1; }
  50%      { transform: scale(1.4); opacity:.6; }
}

/* ---------- Tabla ---------- */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
thead th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .73rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  border-bottom: 1px solid var(--dark-border);
  font-weight: 600;
}
tbody tr {
  border-bottom: 1px solid rgba(255,255,255,.04);
  transition: background var(--transition);
  cursor: pointer;
}
tbody tr:hover { background: rgba(255,255,255,.03); }
tbody td { padding: .85rem 1rem; color: var(--white-dim); }
tbody td:first-child { color: var(--white); font-weight: 600; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(6px);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2.5rem;
  transform: translateY(20px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}
.modal-title { font-family: 'Playfair Display', serif; font-size: 1.5rem; color: var(--gold); }
.modal-close {
  background: transparent; border: none;
  color: var(--muted); font-size: 1.5rem;
  cursor: pointer; line-height: 1;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--white); }

/* ---------- Nav/Sidebar ---------- */
.sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--dark-card);
  border-right: 1px solid var(--dark-border);
  display: flex;
  flex-direction: column;
  padding: 2rem 1.25rem;
  flex-shrink: 0;
}
.sidebar-logo {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  color: var(--gold);
  margin-bottom: 2.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--dark-border);
  letter-spacing: .03em;
}
.sidebar-logo span { display: block; font-size: .7rem; font-family: 'Inter', sans-serif; color: var(--muted); margin-top: 3px; text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }
.sidebar-nav { list-style: none; display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .65rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: var(--gold-dim);
  color: var(--gold);
}
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer { margin-top: auto; padding-top: 1.5rem; border-top: 1px solid var(--dark-border); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--dark-border);
  background: var(--dark-card);
}
.topbar-title { font-size: 1.25rem; font-weight: 600; }

/* ---------- Layout con sidebar ---------- */
.app-layout { display: flex; min-height: 100vh; }
.app-main { flex: 1; overflow: hidden; }
.app-content { padding: 2rem; }

/* ---------- Stats cards ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--gold); }
.stat-number {
  font-family: 'Playfair Display', serif;
  font-size: 2.5rem;
  color: var(--gold);
  line-height: 1;
  margin-bottom: .4rem;
}
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }

/* ---------- Toast / Alert ---------- */
.toast-container {
  position: fixed;
  top: 1.5rem; right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: .9rem 1.25rem;
  font-size: .875rem;
  min-width: 260px;
  animation: slideIn .3s ease;
  box-shadow: var(--shadow);
}
.toast.error   { border-left-color: #e05252; }
.toast.success { border-left-color: #40c070; }
@keyframes slideIn { from { transform:translateX(120%); opacity:0; } to { transform:translateX(0); opacity:1; } }

/* ---------- Divider ---------- */
.divider {
  border: none;
  border-top: 1px solid var(--dark-border);
  margin: 1.5rem 0;
}

/* ---------- Avatar ---------- */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gold-dim);
  border: 1.5px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: .875rem; font-weight: 700;
  color: var(--gold);
  flex-shrink: 0;
}

/* ---------- Mapa Leaflet personalizado ---------- */
.leaflet-container {
  background: #e8e0d4 !important;
  border-radius: var(--radius-sm);
}
.leaflet-control-attribution { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .app-content { padding: 1.25rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .modal { padding: 1.5rem; }
  .card { padding: 1.25rem; }
}

/* ---------- Print / PDF ---------- */
@media print {
  .no-print { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  .card { border: 1px solid #ddd !important; background: #fff !important; }
}
