/* Tickets de Cool Tabs: bandeja, ticket, administración y pantallas de acceso (base copiada del HelpDesk) */
:root {
  --brand: #db073c;
  --text: #222;
  --muted: #777;
  --border: #e2e2e2;
  --bg: #f6f6f7;
  --radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }

/* Cabecera */
.admin-header { display: flex; align-items: center; gap: 24px; background: var(--brand); color: #fff; padding: 0 20px; min-height: 52px; }
.admin-brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 600; }
.admin-brand img { height: 24px; width: auto; }
.admin-header nav { display: flex; gap: 18px; flex: 1; }
.admin-header nav a { color: #fff; }
.admin-user { display: flex; align-items: center; gap: 10px; }
.link-button { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
.admin-user form { display: inline; }
.admin-main { max-width: 1400px; margin: 0 auto; padding: 20px; }

.flash { margin: 12px 20px 0; padding: 10px 14px; border-radius: var(--radius); }
.flash--notice { background: #e7f6ec; color: #17633a; }
.flash--alert { background: #fde8ec; color: #9b1131; }

.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-header h1, .page-header h2, .page-title { margin: 8px 0 16px; }
h1 small, h2 small { font-weight: 400; font-size: 14px; color: var(--muted); }

.button { display: inline-block; padding: 7px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: #fff;
  color: var(--text); font: inherit; cursor: pointer; }
.button:hover { text-decoration: none; border-color: #bbb; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button--primary { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Filtros y tablas */
.filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.filters__row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters select.is-set, .filters input.filters__label:not(:placeholder-shown) { border-color: #1f73b7; background: #eef5fc; }
.other-locale { font-size: 13px; }
.other-locale--draft { color: var(--muted); }
.filters input, .filters select { padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); font: inherit; background: #fff; }
.filters input[type=search] { min-width: 360px; }
.filters input.filters__label { min-width: 180px; }
.search-snippet { margin-top: 3px; font-size: 13px; color: var(--muted); }
.search-snippet mark { background: #fff1b8; color: inherit; padding: 0 1px; }
.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: 13px; color: var(--muted); font-weight: 600; background: #fafafa; }
.sort-link { color: inherit; white-space: nowrap; }
.sort-link:hover, .sort-link.is-active { color: var(--text, #222); text-decoration: none; }

.badge { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 10px; background: #eee; color: #444; }
.public-link { margin-left: 6px; color: var(--muted); }
.public-link:hover { color: #1f73b7; text-decoration: none; }
.badge--published { background: #e7f6ec; color: #17633a; }
.badge--draft { background: #fff4e5; color: #8a5a00; }
.badge--pending { background: #fff7ed; color: #ad5918; border: 1px solid #f5c48f; }
.badge--missing { background: transparent; color: #bbb; }
.badge--internal { background: #e8eefc; color: #2b4aa0; }
.badge--archived { background: #eee; color: #666; }
.badge--promoted { background: transparent; color: var(--brand); }

.panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.panel h2 { font-size: 15px; margin: 0 0 6px; }
.panel p { margin: 4px 0; }

/* Formularios */
.form { display: flex; flex-direction: column; gap: 6px; }
.form.narrow { max-width: 560px; }
.form label { font-size: 13px; color: #555; margin-top: 6px; }
.form input[type=text], .form input[type=email], .form input[type=password], .form input[type=number],
.form select, .form textarea, .fieldset input, .fieldset textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: var(--radius); font: inherit; background: #fff; }
.form .checkbox { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; }
.form input[type=submit] { align-self: flex-start; margin-top: 10px; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px 12px; display: flex; flex-direction: column; gap: 4px; }

/* Historial */
.tabs { display: flex; gap: 6px; margin: 8px 0 12px; }
.tabs button { border: 1px solid var(--border); background: #fff; padding: 6px 12px; border-radius: var(--radius); cursor: pointer; font: inherit; }
.tabs button.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }
.tab-panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; }
.diff { white-space: pre-wrap; line-height: 1.7; }
.diff ins, .diff-title ins { background: #d7f5dd; text-decoration: none; }
.diff del, .diff-title del { background: #fbd5dc; }
.version-content img { max-width: 100%; height: auto; }

/* Acceso */
body.auth { display: grid; place-items: center; min-height: 100vh; background: var(--brand); }
.auth-card { background: #fff; border-radius: 10px; padding: 28px 32px; width: min(420px, 92vw); box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.auth-card h1 { margin: 12px 0; font-size: 22px; }
.auth-logo { width: 160px; height: auto; border-radius: 4px; }
.auth-card .flash { margin: 8px 0; }
.auth-links { font-size: 14px; margin-top: 16px; }



/* Tokens de API */
.code-sample { background: #f6f6f7; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; overflow-x: auto;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.token-created { border-color: #8fd3a8; background: #f2fbf5; }
.form--inline { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.form--inline input[type=text] { flex: 1; min-width: 240px; }

/* Verificación en dos pasos y Seguridad */
.two-factor-option { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.two-factor-or { text-align: center; color: var(--muted); font-size: 13px; margin: 14px 0 4px; }
.two-factor-code { font-size: 22px !important; letter-spacing: 6px; text-align: center; font-family: ui-monospace, monospace; }
.auth-links form { display: inline; }
.link-button--dark { color: var(--brand); }
.totp-setup { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.totp-qr svg { width: 200px; height: 200px; display: block; background: #fff; }
.totp-secret { font-size: 15px; letter-spacing: 1px; }
.form.form--inline { flex-direction: row; align-items: center; }
.form--inline > input[type=text] { flex: 1; min-width: 200px; }
.form--inline > .flash { flex-basis: 100%; margin: 4px 0 0; }

/* Mi cuenta */
.admin-user a { color: #fff; font-weight: 600; }
.account-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 0 16px; }
.account-tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.account-tabs a.is-active { color: var(--text); border-bottom-color: var(--brand); font-weight: 600; }
.account-tabs a:hover { text-decoration: none; color: var(--text); }
.form input:disabled { background: #f6f6f7; color: var(--muted); }


/* ── Tickets ─────────────────────────────────────────────────────────────── */
.flash--shadow { background: #fff7ed; color: #8a4b0f; border: 1px solid #f5c48f; }
.panel--alert { border-color: #f1a7b6; background: #fff6f8; }
.text-alert { color: #9b1131; font-weight: 600; }
.inline { display: inline; }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { margin: 3px 0; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.button--small { padding: 3px 9px; font-size: 13px; }

/* Bandeja: las vistas como pestañas, con su contador */
.view-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.view-tabs a { padding: 7px 12px; border-radius: var(--radius); color: var(--muted); }
.view-tabs a.is-active { background: #fff; color: var(--text); font-weight: 600; border: 1px solid var(--border); }
.view-tabs .count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: #eee; font-size: 12px; text-align: center; color: #444; }
.tickets .ticket-subject { color: var(--text); font-weight: 400; }
.tickets td:nth-child(5) { white-space: nowrap; }
.filters__row input[type=search] { min-width: 280px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); font: inherit; }
.filters__row select { padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); font: inherit; background: #fff; }
/* Abiertos (le toca al equipo): en negrita, para que se vea qué requiere atención */
.tickets tr.is-waiting .ticket-subject { font-weight: 700; }
.tickets tr.is-pending .ticket-subject { font-weight: 500; }
.badge--open { background: #fde8ec; color: #9b1131; }
.badge--pending { background: #e8eefc; color: #2b4aa0; }
.badge--closed { background: #eee; color: #666; }
.badge--note { background: #fff1b8; color: #6b5300; }
.badge--delivery-pending, .badge--delivery-sending { background: #fff4e5; color: #8a5a00; }
.badge--delivery-sent { background: #e7f6ec; color: #17633a; }
.badge--delivery-failed { background: #fde8ec; color: #9b1131; font-weight: 600; }
.pagination a { margin-left: 10px; }

/* Ticket: conversación a la izquierda, datos a la derecha (debajo en pantallas estrechas) */
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .ticket-layout { grid-template-columns: minmax(0, 1fr); } }
.ticket-header h1 { font-size: 22px; margin: 4px 0; }
.previous-ticket { background: #eef5fc; border: 1px solid #c9ddf2; border-radius: var(--radius); padding: 8px 12px; font-size: 14px; }
.ticket-sidebar h2 { font-size: 14px; }
.ticket-sidebar h3 { margin: 12px 0 4px; color: var(--muted); }
.ticket-sidebar select { width: 100%; }
.audit li { line-height: 1.4; }

.timeline { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.msg { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
/* Las respuestas del equipo, con borde de marca a la izquierda; las notas internas, amarillas: nunca se confunden */
.msg--outbound { border-left: 4px solid var(--brand); }
.msg--note { background: #fffbe6; border-color: #f0dc8c; }
.msg--auto { opacity: .7; }
.msg__header { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.msg__date { margin-left: auto; }
.msg__recipients { margin: 2px 0 0; }
.msg__body { margin-top: 8px; overflow-wrap: anywhere; }
.msg__quoted summary { cursor: pointer; display: inline-block; padding: 0 8px; border-radius: 8px; background: #eee; color: #666; font-weight: 700; list-style: none; }
.msg__quoted summary::-webkit-details-marker { display: none; }
.msg__quoted > div { border-left: 3px solid #ddd; padding-left: 12px; margin-top: 8px; color: #555; }
.msg__attachments { margin: 10px 0 0; padding-left: 18px; font-size: 14px; }
.msg__attachments li { margin: 4px 0; }
/* Miniatura de una imagen adjunta (p. ej. una captura pegada en una nota); clic para verla entera */
.attachment-thumb { display: block; max-width: 320px; max-height: 240px; border: 1px solid var(--border); border-radius: 4px; margin-bottom: 2px; }
.msg__footer { margin-top: 8px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
/* Contenido de emails: imágenes y tablas sin desbordar la columna */
.email-content img { max-width: 100%; height: auto; }
.email-content table { max-width: 100%; }
.email-content blockquote { border-left: 3px solid #ddd; margin: 6px 0; padding-left: 10px; color: #555; }
.email-content p { margin: 0 0 .7em; }
/* Imagen remota bloqueada: un recuadro clicable en vez de la imagen */
/* Imagen remota bloqueada: una etiqueta pequeña y clicable (sin el tamaño que traía el email) */
.email-content img.remote-image { display: inline-block; width: auto !important; height: auto !important; max-width: 160px; padding: 2px 6px;
  border: 1px dashed #bbb; border-radius: 4px; background: #fafafa; color: var(--muted); font-size: 12px; cursor: pointer; }

.composer { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.composer textarea { font: inherit; min-height: 160px; }
.composer__actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 10px; flex-wrap: wrap; }
.composer__actions label { margin: 0; }
.composer__actions input[type=submit] { margin-top: 0; }

.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
