/* DatoYa — Identidad visual chilena, mobile-first */
:root {
  --azul: #0B3A82;
  --azul-osc: #072B63;
  --celeste: #E9FBF8;
  --teal: #19C6B4;
  --teal-claro: #4EDCCE;
  --naranja: #FF8A1F;
  --naranja-claro: #FFC247;
  --verde: #16A34A;       /* disponible / éxito */
  --ambar: #D97706;       /* ocupado / alerta */
  --gris: #6B7280;        /* no disponible */
  --rojo: #DC2626;
  --txt: #1B2B48;
  --txt2: #4B5563;
  --borde: #E5E7EB;
  --fondo: #F7F9FC;
  --radio: 18px;
  --sombra: 0 8px 28px rgba(7,43,99,.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: Poppins, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--fondo); color: var(--txt);
  padding-bottom: 76px;
}
.hidden { display: none !important; }
a { color: var(--azul); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ===== Header ===== */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  padding: 14px 18px; background: #fff; border-bottom: 1px solid var(--borde);
}
.datoya-header-logo { width: 176px !important; height: 56px !important; object-fit: contain; }
.logo { min-width: 176px !important; }
@media (max-width: 420px) {
  .datoya-header-logo { width: 154px !important; height: 50px !important; }
  .logo { min-width: 154px !important; }
}
.logo { display: flex; align-items: center; gap: 8px; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--azul);
  color: #fff; font-weight: 800; font-size: 19px;
  display: flex; align-items: center; justify-content: center;
}
.logo-text { font-size: 20px; font-weight: 800; color: var(--txt); }
.logo-text em { font-style: normal; color: var(--azul); }
#topnav { display: flex; gap: 14px; align-items: center; font-size: 14px; margin-left: auto; min-width: 0; }
#topnav a { color: var(--txt2); font-weight: 600; }
#topnav a:hover { color: var(--azul); }
#auth-area { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
#auth-area a { display: inline-flex; align-items: center; min-height: 34px; }
@media (max-width: 640px) {
  #topbar {
    padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
    gap: 12px;
  }
  #topnav > a { display: none; }
  #topnav { flex: 0 0 auto; font-size: 13px; }
  #auth-area { gap: 10px; }
  .logo { min-width: 0 !important; flex: 1 1 auto; }
}
@media (max-width: 380px) {
  #topbar { padding-left: 14px; padding-right: 14px; }
  .datoya-header-logo { width: 144px !important; height: 48px !important; }
  #auth-area { gap: 8px; }
}

