/* El espacio de trabajo: barra superior, «Mis tickets», el chat con el asistente y el detalle de un ticket. Paneles de
   grafito opacos (el cristal es solo del acceso) y el violeta, como siempre, solo para la acción y el avance. */
.work { --side-width: 280px; --detail-width: 420px; height: 100%; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; overflow: hidden; background: var(--ground); animation: work-in .5s var(--ease-out) both; }
.work-top { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 clamp(12px, 2vw, 24px); border-bottom: 1px solid rgba(var(--fg-rgb), .08); }
.work-brand { margin: 0 auto 0 0; font-size: 13px; font-weight: 600; letter-spacing: .08em; white-space: nowrap; }
.work-brand b { color: var(--muted); font-weight: 500; }
.work-chip { padding: 4px 10px; border: 1px solid var(--hairline); border-radius: 12px; color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
.work-chip.is-warning { border-color: var(--danger-line); background: var(--danger-bg); color: var(--danger-ink); }
.work-user { display: flex; align-items: center; gap: 8px; }
.work-user-chip { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border: 1px solid var(--hairline); border-radius: 18px; background: var(--panel); font-size: 13px; font-weight: 500; }
.work-user-chip b { color: var(--muted); font-weight: 500; }
.work-side-toggle { position: relative; flex: none; display: none; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--hairline); border-radius: 12px; background: transparent; color: var(--ink); cursor: pointer; }
.work-side-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.work-badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--ink); color: var(--ground); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }

.work-body { min-height: 0; display: grid; grid-template-columns: var(--side-width) minmax(0, 1fr); }
.work.has-detail .work-body { grid-template-columns: var(--side-width) minmax(0, 1fr) var(--detail-width); }
.work-side { min-height: 0; overflow-y: auto; padding: 20px 12px; border-right: 1px solid rgba(var(--fg-rgb), .08); scrollbar-width: thin; scrollbar-color: rgba(var(--fg-rgb), .14) transparent; }
.work-side h2 { margin: 0 8px 14px; font-size: 13px; font-weight: 600; letter-spacing: .08em; }
.work-chat { min-height: 0; min-width: 0; display: grid; grid-template-rows: 1fr auto; }
.work-detail { min-height: 0; display: grid; grid-template-rows: auto 1fr; border-left: 1px solid rgba(var(--fg-rgb), .08); background: var(--raised); animation: detail-in .35s var(--ease-out) both; }

/* Botones de la plataforma. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border: 1px solid transparent; border-radius: 12px; font: inherit; font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer; transition: background-color .18s ease, border-color .18s ease, color .18s ease, translate .18s ease; }
.btn:focus-visible { outline: 3px solid rgba(122, 90, 248, .55); outline-offset: 2px; }
.btn-primary { background: var(--violet); color: #fff; }
.btn-primary:hover { background: var(--violet-hover); translate: 0 -1px; }
.btn-ghost { border-color: var(--hairline); background: transparent; color: var(--ink); }
.btn-ghost:hover { background: rgba(var(--fg-rgb), .06); border-color: rgba(var(--fg-rgb), .26); }
.btn-quiet { background: transparent; color: var(--placeholder); font-weight: 500; }
.btn-quiet:hover { color: var(--ink); }
.btn-quiet.is-armed { border-color: var(--danger-line); background: var(--danger-bg); color: var(--danger-ink); }
.btn-link { height: auto; margin-left: auto; padding: 4px 2px; background: transparent; color: var(--muted); font-weight: 500; }
.btn-link:hover { color: var(--ink); }

/* Chat */
.chat-scroll { min-height: 0; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(var(--fg-rgb), .14) transparent; }
.chat-list { display: flex; flex-direction: column; gap: 14px; width: min(760px, 100%); min-height: 100%; margin: 0 auto; padding: 28px clamp(14px, 3vw, 28px) 20px; }
.chat-row { display: flex; align-items: flex-end; gap: 10px; }
.chat-row.is-new { animation: chat-in .35s var(--ease-out) both; }
.chat-row-mine { justify-content: flex-end; }
.chat-avatar { flex: none; width: 28px; height: 28px; border-radius: 50%; }
.chat-bubble { max-width: min(560px, 86%); padding: 10px 14px 8px; border-radius: 16px 16px 16px 6px; background: var(--panel); }
.chat-row-mine .chat-bubble { border-radius: 16px 16px 6px 16px; background: var(--bubble-mine); }
.chat-bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-bubble time { display: block; margin-top: 2px; color: var(--placeholder); font-size: 11px; text-align: right; }
.chat-row-card { display: block; padding-left: 38px; }
.chat-row-notice { padding-left: 38px; }
.chat-notice { display: flex; align-items: center; gap: 10px; max-width: 100%; padding: 7px 12px 7px 7px; border: 1px solid var(--hairline); border-radius: 12px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; text-align: left; cursor: pointer; transition: background-color .18s ease, border-color .18s ease; }
.chat-notice:hover { background: rgba(var(--fg-rgb), .05); border-color: rgba(var(--fg-rgb), .26); }
.chat-notice:focus-visible { outline: 3px solid rgba(122, 90, 248, .55); outline-offset: 2px; }
.chat-notice-text { min-width: 0; color: var(--ink); overflow-wrap: anywhere; }
.chat-notice time { flex: none; color: var(--placeholder); font-size: 11px; }
.chat-dots { display: inline-flex; gap: 5px; padding: 13px 14px; border-radius: 16px 16px 16px 6px; background: var(--panel); }
.chat-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: chat-dot 1.1s ease-in-out infinite; }
.chat-dots i:nth-child(2) { animation-delay: .15s; }
.chat-dots i:nth-child(3) { animation-delay: .3s; }

.chat-empty { margin: auto; display: grid; justify-items: center; gap: 12px; max-width: 520px; padding: 20px 0; text-align: center; }
.chat-empty-logo { width: 52px; height: 52px; border-radius: 50%; }
.chat-empty h1 { margin: 6px 0 0; font-size: clamp(28px, 3vw, 36px); font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.chat-empty p { margin: 0; color: var(--muted); text-wrap: pretty; }
.chat-examples { display: grid; gap: 8px; width: 100%; margin-top: 8px; }
.chat-example { padding: 11px 14px; border: 1px solid var(--hairline); border-radius: 12px; background: var(--panel); color: var(--ink); font: inherit; font-size: 14px; text-align: left; cursor: pointer; transition: border-color .18s ease, translate .18s ease; }
.chat-example:hover { border-color: rgba(var(--fg-rgb), .3); translate: 0 -1px; }
.chat-example:focus-visible { outline: 3px solid rgba(122, 90, 248, .55); outline-offset: 2px; }
.chat-empty .chat-empty-note { margin-top: 6px; color: var(--placeholder); font-size: 13px; }

.chat-composer { display: flex; align-items: flex-end; gap: 10px; width: min(760px, 100% - 2 * clamp(14px, 3vw, 28px)); margin: 0 auto clamp(14px, 2.4vh, 24px); padding: 8px 8px 8px 16px; border: 1px solid rgba(var(--fg-rgb), .16); border-radius: 18px; background: var(--field); transition: border-color .18s ease, outline-color .18s ease; outline: 3px solid transparent; outline-offset: 1px; }
.chat-composer:focus-within { border-color: var(--violet); outline-color: rgba(122, 90, 248, .35); }
.chat-composer textarea { flex: 1; min-width: 0; max-height: 180px; margin: 0; padding: 8px 0; border: 0; background: transparent; color: var(--ink); caret-color: var(--violet); font: inherit; line-height: 1.45; resize: none; outline: none; scrollbar-width: thin; }
.chat-composer textarea::placeholder { color: var(--placeholder); }
.chat-send { flex: none; display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 12px; background: var(--violet); color: #fff; cursor: pointer; transition: background-color .18s ease, opacity .18s ease, translate .18s ease; }
.chat-send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chat-send:hover:not(:disabled) { background: var(--violet-hover); translate: 0 -1px; }
.chat-send:disabled { opacity: .35; cursor: default; }
.chat-send:focus-visible { outline: 3px solid rgba(122, 90, 248, .55); outline-offset: 2px; }

.toast { position: fixed; left: 50%; bottom: 96px; z-index: 200; max-width: min(520px, 100% - 32px); margin: 0; padding: 10px 14px; border: 1px solid var(--danger-line); border-radius: 12px; background: var(--danger-bg); color: var(--danger-ink); font-size: 13px; translate: -50% 0; animation: chat-in .3s var(--ease-out) both; }

/* Ajustes: un diálogo de grafito opaco. */
.settings { width: min(620px, 100% - 24px); max-height: min(760px, 100% - 24px); padding: 0; border: 1px solid var(--hairline); border-radius: 20px; background: var(--raised); color: var(--ink); box-shadow: 0 30px 70px rgba(0, 0, 0, .5); overflow: hidden; }
.settings[open] { display: grid; grid-template-rows: auto 1fr; animation: chat-in .3s var(--ease-out) both; }
.settings::backdrop { background: var(--overlay); }
.settings-head { display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 12px 0 22px; border-bottom: 1px solid rgba(var(--fg-rgb), .08); }
.settings-head h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.settings-body { min-height: 0; overflow-y: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 26px; padding: 22px; scrollbar-width: thin; scrollbar-color: rgba(var(--fg-rgb), .14) transparent; }
.settings-section { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.settings-section h3 { margin: 0; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .04em; }
.settings-note { margin: 0; color: var(--muted); font-size: 14px; }
.settings-error { margin: 0; padding: 10px 12px; border: 1px solid var(--danger-line); border-radius: 10px; background: var(--danger-bg); color: var(--danger-ink); font-size: 13px; }
.settings-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.settings-account { display: inline-flex; align-items: center; gap: 10px; font-weight: 500; }
.settings-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--violet); }
.settings-code { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--hairline); border-radius: 14px; background: var(--field); }
.settings-code .settings-row { justify-content: flex-start; }
.settings-code-value { margin: 0; font-size: clamp(22px, 8vw, 34px); font-weight: 700; letter-spacing: .08em; font-variant-numeric: tabular-nums; white-space: nowrap; user-select: all; }
.settings-list { display: grid; gap: 8px; }
.settings-item { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid rgba(var(--fg-rgb), .1); border-radius: 12px; }
.settings-item-main { flex: 1 1 200px; display: grid; min-width: 0; }
.settings-item-name { overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.settings-item-repo { overflow: hidden; color: var(--placeholder); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.settings-select { height: 36px; padding: 0 10px; border: 1px solid rgba(var(--fg-rgb), .16); border-radius: 12px; background: var(--field); color: var(--ink); font: inherit; font-size: 13px; }
.settings-select:focus-visible { border-color: var(--violet); outline: 3px solid rgba(122, 90, 248, .35); outline-offset: 1px; }
.settings-search { flex: none; width: 100%; }
.settings-ready { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.settings-ready li { display: flex; gap: 10px; }
.settings-ready .detail-mark { flex: none; }
.settings-ready li.is-ok > .detail-mark { border-color: var(--violet); background: var(--violet); color: #fff; }
.settings-ready li.is-missing > .detail-mark { border-color: #a8555c; background: var(--danger-bg); color: var(--danger-ink); }
.settings-ready li.is-unknown > .detail-mark { border-style: dashed; }
.settings-ready-label { display: block; font-size: 14px; font-weight: 500; }
.settings-ready-detail { display: block; color: var(--placeholder); font-size: 13px; }
.settings-ready li.is-missing .settings-ready-detail { color: var(--danger-ink); }
.settings-fields { flex: 1 1 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.settings-field { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 500; }
.settings-field .ticket-input { width: 100%; }
a.btn { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }

@keyframes work-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes detail-in { from { translate: 16px 0; } to { translate: 0 0; } }
@keyframes chat-in { from { translate: 0 8px; } to { translate: 0 0; } }
@keyframes chat-dot { 0%, 60%, 100% { translate: 0 0; opacity: .5; } 30% { translate: 0 -4px; opacity: 1; } }

/* Pantallas medianas: el detalle se superpone a la derecha en vez de estrechar el chat. */
@media (max-width: 1180px) {
  .work.has-detail .work-body { grid-template-columns: var(--side-width) minmax(0, 1fr); }
  .work-detail { position: fixed; top: 56px; right: 0; bottom: 0; z-index: 20; width: min(var(--detail-width), 100%); box-shadow: -30px 0 60px rgba(0, 0, 0, .45); }
}
/* Móvil: «Mis tickets» se abre desde su botón. */
@media (max-width: 820px) {
  .work-body, .work.has-detail .work-body { grid-template-columns: minmax(0, 1fr); }
  .work-side-toggle { display: grid; }
  .work-side { position: fixed; top: 56px; left: 0; bottom: 0; z-index: 15; width: min(320px, 88%); background: var(--raised); translate: -100% 0; transition: translate .3s var(--ease-out); }
  .work.has-side .work-side { translate: 0 0; box-shadow: 30px 0 60px rgba(0, 0, 0, .45); }
  .work-brand b, .work-user-chip b { display: none; }
  .chat-row-card, .chat-row-notice { padding-left: 0; }
}
@media (max-width: 520px) {
  .work-brand, .work-user-chip { display: none; }
  .work-user { margin-left: auto; }
  .work-top { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .work, .work *, .work *::before, .work *::after { animation: none !important; transition-duration: .01ms !important; }
}
