/* Plaza IA — estilos con la identidad corporativa de Ediciones Plaza
   Colores del manual: Pantone 5415 C #607387 · 45% #B3B8C5 · gris #e4e4e4 */
:root {
  --azul: #607387;
  --azul-oscuro: #4b5c6e;
  --azul-suave: #B3B8C5;
  --azul-fondo: #eef1f4;
  --azul-borde: #ccd4dc;
  --tinta: #1c1c1e;
  --gris: #6b6b70;
  --fondo: #f5f5f4;
  --borde: #e4e4e4;
  --blanco: #ffffff;
  --radio: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Cabinet Grotesk", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--fondo); color: var(--tinta); font-size: 15.5px; line-height: 1.55;
}
a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Barra superior */
.topbar {
  display: flex; align-items: center; gap: 24px;
  background: var(--blanco); border-bottom: 1px solid var(--borde);
  padding: 0 24px; height: 60px; position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-symbol { height: 30px; width: auto; }
.brand-text { font-size: 22px; font-weight: 800; color: var(--tinta); letter-spacing: -0.5px; }
.brand-text span { color: var(--azul); }
.brand:hover { text-decoration: none; }
.topnav { display: flex; gap: 18px; }
.topnav a { color: var(--tinta); font-weight: 500; }
.topnav a.admin-link { color: var(--azul); font-weight: 700; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.credits-chip {
  background: var(--azul-fondo); border: 1px solid var(--azul-borde); color: var(--azul-oscuro);
  border-radius: 999px; padding: 5px 14px; font-size: 13px; white-space: nowrap;
}
.credits-chip .sep { opacity: .5; margin: 0 4px; }
.username { color: var(--gris); font-size: 14px; }
.inline { display: inline; }

.container { max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }
.narrow { max-width: 480px; margin: 40px auto; }
.center { text-align: center; }
.page-title { margin: 0 0 4px; font-size: 27px; font-weight: 800; letter-spacing: -0.5px; }
.muted { color: var(--gris); }
.muted-link { color: var(--gris); font-size: 14px; }

/* Tarjetas de herramientas */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 18px; margin: 22px 0 36px; }
.tool-card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 9px;
  background: linear-gradient(160deg, #ffffff 62%, var(--azul-fondo) 100%);
  border: 1px solid var(--azul-borde); border-radius: 14px;
  padding: 20px 20px 18px; color: var(--tinta);
  transition: box-shadow .22s ease, transform .22s ease, border-color .22s ease;
}
.tool-card:hover {
  text-decoration: none; transform: translateY(-5px);
  box-shadow: 0 16px 34px rgba(75,92,110,.24);
  border-color: var(--azul);
}
.tool-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.tool-icon {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 13px;
  background: linear-gradient(140deg, #71869b, var(--azul-oscuro));
  box-shadow: 0 5px 12px rgba(75,92,110,.35);
  transition: transform .22s;
}
.tool-icon img { width: 26px; height: auto; }
.tool-card:hover .tool-icon { transform: scale(1.08) rotate(-3deg); }
.tool-badges { display: flex; gap: 6px; }
.tool-badge {
  font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--azul-oscuro); background: #fff; border: 1px solid var(--azul-borde);
  border-radius: 999px; padding: 3px 10px;
}
.tool-badge-skill { color: #fff; background: var(--azul); border-color: var(--azul); }
.tool-name { font-weight: 800; font-size: 19px; letter-spacing: -0.3px; color: var(--azul-oscuro); line-height: 1.25; position: relative; z-index: 1; }
.tool-desc { font-size: 14px; position: relative; z-index: 1; max-width: 92%; }
.tool-how { font-size: 13px; color: var(--gris); position: relative; z-index: 1; max-width: 92%; }
.tool-how span {
  display: block; font-size: 11px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: var(--azul); margin-bottom: 2px;
}
.tool-footer { margin-top: auto; padding-top: 12px; position: relative; z-index: 1; }
.tool-open {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13.5px; font-weight: 800; color: var(--azul);
  border: 1.5px solid var(--azul); border-radius: 999px; padding: 7px 16px;
  background: #fff; transition: background .2s, color .2s;
}
.tool-open b { transition: transform .2s; font-weight: 800; }
.tool-card:hover .tool-open { background: var(--azul); color: #fff; }
.tool-card:hover .tool-open b { transform: translateX(4px); }
.tool-mark {
  position: absolute; right: -55px; bottom: -55px; width: 190px; height: auto;
  opacity: .06; pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.tool-card:hover .tool-mark { opacity: .12; transform: scale(1.06) rotate(-3deg); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; }
.section-head h2 { font-size: 18px; margin: 0 0 10px; }

/* Tarjetas y tablas */
.card { background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); padding: 18px; }
.card.empty { color: var(--gris); text-align: center; padding: 32px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--gris); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--borde); }
.table td { padding: 9px 10px; border-bottom: 1px solid #f0efec; }
.table tr:last-child td { border-bottom: none; }

/* Botones */
.btn {
  display: inline-block; border: none; border-radius: 8px; cursor: pointer;
  font-size: 14px; font-weight: 700; padding: 9px 18px; font-family: inherit;
}
.btn-primary { background: var(--azul); color: #fff; }
.btn-primary:hover { background: var(--azul-oscuro); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--tinta); border: 1px solid var(--borde); }
.btn-ghost:hover { background: #f0efec; text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-danger { background: #fff; color: #a33; border: 1px solid #e5c9c9; }

/* Formularios */
.form label, label { display: block; font-size: 14px; font-weight: 700; margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; margin-top: 5px; padding: 9px 11px; border: 1px solid var(--borde); border-radius: 8px;
  font-family: inherit; font-size: 14px; background: #fff; font-weight: 400;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul-suave); }
textarea { resize: vertical; }
.alert { border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.alert-error { background: #faf0f0; border: 1px solid #e5c9c9; color: #8c2f2f; }
.alert-ok { background: var(--azul-fondo); border: 1px solid var(--azul-borde); color: var(--azul-oscuro); }
.copy-row { display: flex; gap: 8px; margin-top: 8px; }
.copy-row input { font-size: 13px; background: #fff; }

/* Login */
.login-body { min-height: 100vh; margin: 0; display: grid; place-items: center; background: var(--fondo); font-family: "Cabinet Grotesk", -apple-system, "Segoe UI", Arial, sans-serif; }
.login-split {
  display: grid; grid-template-columns: 340px 400px; border-radius: 16px; overflow: hidden;
  box-shadow: 0 14px 50px rgba(28,28,30,.16); background: #fff; max-width: 96vw;
}
.login-side {
  background: var(--azul); color: #fff; padding: 36px; display: flex; flex-direction: column; justify-content: space-between;
}
.login-symbol { width: 150px; align-self: flex-start; opacity: .95; }
.login-side-title { font-size: 34px; font-weight: 800; letter-spacing: -1px; }
.login-side-title span { opacity: .8; }
.login-side-text p { margin: 6px 0 0; opacity: .85; font-size: 15px; }
.login-card { padding: 36px; }
.login-logo { height: 44px; width: auto; margin-bottom: 18px; }
.login-title { font-size: 22px; margin: 0 0 18px; font-weight: 800; letter-spacing: -0.5px; }
.login-title span { color: var(--azul); }
.login-links { margin-top: 16px; font-size: 14px; }
@media (max-width: 820px) { .login-split { grid-template-columns: 1fr; } .login-side { display: none; } }

/* Chat */
.chat-page { display: flex; flex-direction: column; height: calc(100vh - 160px); }
.chat-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.chat-title { margin: 0; font-size: 21px; font-weight: 800; }
.chat-sub { margin: 2px 0 12px; font-size: 13px; }
.chat-box {
  flex: 1; overflow-y: auto; background: var(--blanco); border: 1px solid var(--borde);
  border-radius: var(--radio); padding: 18px; display: flex; flex-direction: column; gap: 12px;
}
.chat-box.drag { outline: 2px dashed var(--azul); outline-offset: -6px; }
.chat-welcome { background: var(--azul-fondo); border: 1px dashed var(--azul-borde); border-radius: var(--radio); padding: 14px 16px; color: var(--azul-oscuro); font-size: 14px; }
.chat-welcome p { margin: 4px 0; }
.msg { display: flex; }
.msg-user { justify-content: flex-end; }
.msg-bubble {
  max-width: 78%; border-radius: 12px; padding: 10px 14px; font-size: 14.5px;
  white-space: normal; overflow-wrap: break-word;
}
.msg-user .msg-bubble { background: var(--azul); color: #fff; border-bottom-right-radius: 4px; }
.msg-assistant .msg-bubble { background: #f1f2f4; border-bottom-left-radius: 4px; }
.msg-bubble h3, .msg-bubble h4 { margin: 10px 0 4px; }
.msg-bubble li { margin-left: 18px; }
.msg-error { color: #8c2f2f; }
.msg-atts { margin-bottom: 6px; }
.att-chip {
  display: inline-block; background: rgba(255,255,255,.25); border: 1px solid rgba(255,255,255,.4);
  border-radius: 999px; padding: 2px 10px; margin: 2px 4px 2px 0; font-size: 12.5px;
}
.msg-assistant .att-chip { background: #fff; border-color: var(--borde); }
.pending-files { margin-top: 10px; }
.pending-files .att-chip { background: var(--azul-fondo); border-color: var(--azul-borde); color: var(--azul-oscuro); cursor: default; }
.pending-files .att-chip b { cursor: pointer; margin-left: 4px; }
.typing { letter-spacing: 3px; color: var(--gris); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.chat-form { display: flex; gap: 10px; margin-top: 8px; align-items: flex-end; }
.chat-form textarea { flex: 1; margin-top: 0; }
.attach-btn { font-size: 17px; padding: 9px 13px; }
.chat-status { min-height: 20px; color: var(--gris); font-size: 13px; margin-top: 6px; font-style: italic; }
.files-block { background: var(--azul-fondo); border: 1px solid var(--azul-borde); border-radius: var(--radio); padding: 12px 14px; }
.files-title { font-size: 13px; font-weight: 800; color: var(--azul-oscuro); margin-bottom: 8px; }
.file-pill {
  display: inline-block; background: #fff; border: 1px solid var(--azul-borde); border-radius: 999px;
  padding: 6px 14px; margin: 3px 6px 3px 0; font-size: 13.5px; font-weight: 700;
}

/* Estudio de trabajo (pantalla de herramienta) */
.studio { display: grid; grid-template-columns: 250px minmax(0, 1fr) 400px; gap: 18px; height: calc(100vh - 135px); }
.studio-left { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.studio-tool { display: flex; gap: 10px; align-items: center; }
.tool-icon-sm { width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0; }
.tool-icon-sm img { width: 22px; }
.studio-tool-name { font-weight: 800; font-size: 15.5px; line-height: 1.25; letter-spacing: -0.2px; }
.studio-info-btn { background: none; border: none; color: var(--azul); font-size: 12.5px; cursor: pointer; padding: 0; font-weight: 700; font-family: inherit; }
.studio-info { display: none; background: var(--azul-fondo); border: 1px solid var(--azul-borde); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.studio-info.open { display: block; }
.studio-info p { margin: 4px 0; }
.studio-jobs-title { font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--gris); margin-top: 8px; padding-left: 2px; }
.studio-jobs { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; }
.studio-job { display: block; padding: 8px 10px; border-radius: 9px; color: var(--tinta); font-size: 13.5px; border: 1px solid transparent; }
.studio-job:hover { background: #fff; text-decoration: none; border-color: var(--borde); }
.studio-job.active { background: #fff; border-color: var(--azul); box-shadow: 0 2px 8px rgba(96,115,135,.15); }
.studio-job-title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.studio-job-date { font-size: 11.5px; color: var(--gris); }
.studio-center { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.studio-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.studio-head-titles { min-width: 0; }
.studio-head-actions { display: flex; gap: 6px; flex-shrink: 0; }
.studio-edit { display: none; margin-bottom: 10px; }
.studio-edit.open { display: block; }
.studio-center .chat-box { flex: 1; min-height: 0; }
.studio-right { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--borde); border-radius: 14px; overflow: hidden; min-height: 0; }
.preview-head {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(140deg, #71869b, var(--azul-oscuro)); color: #fff;
  padding: 10px 14px; font-weight: 800; font-size: 14px; letter-spacing: .02em;
}
.preview-actions { display: flex; gap: 8px; align-items: center; }
.preview-words { font-size: 12px; opacity: .9; font-weight: 600; white-space: nowrap; }
.preview-head .btn-ghost { border-color: rgba(255,255,255,.45); color: #fff; background: rgba(255,255,255,.12); }
.preview-head .btn-ghost:hover { background: rgba(255,255,255,.25); }
.preview-files { padding: 10px 14px; border-bottom: 1px solid var(--borde); background: var(--azul-fondo); }
.preview-files .files-title { margin-bottom: 6px; }
.preview-doc { flex: 1; overflow-y: auto; padding: 16px; background: #e9ebee; }
#preview-content { background: #fff; border-radius: 6px; box-shadow: 0 2px 12px rgba(28,28,30,.10); padding: 26px 28px; font-size: 14px; line-height: 1.7; }
#preview-content:empty { display: none; }
#preview-content h3, #preview-content h4 { margin: 14px 0 6px; }
.preview-empty { color: var(--gris); font-size: 13px; text-align: center; margin-top: 45%; line-height: 1.7; }
@media (max-width: 1250px) {
  .studio { grid-template-columns: 230px minmax(0, 1fr); }
  .studio-right { position: fixed; top: 70px; right: 12px; bottom: 12px; width: 400px; max-width: 92vw; z-index: 30; box-shadow: -8px 0 30px rgba(28,28,30,.25); display: none; }
  .studio-right.open { display: flex; }
}
@media (max-width: 860px) {
  .studio { grid-template-columns: 1fr; height: auto; }
  .studio-left { flex-direction: column; }
  .studio-jobs { max-height: 180px; }
  .studio-center .chat-box { min-height: 45vh; }
}

/* Admin */
.admin-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-tabs a {
  padding: 7px 16px; border-radius: 999px; border: 1px solid var(--borde);
  background: #fff; color: var(--tinta); font-size: 14px; font-weight: 700;
}
.admin-tabs a.active { background: var(--azul); border-color: var(--azul); color: #fff; }
.admin-tabs a:hover { text-decoration: none; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-tile { background: #fff; border: 1px solid var(--borde); border-left: 4px solid var(--azul); border-radius: var(--radio); padding: 16px; }
.stat-tile .num { font-size: 24px; font-weight: 800; }
.stat-tile .lbl { color: var(--gris); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } .topnav { display: none; } }
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; }
.pill-cat { background: var(--azul-fondo); color: var(--azul-oscuro); margin-right: 4px; }
.pill-on { background: #eefaf0; color: #1e7c34; }
.pill-off { background: #faf0f0; color: #8c2f2f; }
.dropzone {
  border: 2px dashed var(--azul-borde); border-radius: var(--radio); padding: 26px; text-align: center;
  color: var(--gris); background: var(--azul-fondo); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone.drag { border-color: var(--azul); background: #e2e8ee; }
.footer { text-align: center; padding: 26px 0 34px; }
.footer-logo { height: 34px; width: auto; opacity: .5; }
h1 { font-size: 24px; }