/* ===== Bottom nav (móvil) ===== */
#bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; background: #fff; border-top: 1px solid var(--borde);
  padding-bottom: env(safe-area-inset-bottom);
}
#bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; font-size: 11px; color: var(--txt2); position: relative;
}
#bottomnav a span { font-size: 20px; }
#bottomnav a.active { color: var(--azul); font-weight: 700; }
.badge {
  position: absolute; top: 2px; right: calc(50% - 20px);
  background: var(--rojo); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ===== Layout ===== */
#view { max-width: 980px; margin: 0 auto; padding: 16px; }
.section-title { font-size: 19px; font-weight: 800; margin: 24px 0 12px; }
.muted { color: var(--txt2); }
.small { font-size: 13px; }
.demo-tag {
  display: inline-block; background: #FEF3C7; color: #92400E; font-size: 11px;
  font-weight: 700; padding: 2px 8px; border-radius: 20px; margin-left: 6px;
}

/* ===== Hero / Landing ===== */
.hero {
  background: linear-gradient(135deg, var(--azul) 0%, var(--azul-osc) 100%);
  border-radius: 20px; color: #fff; padding: 34px 22px; text-align: center;
}
.hero h1 { font-size: 27px; line-height: 1.25; margin-bottom: 8px; }
.hero p { opacity: .92; margin-bottom: 20px; font-size: 15px; }
.searchbox { display: flex; flex-direction: column; gap: 8px; }
.searchbox input, .searchbox select {
  padding: 14px; border-radius: 12px; border: none; font-size: 15px; width: 100%;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 20px; border-radius: 12px; border: none;
  font-size: 15px; font-weight: 700; transition: transform .05s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--azul); color: #fff; }
.btn-accent { background: var(--naranja); color: #fff; }
.btn-white { background: #fff; color: var(--azul); }
.btn-outline { background: #fff; color: var(--azul); border: 2px solid var(--azul); }
.btn-green { background: var(--verde); color: #fff; }
.btn-danger { background: var(--rojo); color: #fff; }
.btn-ghost { background: #F3F4F6; color: var(--txt); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 10px; }
@media (min-width: 640px) { .searchbox { flex-direction: row; } .searchbox input { flex: 2; } .searchbox select { flex: 1; } }

/* ===== Categorías ===== */
.cat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.cat-item {
  background: #fff; border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 14px 6px; text-align: center; font-size: 12px; font-weight: 600; color: var(--txt);
}
.cat-item span { font-size: 26px; display: block; margin-bottom: 6px; }
.cat-item:hover { border-color: var(--azul); color: var(--azul); }
@media (max-width: 640px) { .cat-grid { grid-template-columns: repeat(5, 1fr); gap: 6px; } .cat-item { font-size: 10.5px; padding: 10px 2px; } .cat-item span { font-size: 22px; } }

/* ===== Tarjetas de trabajador ===== */
.cards { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 720px) { .cards { grid-template-columns: 1fr 1fr; } }
.wcard {
  background: #fff; border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 14px; box-shadow: var(--sombra);
}
.wcard-top { display: flex; gap: 12px; }
.avatar {
  width: 58px; height: 58px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 22px; position: relative;
}
.avatar .st { position: absolute; bottom: 0; right: 0; width: 15px; height: 15px; border-radius: 50%; border: 2px solid #fff; }
.st-disponible { background: var(--verde); } .st-ocupado { background: var(--ambar); } .st-no_disponible { background: #9CA3AF; }
.wcard-info { flex: 1; min-width: 0; }
.wcard-info h3 { font-size: 16px; }
.wcard-info .oficio { color: var(--azul); font-weight: 600; font-size: 13px; }
.wmeta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; font-size: 12.5px; color: var(--txt2); }
.pill { background: var(--celeste); color: var(--azul-osc); padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.pill-verif { background: #DCFCE7; color: #166534; }
.pill-pro { background: linear-gradient(90deg,#F59E0B,#FBBF24); color: #7C2D12; }
.wcard-actions { display: flex; gap: 8px; margin-top: 12px; }
.wcard-actions .btn { flex: 1; }

/* ===== Perfil ===== */
.profile-head { background: #fff; border-radius: var(--radio); padding: 20px; box-shadow: var(--sombra); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.badge-v { background: #DCFCE7; color: #166534; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.status-chip { font-weight: 700; font-size: 13px; }
.st-txt-disponible { color: var(--verde); } .st-txt-ocupado { color: var(--ambar); } .st-txt-no_disponible { color: var(--gris); }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.g-item { background: var(--celeste); border-radius: 12px; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; text-align: center; padding: 6px; color: var(--txt2); }
.g-item b { font-size: 34px; }

/* ===== Formularios ===== */
.card { background: #fff; border-radius: var(--radio); padding: 18px; box-shadow: var(--sombra); margin-bottom: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; font-size: 13.5px; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px; border: 1.5px solid var(--borde); border-radius: 10px;
  font-size: 15px; font-family: inherit; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--azul); }
.field .hint { font-size: 12px; color: var(--txt2); margin-top: 4px; }
.stepper { display: flex; gap: 6px; margin-bottom: 18px; }
.stepper i { flex: 1; height: 5px; border-radius: 3px; background: var(--borde); }
.stepper i.on { background: var(--azul); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 16px; border-radius: 24px; border: 1.5px solid var(--borde);
  background: #fff; font-size: 14px; font-weight: 600;
}
.chip.sel { border-color: var(--azul); background: var(--celeste); color: var(--azul); }

/* ===== Cotizaciones / jobs ===== */
.quote-card { border: 2px solid var(--borde); border-radius: var(--radio); padding: 14px; margin-bottom: 10px; background: #fff; }
.quote-card.aceptada { border-color: var(--verde); }
.quote-price { font-size: 22px; font-weight: 800; color: var(--txt); }
.status-tag { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.st-abierta, .st-SOLICITADO { background: #DBEAFE; color: #1E40AF; }
.st-COTIZANDO, .st-en_proceso { background: #FEF3C7; color: #92400E; }
.st-TRABAJADOR_SELECCIONADO { background: #EDE9FE; color: #5B21B6; }
.st-CONFIRMADO { background: #CFFAFE; color: #155E75; }
.st-EN_PROCESO { background: #FEF3C7; color: #92400E; }
.st-FINALIZADO, .st-cerrada { background: #DCFCE7; color: #166534; }
.st-CANCELADO, .st-cancelada { background: #F3F4F6; color: #4B5563; }
.st-DISPUTA { background: #FEE2E2; color: #991B1B; }

/* ===== Chat ===== */
.chat-list a { display: flex; gap: 12px; padding: 14px; background: #fff; border-radius: var(--radio); margin-bottom: 8px; color: var(--txt); box-shadow: var(--sombra); }
.chat-window { display: flex; flex-direction: column; height: calc(100vh - 220px); min-height: 380px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: #fff; border-radius: var(--radio) var(--radio) 0 0; }
.msg { max-width: 78%; padding: 10px 13px; border-radius: 16px; font-size: 14.5px; line-height: 1.4; }
.msg.mine { align-self: flex-end; background: var(--azul); color: #fff; border-bottom-right-radius: 4px; }
.msg.theirs { align-self: flex-start; background: #F3F4F6; border-bottom-left-radius: 4px; }
.msg .time { display: block; font-size: 10.5px; opacity: .65; margin-top: 3px; }
.msg .warn { display: block; font-size: 11px; margin-top: 4px; font-weight: 600; }
.chat-input { display: flex; gap: 8px; padding: 10px; background: #fff; border-top: 1px solid var(--borde); border-radius: 0 0 var(--radio) var(--radio); }
.chat-input input { flex: 1; padding: 12px; border: 1.5px solid var(--borde); border-radius: 24px; font-size: 15px; }
.lock-note { background: #FEF3C7; color: #92400E; font-size: 12.5px; padding: 10px 14px; border-radius: 10px; margin-bottom: 8px; }

/* ===== Admin ===== */
.admin-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 720px) { .admin-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card { background: #fff; border-radius: var(--radio); padding: 16px; box-shadow: var(--sombra); }
.stat-card b { font-size: 24px; display: block; }
.stat-card span { font-size: 12.5px; color: var(--txt2); }
.table-wrap { overflow-x: auto; background: #fff; border-radius: var(--radio); box-shadow: var(--sombra); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--borde); white-space: nowrap; }
th { background: #F9FAFB; font-size: 12px; text-transform: uppercase; color: var(--txt2); }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 12px; }
.tabs button { padding: 9px 16px; border-radius: 24px; border: 1.5px solid var(--borde); background: #fff; font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.tabs button.on { background: var(--azul); color: #fff; border-color: var(--azul); }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.bar-row .bar { height: 18px; border-radius: 6px; background: var(--azul); min-width: 4px; }
.bar-row .lbl { width: 90px; flex-shrink: 0; }

/* ===== Toast / modal ===== */
#toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; z-index: 100; max-width: 90vw; text-align: center; box-shadow: 0 8px 30px rgba(0,0,0,.25);
}
#toast.ok { background: var(--verde); } #toast.err { background: var(--rojo); }
#modal { position: fixed; inset: 0; background: rgba(17,24,39,.55); z-index: 90; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) { #modal { align-items: center; } }
#modal-card { background: #fff; width: 100%; max-width: 480px; border-radius: 20px 20px 0 0; padding: 22px; max-height: 88vh; overflow-y: auto; }
@media (min-width: 640px) { #modal-card { border-radius: 20px; } }
#modal-card h3 { margin-bottom: 14px; }

/* ===== Estrellas ===== */
.stars { color: #F59E0B; font-size: 15px; letter-spacing: 1px; }
.star-input { font-size: 30px; color: var(--borde); display: flex; gap: 4px; }
.star-input span { cursor: pointer; }
.star-input span.on { color: #F59E0B; }

.empty { text-align: center; padding: 40px 16px; color: var(--txt2); }
.empty b { font-size: 40px; display: block; margin-bottom: 8px; }
.notif { background: #fff; border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; font-size: 14px; box-shadow: var(--sombra); }
.notif.unread { border-left: 4px solid var(--azul); }
.footer-landing { text-align: center; padding: 30px 16px; color: var(--txt2); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
