/* ================================================================
   DWW Agentur Feedback Platform — style.css
   ================================================================ */

/* ---------- Fuentes locales (DM Sans variable font v17) ---------- */
/* latin-ext: cubre ä, ö, ü, ñ, á, é, í, ó, ú, etc. */
@font-face {
  font-family: 'DM Sans';
  src: url('./fonts/DMSans-Ext.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
                 U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
                 U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
                 U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin: caracteres básicos */
@font-face {
  font-family: 'DM Sans';
  src: url('./fonts/DMSans.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC,
                 U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
                 U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
                 U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Variables ---------- */
:root {
  --dark:    #0F1A24;
  --white:   #FFFFFF;
  --border:  #E8E8E8;
  --surface: #F5F5F5;
  --grad:    linear-gradient(45deg, #F1136C, #FE6109);
  --shadow:  0 2px 12px rgba(15,26,36,.08);
  --radius:  10px;
  --font:    'DM Sans', system-ui, sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  font-weight: 400;
  color: var(--dark);
  background: var(--white);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: var(--font); cursor: pointer; border: none; }
input, textarea, select { font-family: var(--font); }
ul { list-style: none; }

/* ---------- Tipografía ---------- */
h1,h2,h3,h4 { font-weight: 700; line-height: 1.2; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .75rem; }
.text-muted { color: #6B7280; }
.font-bold { font-weight: 700; }

/* ---------- Header ---------- */
.header {
  background: var(--dark);
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
}
.header-logo.invert { filter: invert(1); }
.header-title {
  color: var(--white);
  font-weight: 700;
  font-size: 1rem;
}
.header-spacer { flex: 1; }
.header-user {
  color: rgba(255,255,255,.6);
  font-size: .875rem;
}
.header-btn-logout {
  background: transparent;
  color: rgba(255,255,255,.7);
  font-size: .8125rem;
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 6px;
  transition: background .2s;
}
.header-btn-logout:hover { background: rgba(255,255,255,.1); }

/* ---------- Layout shell ---------- */
.app-shell {
  display: flex;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 320px;
  min-width: 280px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--white);
  overflow: hidden;
}
.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: .9375rem;
  transition: transform 1s ease;
  white-space: nowrap;
}
.btn:hover  { transform: scale(1.03); }
.btn:active { transform: scale(1.03); }
.btn:focus  { outline: none; transform: scale(1.03); }

.btn-primary {
  background: var(--grad);
  color: var(--white);
}
.btn-dark {
  background: var(--dark);
  color: var(--white);
}
.btn-ghost {
  background: transparent;
  color: var(--dark);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface); }
.btn-sm {
  padding: 6px 12px;
  font-size: .8125rem;
  border-radius: 6px;
}
.btn-icon {
  padding: 8px;
  border-radius: 8px;
  background: transparent;
  color: var(--dark);
}
.btn-icon:hover { background: var(--surface); }
.btn-danger {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
}
.btn-danger:hover { background: #fecaca; transform: scale(1.03); }
.btn-full { width: 100%; }

/* ---------- Formularios ---------- */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: .875rem;
  font-weight: 700;
  color: var(--dark);
}
.form-input, .form-select, .form-textarea {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .9375rem;
  color: var(--dark);
  background: var(--white);
  transition: border-color .15s;
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: #F1136C;
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: .75rem; color: #6B7280; }

/* ---------- Alertas ---------- */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: .875rem;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.alert-error   { background: #fee2e2; color: #dc2626; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* ---------- Tarjetas de proyecto ---------- */
.project-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--white);
  transition: box-shadow .2s;
}
.project-card:hover { box-shadow: var(--shadow); }
.project-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 8px;
}
.project-card-title { font-weight: 700; font-size: 1rem; }
.project-card-url   { font-size: .8125rem; color: #6B7280; word-break: break-all; }
.project-card-meta  { display: flex; gap: 16px; margin: 12px 0; flex-wrap: wrap; }
.project-card-meta-item { font-size: .8125rem; color: #6B7280; }
.project-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: .6875rem;
  font-weight: 700;
}
.badge-orange { background: #FE6109; color: white; }
.badge-red    { background: #F1136C; color: white; }
.badge-green  { background: #059669; color: white; }
.badge-gray   { background: var(--border); color: #6B7280; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white);
  border-radius: 14px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transform: translateY(12px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: #6B7280;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--dark); }
.modal-body { display: flex; flex-direction: column; gap: 16px; }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 8px;
}

/* ---------- Credenciales / Caja copy ---------- */
.credentials-box {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.credential-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.credential-label { font-size: .75rem; font-weight: 700; color: #6B7280; text-transform: uppercase; letter-spacing: .04em; }
.credential-value { font-size: .9375rem; font-weight: 700; word-break: break-all; }
.copy-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  flex: 1;
}
.copy-field input {
  border: none;
  background: transparent;
  flex: 1;
  font-size: .875rem;
  color: var(--dark);
  outline: none;
  min-width: 0;
}
.copy-field .copy-icon {
  cursor: pointer;
  color: #6B7280;
  flex-shrink: 0;
  font-size: 1rem;
}
.copy-field .copy-icon:hover { color: var(--dark); }

/* ---------- Vista de feedback (iframe + pins) ---------- */
.feedback-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
}
.feedback-toolbar {
  padding: 12px 20px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.iframe-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  margin: 16px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--white);
  box-shadow: var(--shadow);
}
.feedback-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}
.iframe-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.iframe-overlay.modo-comentar {
  pointer-events: all;
  cursor: crosshair;
}

/* ---------- Pins ---------- */
.pin {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: all;
  cursor: pointer;
  z-index: 10;
}
.pin-dot {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  transition: transform .2s, box-shadow .2s;
  background: var(--grad);
}
.pin-dot:hover {
  transform: rotate(-45deg) scale(1.15);
  box-shadow: 0 4px 16px rgba(241,19,108,.4);
}
.pin-number {
  transform: rotate(45deg);
  color: white;
  font-size: .6875rem;
  font-weight: 700;
  line-height: 1;
}
.pin.resolved .pin-dot {
  background: #059669;
}
.pin-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--dark);
  color: var(--white);
  font-size: .75rem;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  max-width: 200px;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 20;
  text-align: center;
}
.pin:hover .pin-tooltip { opacity: 1; }
.pin-new-form {
  position: absolute;
  z-index: 30;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  width: 240px;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  transform: translateX(-50%);
}
.pin-new-form textarea {
  width: 100%;
  resize: none;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  font-size: .875rem;
  font-family: var(--font);
  color: var(--dark);
  outline: none;
  min-height: 70px;
  margin-bottom: 10px;
}
.pin-new-form textarea:focus { border-color: #F1136C; }
.pin-new-form-actions { display: flex; gap: 8px; }

/* ---------- Comentario en sidebar ---------- */
.comment-item {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--white);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.comment-item:hover { border-color: #F1136C; background: #fff5f8; }
.comment-item.resolved { opacity: .6; }
.comment-item.selected { border-color: #F1136C; background: #fff5f8; }
.comment-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.comment-number {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--grad);
  color: white;
  font-size: .6875rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.comment-number.resolved-num { background: #059669; }
.comment-autor { font-size: .75rem; font-weight: 700; }
.comment-tipo {
  font-size: .625rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.tipo-cliente { background: #dbeafe; color: #1e40af; }
.tipo-agencia { background: var(--dark); color: var(--white); }
.comment-text { font-size: .875rem; color: var(--dark); line-height: 1.4; }
.comment-date { font-size: .6875rem; color: #6B7280; margin-top: 6px; }
.comment-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ---------- Replies ---------- */
.replies-list {
  margin-top: 8px;
  border-left: 2px solid var(--border);
  padding-left: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.reply-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.reply-autor {
  font-size: .6875rem;
  font-weight: 600;
  color: var(--dark);
}
.reply-text {
  font-size: .8125rem;
  color: var(--dark);
  line-height: 1.4;
}
.reply-date {
  font-size: .625rem;
  color: #9CA3AF;
}

/* ---------- Filtros ---------- */
.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-radius: 8px;
  padding: 4px;
}
.filter-tab {
  flex: 1;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: .8125rem;
  font-weight: 700;
  background: transparent;
  color: #6B7280;
  transition: background .15s, color .15s;
  text-align: center;
  cursor: pointer;
  border: none;
}
.filter-tab.active { background: var(--white); color: var(--dark); box-shadow: 0 1px 4px rgba(0,0,0,.1); }

/* ---------- Chat ---------- */
.chat-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
}
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #FAFAFA;
}
.chat-footer {
  padding: 16px 20px;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.chat-textarea {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: .9375rem;
  font-family: var(--font);
  resize: none;
  min-height: 44px;
  max-height: 120px;
  outline: none;
  color: var(--dark);
  background: var(--white);
  transition: border-color .15s;
}
.chat-textarea:focus { border-color: #F1136C; }

/* Burbujas */
.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}
.msg-row.agencia { align-self: flex-end; align-items: flex-end; }
.msg-row.cliente  { align-self: flex-start; align-items: flex-start; }
.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: .9375rem;
  line-height: 1.45;
  word-break: break-word;
  max-width: 100%;
}
.msg-row.agencia .msg-bubble {
  background: var(--dark);
  color: var(--white);
  border-bottom-right-radius: 4px;
}
.msg-row.cliente .msg-bubble {
  background: var(--surface);
  color: var(--dark);
  border-bottom-left-radius: 4px;
}
.msg-meta {
  font-size: .6875rem;
  color: #9CA3AF;
  margin-top: 4px;
  padding: 0 4px;
}

/* Adjuntos en chat */
.msg-attachment {
  max-width: 280px;
  border-radius: 12px;
  overflow: hidden;
  border: 1.5px solid var(--border);
  background: var(--white);
}
.msg-attachment img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  display: block;
  cursor: pointer;
}
.msg-attachment video {
  width: 100%;
  max-height: 200px;
  display: block;
}
.msg-attachment-info {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.msg-attachment-icon { font-size: 1.5rem; flex-shrink: 0; }
.msg-attachment-name {
  flex: 1;
  font-size: .8125rem;
  font-weight: 700;
  word-break: break-all;
  color: var(--dark);
}
.msg-attachment-dl {
  font-size: .75rem;
  color: #F1136C;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

/* Preview de archivo antes de enviar */
.attachment-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: .8125rem;
}
.attachment-preview-name { flex: 1; font-weight: 700; word-break: break-all; }
.attachment-preview-remove {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #dc2626;
  font-size: 1rem;
  line-height: 1;
}

/* ---------- Indicador de no leídos ---------- */
.unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #F1136C;
  flex-shrink: 0;
}

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  background: var(--dark);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.login-logo-wrap {
  display: flex;
  justify-content: center;
}
.login-logo {
  height: 40px;
  width: auto;
  filter: invert(1);
}
.login-title {
  text-align: center;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--dark);
}
.login-subtitle {
  text-align: center;
  font-size: .875rem;
  color: #6B7280;
  margin-top: -16px;
}

/* ---------- Dashboard grid ---------- */
.dashboard-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.dashboard-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
}

/* ---------- Spinner ---------- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
.spinner-dark {
  border-color: rgba(15,26,36,.2);
  border-top-color: var(--dark);
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: #6B7280;
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #6B7280;
}
.empty-state h3 { margin-bottom: 8px; color: var(--dark); }

/* ---------- Utils ---------- */
.hidden      { display: none !important; }
.d-flex      { display: flex; }
.d-col       { flex-direction: column; }
.gap-4       { gap: 4px; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.gap-16      { gap: 16px; }
.gap-20      { gap: 20px; }
.items-center { align-items: center; }
.flex-1      { flex: 1; }
.w-full      { width: 100%; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.p-20  { padding: 20px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Toast ---------- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--dark);
  color: var(--white);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: .875rem;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  animation: toast-in .25s ease;
  pointer-events: all;
  max-width: 320px;
}
.toast.success { background: #065f46; }
.toast.error   { background: #7f1d1d; }
@keyframes toast-in { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform: translateY(0); } }

/* ---------- Scrollbar custom ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }
