/* ─── PRESULAB · DESIGN SYSTEM ─────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;1,9..40,400&display=swap');

/* ── VARIABLES ─────────────────────────────────────────────────────────────── */
:root {
  /* Paleta principal */
  --green:         #7DBF45;
  --green-dark:    #5E9A30;
  --green-light:   #EEF7E3;
  --blue:          #2348CC;
  --blue-dark:     #1A35A0;
  --blue-light:    #EEF1FC;
  --red:           #DC2626;
  --red-light:     #FEF2F2;

  /* Neutros */
  --ink:           #0E1117;
  --text-primary:  #111827;
  --text-secondary:#4B5563;
  --text-muted:    #9CA3AF;
  --border:        #E5E7EB;
  --border-soft:   #F3F4F6;
  --bg:            #F5F6F8;
  --card:          #FFFFFF;

  /* Sidebar */
  --sidebar-w:     240px;
  --sidebar-bg:    #0E1117;

  /* Radios / sombras */
  --radius:        10px;
  --radius-sm:     6px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:     0 4px 16px rgba(0,0,0,.09);
  --shadow-modal:  0 24px 64px rgba(0,0,0,.20);

  /* Tipografía */
  --font-ui:       'DM Sans', sans-serif;
  --font-display:  'Outfit', sans-serif;

  /* Layout */
  --topbar-h:      60px;
}

/* ── RESET ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html  { font-size: 16px; }
body  {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a       { color: inherit; text-decoration: none; }
button  { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea {
  font-family: var(--font-ui);
  font-size: .9375rem;
}

/* ── APP SHELL ─────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ───────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 200;
  transition: transform .24s ease;
}

/* Logo */
.sidebar-logo {
  height: var(--topbar-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.03em;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
  user-select: none;
}
.sidebar-logo span { color: var(--green); }

/* Sección etiqueta */
.sidebar-section {
  padding: 22px 16px 5px;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.25);
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 6px 0 12px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  color: rgba(255,255,255,.55);
  transition: background .14s, color .14s;
  user-select: none;
}
.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.9);
}
.nav-item.active {
  background: rgba(125,191,69,.14);
  color: var(--green);
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-icon { flex-shrink: 0; opacity: .55; transition: opacity .14s; }
.nav-item:hover  .nav-icon { opacity: 1; }
.nav-item.active .nav-icon { opacity: 1; }

/* Próximamente */
.nav-item.soon { opacity: .38; pointer-events: none; }
.badge-soon {
  margin-left: auto;
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .04em;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.35);
  padding: 2px 7px;
  border-radius: 20px;
}

/* Footer */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  font-size: .73rem;
  color: rgba(255,255,255,.2);
  text-align: center;
}

/* ── OVERLAY MÓVIL ─────────────────────────────────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
  opacity: 0;
  transition: opacity .24s;
}

/* ── MAIN ──────────────────────────────────────────────────────────────────── */
#main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ── TOPBAR ────────────────────────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

#menu-toggle {
  display: none;
  width: 36px; height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: background .14s;
}
#menu-toggle:hover { background: var(--border-soft); }

#page-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -.01em;
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.topbar-badge {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: var(--green-light);
  color: var(--green-dark);
  padding: 3px 10px;
  border-radius: 20px;
}

/* ── CONTENT ───────────────────────────────────────────────────────────────── */
#content {
  padding: 28px 28px 60px;
  flex: 1;
}

