:root {
    --do-blue: #306fee;
    --do-blue-dark: #306fee;
    --do-blue-light: #EEF2FF;
    --do-bg: #f7f8fa;
    --do-surface: #ffffff;
    --do-border: #e4e7ec;
    --do-text: #17181c;
    --do-text-muted: #67717e;
    --do-success: #65A30D;
    --do-success-bg: #F7FEE7;
    --do-warning: #ea9e13;
    --do-warning-bg: #FFFBEB;
    --do-danger: #DC2626;
    --do-danger-bg: #FEF2F2;
    --do-radius: 10px;
    --do-radius-sm: 6px;
    --do-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
    --do-sidebar-width: 248px;
    --bs-primary: var(--do-blue);
    --bs-primary-rgb: 79, 70, 229;
    --bs-secondary: #64748B;
    --bs-secondary-rgb: 100, 116, 139;
    --bs-success: var(--do-success);
    --bs-success-rgb: 101, 163, 13;
    --bs-danger: var(--do-danger);
    --bs-danger-rgb: 220, 38, 38;
    --bs-warning: var(--do-warning);
    --bs-warning-rgb: 217, 119, 6;
    --bs-info: #0891B2;
    --bs-info-rgb: 8, 145, 178;
    --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* ---------- Modo oscuro ----------
   Bootstrap 5.3 ya adapta sus propios componentes (btn, badge, alert, form-control, etc.)
   solo con el atributo data-bs-theme="dark". Acá solo redefinimos las variables --do-*
   propias del sistema; como todo el CSS de abajo ya usa var(--do-*), el resto se acomoda solo. */
[data-bs-theme="dark"] {
    --do-blue: #306fee;
    --do-blue-dark: #306fee;
    --do-blue-light: rgba(99, 102, 241, 0.16);
    --do-bg: #101216;
    --do-surface: #1a1d23;
    --do-border: #2c3038;
    --do-text: #e7e9ec;
    --do-text-muted: #98a1ad;
    --do-success: #84CC16;
    --do-success-bg: rgba(132, 204, 22, 0.14);
    --do-warning: #F59E0B;
    --do-warning-bg: rgba(245, 158, 11, 0.14);
    --do-danger: #EF4444;
    --do-danger-bg: rgba(239, 68, 68, 0.14);
    --do-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.4);
    --bs-primary-rgb: 99, 102, 241;
    --bs-secondary: #94A3B8;
    --bs-secondary-rgb: 148, 163, 184;
    --bs-success-rgb: 132, 204, 22;
    --bs-danger-rgb: 239, 68, 68;
    --bs-warning-rgb: 245, 158, 11;
    --bs-info: #06B6D4;
    --bs-info-rgb: 6, 182, 212;
}

/* Logo de la empresa (subido en Configuración): si es negro/oscuro, se pierde
   sobre fondo oscuro. invert(1) lo vuelve blanco solo en modo oscuro; en
   modo claro queda tal cual se subió. */
[data-bs-theme="dark"] .do-brand-logo { filter: invert(1); }

* { box-sizing: border-box; }

body.do-body {
    background: var(--do-bg);
    color: var(--do-text);
    font-family: var(--bs-body-font-family);
    font-size: 14.5px;
}

/* ---------- Shell layout ---------- */
.do-shell { display: flex; min-height: 100vh; }

.do-sidebar {
    width: var(--do-sidebar-width);
    background: var(--do-surface);
    border-right: 1px solid var(--do-border);
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
    transition: transform 0.2s ease;
    z-index: 40;
}

