* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    background: #f5f5f7;
    color: #1d1d1f;
}

/* ---- Topbar ---- */
.topbar {
    height: 56px;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid #e5e5e7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.logo { font-weight: 700; font-size: 18px; letter-spacing: -0.5px; }
.top-link { color: #1d1d1f; text-decoration: none; margin-left: 18px; font-size: 14px; opacity: 0.75; }
.top-link:hover { opacity: 1; }
.user-chip { margin-left: 18px; font-size: 13px; background: #eee; padding: 5px 12px; border-radius: 20px; }

/* ---- Login ---- */
.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card {
    background: #fff; padding: 40px 36px; border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.12);
    width: 320px; text-align: center;
}
.login-card h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -0.5px; }
.login-sub { color: #86868b; margin-bottom: 24px; font-size: 14px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.login-card label { font-size: 13px; color: #6e6e73; }
.login-card input {
    padding: 10px 12px; border-radius: 10px; border: 1px solid #d2d2d7; font-size: 14px; margin-top: -4px;
}
.login-card button {
    margin-top: 10px; background: #111; color: #fff; border: none; border-radius: 10px;
    padding: 11px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.login-card button:hover { background: #000; }
.login-error { background: #fdecea; color: #c0392b; padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }

/* ---- App shell ---- */
.app-shell { display: flex; height: calc(100vh - 56px); }
.chat-list-panel {
    width: 320px; background: #fff; border-right: 1px solid #e5e5e7;
    display: flex; flex-direction: column; overflow: hidden;
}
.tabs { display: flex; border-bottom: 1px solid #eee; }
.tab {
    flex: 1; padding: 12px; border: none; background: none; cursor: pointer;
    font-size: 13px; font-weight: 600; color: #86868b; border-bottom: 2px solid transparent;
}
.tab.active { color: #111; border-bottom-color: #111; }
.badge {
    background: #ff3b30; color: #fff; border-radius: 10px; padding: 1px 7px;
    font-size: 11px; margin-left: 4px;
}
.site-filter { padding: 10px; border-bottom: 1px solid #eee; }
.site-filter select { width: 100%; padding: 8px; border-radius: 8px; border: 1px solid #d2d2d7; font-size: 13px; }

.chat-list { flex: 1; overflow-y: auto; }
.chat-item {
    padding: 12px 14px; border-bottom: 1px solid #f0f0f0; cursor: pointer; display: block;
}
.chat-item:hover { background: #fafafa; }
.chat-item.selected { background: #eef3ff; }
.chat-item-top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; }
.chat-item-site { font-size: 11px; color: #86868b; margin: 2px 0; }
.chat-item-preview { font-size: 12px; color: #6e6e73; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-time { font-size: 11px; color: #aaa; }
.dot-unread { width: 8px; height: 8px; background: #ff3b30; border-radius: 50%; display: inline-block; margin-right: 6px; }

.chat-window { flex: 1; display: flex; flex-direction: column; background: #f5f5f7; }
.chat-empty { margin: auto; color: #86868b; font-size: 14px; }

.chat-header {
    background: #fff; border-bottom: 1px solid #e5e5e7; padding: 14px 20px;
    display: flex; justify-content: space-between; align-items: center;
}
.chat-header-info h3 { margin: 0 0 2px; font-size: 15px; }
.chat-header-info p { margin: 0; font-size: 12px; color: #86868b; }
.chat-header-info-conAvatar { display: flex; align-items: center; gap: 10px; }
.avatar-cliente { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.msg-fila { display: flex; align-items: flex-end; gap: 8px; }
.msg-fila-staff { justify-content: flex-end; }
.msg-fila-cliente { justify-content: flex-start; }
.avatar-mini { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar-inicial {
    background: #111; color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600;
}
.avatar-cliente.avatar-inicial { font-size: 15px; }
.chat-header-actions { display: flex; gap: 8px; align-items: center; }
.chat-header-actions select { padding: 6px 10px; border-radius: 8px; border: 1px solid #d2d2d7; font-size: 12px; }

.btn { background: #111; color: #fff; border: none; border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer; }
.btn:hover { background: #000; }
.btn-danger { background: #ff3b30; color: #fff; border: none; border-radius: 10px; padding: 10px 16px; font-size: 13px; cursor: pointer; margin-top: 8px; }
.btn-danger-sm { background: #ff3b30; color: #fff; border: none; border-radius: 6px; padding: 5px 10px; font-size: 12px; cursor: pointer; }
.btn-secondary { background: #eee; color: #111; border: none; border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer; }

.messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.msg-col { display: flex; flex-direction: column; max-width: 60%; }
.msg-fila-staff .msg-col { align-items: flex-end; }
.msg-fila-cliente .msg-col { align-items: flex-start; }
.msg { padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.4; }
.msg-cliente { background: #fff; border-bottom-left-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.msg-staff { background: #111; color: #fff; border-bottom-right-radius: 4px; }
.msg-time { font-size: 11px; color: #a1a1a6; margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.msg-delete { background: none; border: none; color: #ff3b30; cursor: pointer; font-size: 11px; padding: 0; opacity: 0.7; }
.msg-delete:hover { opacity: 1; text-decoration: underline; }
.msg img { max-width: 220px; border-radius: 10px; display: block; }
.msg a.doc-link { color: inherit; text-decoration: underline; }

.chat-closed-banner { text-align: center; font-size: 12px; color: #86868b; padding: 8px; }

.send-box { background: #fff; border-top: 1px solid #e5e5e7; padding: 12px 16px; display: flex; gap: 8px; align-items: center; }
.send-box input[type=text] {
    flex: 1; padding: 10px 14px; border-radius: 20px; border: 1px solid #d2d2d7; font-size: 14px;
}
.send-box button { border-radius: 20px; }
.attach-btn { background: #eee; border: none; border-radius: 50%; width: 36px; height: 36px; cursor: pointer; font-size: 16px; }

/* ---- Páginas de gestión (sitios/editores) ---- */
.page-content { max-width: 760px; margin: 0 auto; padding: 30px 20px; }
.page-content h2 { margin-top: 0; }
.card { background: #fff; border-radius: 14px; padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.card h3 { margin-top: 0; font-size: 15px; }
.form-grid { display: flex; flex-direction: column; gap: 12px; }
.form-grid label { font-size: 13px; color: #6e6e73; display: flex; flex-direction: column; gap: 4px; }
.form-grid input[type=text], .form-grid input[type=color], .form-grid input[type=time] {
    padding: 9px 12px; border-radius: 10px; border: 1px solid #d2d2d7; font-size: 14px;
}
.horarios-grid { display: flex; flex-direction: column; gap: 8px; background: #f5f5f7; border-radius: 10px; padding: 12px; }
.horario-fila { display: flex; align-items: center; gap: 8px; }
.horario-dia { flex-direction: row !important; align-items: center; gap: 6px; width: 110px; flex-shrink: 0; font-size: 13px; color: #1d1d1f; }
.horario-fila input[type=time] { padding: 6px 8px; font-size: 13px; }
.horario-a { color: #86868b; font-size: 12px; }
.form-grid .checkbox { flex-direction: row; align-items: center; gap: 8px; }
.checklist { display: flex; flex-direction: column; gap: 6px; background: #f5f5f7; border-radius: 10px; padding: 10px 12px; }
.checklist .checkbox { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: #1d1d1f; }
.form-grid button { align-self: flex-start; background: #111; color: #fff; border: none; border-radius: 10px; padding: 10px 18px; font-size: 14px; cursor: pointer; }
.form-grid button:hover { background: #000; }
.aviso { background: #eafaf1; color: #1e7e45; padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 13px; }
.ayuda { color: #86868b; font-size: 13px; }
.badge-off { background: #eee; color: #999; font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.snippet-box { margin-top: 14px; background: #f5f5f7; border-radius: 10px; padding: 12px 14px; }
.snippet-box pre { margin: 6px 0 0; overflow-x: auto; font-size: 12px; }
.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla th, .tabla td { text-align: left; padding: 8px; border-bottom: 1px solid #f0f0f0; }
.vacio { color: #aaa; text-align: center; }
.perfil-actual { margin-bottom: 14px; }
.editor-titulo { display: flex; align-items: center; gap: 8px; }