/* ── MODULE HEADER ─────────────────────────────────────────────────────────── */
.module-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.module-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.025em;
  line-height: 1.2;
}
.module-sub {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── CARD ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* ── BUSCADOR ──────────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.search-bar input {
  border: none;
  outline: none;
  flex: 1;
  font-size: .9rem;
  color: var(--text-primary);
  background: transparent;
}
.search-bar input::placeholder { color: var(--text-muted); }

/* ── TABLA ─────────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  padding: 10px 18px;
  text-align: left;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--border-soft);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-soft);
  font-size: .875rem;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover { background: #FAFBFC; }

.cell-name { display: flex; align-items: center; gap: 10px; font-weight: 500; }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--blue-light);
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: .78rem;
  font-weight: 700;
  flex-shrink: 0;
}

.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }

.link { color: var(--blue); }
.link:hover { text-decoration: underline; color: var(--blue-dark); }

.col-actions { width: 86px; text-align: right; }

/* ── ESTADOS ───────────────────────────────────────────────────────────────── */
.loading-state,
.empty-state,
.error-state {
  padding: 56px 24px;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-size: .9rem;
  line-height: 1.65;
}
.error-state { color: var(--red); }

.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── BOTONES ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: .875rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
  transition: background .14s, box-shadow .14s, transform .1s;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--green);
  color: #fff;
  box-shadow: 0 1px 4px rgba(125,191,69,.28);
}
.btn-primary:hover:not(:disabled) {
  background: var(--green-dark);
  box-shadow: 0 3px 10px rgba(125,191,69,.32);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--border-soft); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-icon {
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  border: 1px solid transparent;
}
.btn-icon:hover { background: var(--border-soft); color: var(--blue); border-color: var(--border); }
.btn-icon-danger:hover { background: var(--red-light); color: var(--red); border-color: #FECACA; }

/* ── MODAL ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14,17,23,.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .15s ease;
}
.modal-overlay.hidden { display: none; }

@keyframes fadeIn  { from { opacity: 0; }              to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; }
                     to   { transform: translateY(0);     opacity: 1; } }

.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 560px;
  animation: slideUp .2s ease;
  overflow: hidden;
}
.modal-sm {
  max-width: 380px;
  padding: 28px 28px 24px;
  overflow: visible;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-sm .modal-header {
  padding: 0;
  border: none;
  margin-bottom: 10px;
}
.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
}

.modal-close {
  width: 30px; height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background .14s, color .14s;
}
.modal-close:hover { background: var(--border-soft); color: var(--text-primary); }

.confirm-text {
  font-size: .9rem;
  color: var(--text-secondary);
  margin-bottom: 22px;
  line-height: 1.55;
}

/* ── FORMULARIO ────────────────────────────────────────────────────────────── */
#client-form {
  padding: 22px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.required { color: var(--red); }

.form-group input,
.form-group textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  color: var(--text-primary);
  background: var(--card);
  width: 100%;
  resize: vertical;
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(125,191,69,.14);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-muted); }

.form-error {
  padding: 10px 12px;
  background: var(--red-light);
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: .84rem;
}
.form-error.hidden { display: none; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

/* ── RESPONSIVE ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Sidebar oculto por defecto en móvil */
  #sidebar { transform: translateX(-100%); }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-modal);
  }

  /* Overlay visible */
  #sidebar-overlay { display: block; }
  #sidebar-overlay.visible { opacity: 1; }

  #main      { margin-left: 0; }
  #menu-toggle { display: flex; }
  #content   { padding: 18px 16px 48px; }

  /* Header en móvil: botón ocupa ancho completo */
  .module-header {
    flex-direction: column;
    align-items: stretch;
  }
  .module-header .btn {
    width: 100%;
    padding: 12px 18px;
    font-size: .95rem;
  }

  /* Formulario: columnas apiladas */
  .form-row { grid-template-columns: 1fr; }

  /* Tabla: ocultar columnas empresa y teléfono */
  .data-table th:nth-child(2),
  .data-table td:nth-child(2),
  .data-table th:nth-child(4),
  .data-table td:nth-child(4) { display: none; }
}

/* Modal pegado al fondo en pantallas muy pequeñas */
@media (max-width: 480px) {
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 92vh;
    overflow-y: auto;
  }
}

/* ── PRESUPUESTOS — ESTILOS EXTRA ───────────────────────────────────────────
   Añade este bloque al final de css/styles.css                              */

/* Select del formulario (mismo aspecto que input) */
.form-group select {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  color: var(--text-primary);
  background: var(--card);
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%239CA3AF' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.form-group select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(125,191,69,.14);
}

/* Avatar variante verde (presupuestos) */
.avatar-green {
  background: var(--green-light);
  color: var(--green-dark);
}

/* Badges de estado */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .03em;
  white-space: nowrap;
}
.status-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .7;
  flex-shrink: 0;
}

.status-draft    { background: #F3F4F6; color: #6B7280; }
.status-sent     { background: var(--blue-light);   color: var(--blue); }
.status-accepted { background: var(--green-light);  color: var(--green-dark); }
.status-rejected { background: var(--red-light);    color: var(--red); }

/* Columna fecha — ocultar en móvil */
@media (max-width: 768px) {
  .data-table th:nth-child(5),
  .data-table td:nth-child(5) { display: none; }
}