.do-sidebar__brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; padding: 6px 10px 20px; }
.do-sidebar__mark { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: var(--do-blue); color: #fff; font-weight: 700; }
.do-sidebar__nav { display: flex; flex-direction: column; gap: 2px; }
.do-sidebar__link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--do-radius-sm); color: var(--do-text-muted); text-decoration: none; font-weight: 500; font-size: 0.9rem; }
.do-sidebar__link:hover { background: var(--do-bg); color: var(--do-text); }
.do-sidebar__link.is-active { background: var(--do-blue-light); color: var(--do-blue-dark); }
.do-sidebar__link.is-disabled { color: #b7bec8; cursor: default; }
.do-sidebar__icon { font-size: 1rem; }
.do-sidebar__group-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: #b7bec8; padding: 16px 12px 4px; font-weight: 600; }

.do-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.do-topbar {
    background: var(--do-surface);
    border-bottom: 1px solid var(--do-border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 30;
}

.do-topbar__title { font-size: 1.1rem; font-weight: 600; margin: 0; }
.do-topbar__user { display: flex; align-items: center; gap: 12px; }
.do-topbar__user-name { font-weight: 500; color: var(--do-text-muted); font-size: 0.9rem; }
.do-topbar__toggle { display: none; flex-direction: column; gap: 4px; background: none; border: none; padding: 6px; }
.do-topbar__toggle span { width: 20px; height: 2px; background: var(--do-text); display: block; }

.do-content { padding: 28px; flex: 1; }

/* ---------- Cards & grid ---------- */
.do-card { background: var(--do-surface); border: 1px solid var(--do-border); border-radius: var(--do-radius); box-shadow: var(--do-shadow); padding: 22px 24px; }
.do-card--form { max-width: 720px; }
.do-card__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.do-card__title { font-size: 1rem; font-weight: 600; margin: 0 0 4px; }
.do-card__actions { display: flex; gap: 8px; }

.do-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.do-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
@media (max-width: 900px) { .do-grid-3, .do-grid-2 { grid-template-columns: 1fr; } }

.do-stat { display: flex; flex-direction: column; gap: 4px; }
.do-stat__label { font-size: 0.8rem; color: var(--do-text-muted); font-weight: 500; }
.do-stat__value { font-size: 1.9rem; font-weight: 700; }
.do-stat__hint { font-size: 0.75rem; color: #b7bec8; }

/* ---------- Forms ---------- */
.form-label { font-weight: 500; font-size: 0.85rem; color: var(--do-text); }
.form-control, .form-select { border-radius: var(--do-radius-sm); border: 1px solid var(--do-border); padding: 9px 12px; font-size: 0.9rem; }
.form-control:focus, .form-select:focus { border-color: var(--do-blue); box-shadow: 0 0 0 3px var(--do-blue-light); }

.btn { border-radius: var(--do-radius-sm); font-weight: 500; font-size: 0.88rem; padding: 8px 16px; }
.btn-primary { background: var(--do-blue); border-color: var(--do-blue); }
.btn-primary:hover { background: var(--do-blue-dark); border-color: var(--do-blue-dark); }
.btn-secondary { background: var(--bs-secondary); border-color: var(--bs-secondary); }
.btn-success { background: var(--do-success); border-color: var(--do-success); }
.btn-danger { background: var(--do-danger); border-color: var(--do-danger); }
.btn-warning { background: var(--do-warning); border-color: var(--do-warning); color: #fff; }
.btn-info { background: var(--bs-info); border-color: var(--bs-info); color: #fff; }
.btn-outline-secondary { border-color: var(--do-border); color: var(--do-text); }
.btn-outline-primary { color: var(--do-blue); border-color: var(--do-blue); }
.btn-outline-primary:hover { background: var(--do-blue); border-color: var(--do-blue); }
.btn-outline-success { color: var(--do-success); border-color: var(--do-success); }
.btn-outline-success:hover { background: var(--do-success); border-color: var(--do-success); }
.btn-outline-danger { color: var(--do-danger); border-color: var(--do-danger); }
.btn-outline-danger:hover { background: var(--do-danger); border-color: var(--do-danger); }
.btn-outline-warning { color: var(--do-warning); border-color: var(--do-warning); }
.btn-outline-warning:hover { background: var(--do-warning); border-color: var(--do-warning); color: #fff; }
.btn-outline-info { color: var(--bs-info); border-color: var(--bs-info); }
.btn-outline-info:hover { background: var(--bs-info); border-color: var(--bs-info); color: #fff; }

.form-check-input:checked { background-color: var(--do-blue); border-color: var(--do-blue); }

/* ---------- Tables ---------- */
.do-table thead th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--do-text-muted); border-bottom: 1px solid var(--do-border); font-weight: 600; }
.do-table td { vertical-align: middle; border-color: var(--do-border); font-size: 0.88rem; }
.do-table__actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.do-table__actions form { display: inline; }
.do-search-form { display: flex; gap: 8px; margin-bottom: 16px; }
.do-search-form .form-control { max-width: 320px; }

/* ---------- Selector de íconos (tipos de servicio) ---------- */
.do-emoji-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.do-emoji-picker__btn { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; background: var(--do-surface); border: 1px solid var(--do-border); border-radius: var(--do-radius-sm); cursor: pointer; padding: 0; }
.do-emoji-picker__btn:hover { background: var(--do-blue-light); border-color: var(--do-blue); }

/* ---------- Hilo de mensajes (tickets) ---------- */
.do-ticket-thread { display: flex; flex-direction: column; gap: 14px; }
.do-ticket-msg { max-width: 78%; padding: 12px 16px; border-radius: var(--do-radius); border: 1px solid var(--do-border); }
.do-ticket-msg--cliente { align-self: flex-end; background: var(--do-surface); }
.do-ticket-msg--cliente-invert {align-self: flex-start;}
.do-ticket-msg--admin { align-self: flex-start; background: var(--do-blue-light); border-color: #c7defe; }
.do-ticket-msg--admin-invert {align-self: flex-end;}
.do-ticket-msg__header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.do-ticket-msg__autor { font-weight: 600; font-size: 0.85rem; }
.do-ticket-msg--admin .do-ticket-msg__autor { color: var(--do-blue-dark); }
.do-ticket-msg__fecha { font-size: 0.72rem; color: var(--do-text-muted); white-space: nowrap; }
.do-ticket-msg__texto { margin: 0; font-size: 0.9rem; white-space: pre-line; line-height: 1.5; }
@media (max-width: 700px) { .do-ticket-msg { max-width: 100%; } }

/* ---------- Badges (para estados de módulos futuros: servicios, pagos, etc.) ---------- */
.do-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.do-badge--activo { background: var(--do-success-bg); color: var(--do-success); }
.do-badge--pendiente { background: var(--do-warning-bg); color: var(--do-warning); }
.do-badge--suspendido, .do-badge--vencido { background: var(--do-danger-bg); color: var(--do-danger); }
.do-badge--finalizado { background: #eef0f3; color: var(--do-text-muted); }

/* ---------- Detail list ---------- */
.do-detail-list { display: grid; grid-template-columns: 140px 1fr; row-gap: 10px; margin: 0; }
.do-detail-list dt { color: var(--do-text-muted); font-size: 0.82rem; font-weight: 500; }
.do-detail-list dd { margin: 0; font-size: 0.9rem; }

/* ---------- Notificaciones (campana + listado) ---------- */
.do-notif { position: relative; }
.do-notif__badge {
    position: absolute; top: -4px; right: -4px; background: var(--do-danger); color: #fff;
    border-radius: 999px; font-size: 0.65rem; padding: 1px 5px; line-height: 1.3; font-weight: 700;
}
.do-notif__menu { width: 340px; max-height: 440px; overflow-y: auto; }
.do-notif__header {
    display: flex; justify-content: space-between; align-items: center; padding: 10px 14px;
    border-bottom: 1px solid var(--do-border); font-weight: 600; font-size: 0.85rem;
}
.do-notif__item {
    display: flex; gap: 10px; padding: 10px 14px; text-decoration: none; color: inherit;
    border-bottom: 1px solid var(--do-border); white-space: normal;
}
.do-notif__item:hover { background: var(--do-bg); }
.do-notif__item.is-unread { background: var(--do-blue-light); }
.do-notif__icon {
    width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center;
    justify-content: center; flex-shrink: 0; font-size: 0.85rem;
}
.do-notif__empty { padding: 24px 14px; text-align: center; }
.do-notif__footer {
    display: block; text-align: center; padding: 10px; font-size: 0.85rem;
    border-top: 1px solid var(--do-border); text-decoration: none;
}

.do-notif-row {
    display: flex; gap: 12px; align-items: flex-start; padding: 14px 18px; text-decoration: none;
    color: inherit; border-bottom: 1px solid var(--do-border);
}
.do-notif-row:last-child { border-bottom: none; }
.do-notif-row:hover { background: var(--do-bg); }
.do-notif-row.is-unread { background: var(--do-blue-light); }
.do-notif-row.is-unread strong::before { content: "\25CF "; color: var(--do-blue); font-size: 0.6rem; }
.do-notif-row__icon {
    width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center;
    justify-content: center; flex-shrink: 0;
}
.do-notif-row__body { flex: 1; }
.do-notif-row__meta { white-space: nowrap; }

/* ---------- Alerts ---------- */
.do-alert { border-radius: var(--do-radius-sm); border: none; font-size: 0.88rem; }
.alert-success { background: var(--do-success-bg); color: #0a7a49; }
.alert-danger { background: var(--do-danger-bg); color: #a3282d; }
.alert-info { background: rgba(var(--bs-info-rgb), 0.12); color: var(--do-text); }

/* ---------- Impersonation banner ---------- */
.do-impersonation-banner { background: #1b1f27; color: #fff; padding: 10px 20px; border-radius: var(--do-radius-sm); display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; font-size: 0.88rem; gap: 12px; flex-wrap: wrap; }

/* ---------- Auth (login / registro / recuperar) — pantalla dividida ---------- */
.do-auth-shell { display: flex; min-height: 100vh; background: var(--do-bg); }

.do-auth-col { flex: 1 1 50%; display: flex; align-items: center; justify-content: center; padding: 48px 24px; overflow-y: auto; }
.do-auth-form { width: 100%; max-width: 440px; }
.do-auth-form--wide { max-width: 620px; }

.do-auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; }
.do-auth-brand__mark { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; background: var(--do-blue); color: #fff; }
.do-auth-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.do-auth-subtitle { color: var(--do-text-muted); font-size: 0.92rem; margin-bottom: 28px; }
.do-auth-links { display: flex; justify-content: space-between; margin-top: 20px; font-size: 0.85rem; flex-wrap: wrap; gap: 8px; }
.do-auth-links a { color: var(--do-blue); text-decoration: none; font-weight: 500; }
.do-auth-links a:hover { text-decoration: underline; }

/* Panel derecho: solo desde tablet grande en adelante (evita achicar formularios de 2 columnas, como el de registro) */
.do-auth-showcase { display: none; position: relative; flex: 1 1 50%; padding: 56px; overflow: hidden; color: #fff; background: linear-gradient(160deg, var(--do-blue) 0%, #0891B2 100%); }
[data-bs-theme="dark"] .do-auth-showcase { background: linear-gradient(160deg, #312e81 0%, #0e7490 100%); }
@media (min-width: 992px) { .do-auth-showcase { display: flex; flex-direction: column; justify-content: center; } }

.do-auth-showcase__badge { display: inline-flex; align-items: center; gap: 8px; width: fit-content; background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.22); padding: 7px 16px; border-radius: 999px; font-weight: 600; font-size: 0.82rem; margin-bottom: 26px; }
.do-auth-showcase__title { font-size: 2rem; font-weight: 800; line-height: 1.25; margin-bottom: 28px; max-width: 460px; }
.do-auth-showcase__list { list-style: none; padding: 0; margin: 0 0 44px; display: flex; flex-direction: column; gap: 14px; }
.do-auth-showcase__list li { display: flex; align-items: center; gap: 12px; font-size: 0.96rem; font-weight: 500; }
.do-auth-showcase__check { flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; background: rgba(255, 255, 255, 0.2); display: inline-flex; align-items: center; justify-content: center; font-size: 0.75rem; }

.do-auth-illustration { position: relative; width: 100%; max-width: 340px; aspect-ratio: 1; border-radius: 50%; background: rgba(255, 255, 255, 0.97); margin: 0 auto; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25); display: flex; align-items: center; justify-content: center; }
.do-auth-mockup { width: 76%; background: #f7f8fa; border: 1px solid #e4e7ec; border-radius: 14px; padding: 16px; box-shadow: 0 10px 30px rgba(16, 24, 40, 0.12); }
.do-auth-mockup__dots { display: flex; gap: 6px; margin-bottom: 14px; }
.do-auth-mockup__dots span { width: 9px; height: 9px; border-radius: 50%; background: #d8dce3; display: block; }
.do-auth-mockup__bar { height: 10px; border-radius: 5px; background: #e4e7ec; margin-bottom: 8px; }
.do-auth-mockup__bar--short { width: 55%; margin-bottom: 0; }
.do-auth-mockup__bar--accent { background: var(--do-blue); opacity: 0.4; }
.do-auth-mockup__badge { position: absolute; bottom: 15%; right: 15%; width: 54px; height: 54px; border-radius: 50%; background: var(--do-success); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; font-weight: 700; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2); border: 4px solid #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .do-sidebar { position: fixed; transform: translateX(-100%); }
    .do-sidebar.is-open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.25); }
    .do-topbar__toggle { display: flex; }
    .do-content { padding: 18px; }
}
