/* VideoPago — estilo minimalista, paleta inspirada en YouTube */

:root {
  --yt-red: #FF0000;
  --yt-red-dark: #CC0000;
  --yt-ink: #0F0F0F;
  --yt-gray-900: #272727;
  --yt-gray-600: #606060;
  --yt-gray-300: #D9D9D9;
  --yt-gray-150: #EDEDED;
  --yt-gray-100: #F9F9F9;
  --yt-white: #FFFFFF;

  --ok: #1E8E3E;
  --warn: #B45309;
  --info: #1A73E8;
  --purple: #7C4DFF;

  --radius-sm: 8px;
  --radius-md: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 2px 10px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--yt-gray-100);
  color: var(--yt-ink);
  font-family: "Roboto", "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

/* Look & feel de app instalada: sin selección de texto accidental en la
   navegación, y una pequeña entrada suave del contenido al cambiar de página. */
.content { animation: content-in .18s ease-out; }
@keyframes content-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

a { color: inherit; text-decoration: none; }

.layout {
  display: flex;
  min-height: 100vh;
}

/* --- Barra lateral --- */
.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--yt-white);
  border-right: 1px solid var(--yt-gray-150);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 20px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.2px;
}

.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--yt-red);
  display: inline-block;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--yt-gray-900);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
}

.nav-link svg { flex-shrink: 0; opacity: .85; }
.nav-link.active svg { opacity: 1; }

.nav-link:hover { background: var(--yt-gray-100); }
.nav-link:active { transform: scale(.98); }

.nav-link.active {
  background: #FFF1F1;
  color: var(--yt-red-dark);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--yt-gray-150);
  font-size: 13px;
  color: var(--yt-gray-600);
}

.sidebar-footer .user-name {
  color: var(--yt-ink);
  font-weight: 600;
  display: block;
}

.logout-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--yt-red);
  font-weight: 600;
  font-size: 13px;
}

/* --- Contenido --- */
.content {
  flex: 1;
  padding: 28px 32px;
  max-width: 1180px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
}

.page-subtitle {
  color: var(--yt-gray-600);
  font-size: 14px;
  margin: 0 0 24px;
}

/* --- Tarjetas / stats --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--yt-white);
  border: 1px solid var(--yt-gray-150);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.stat-card .value {
  font-size: 24px;
  font-weight: 700;
}

.stat-card .label {
  font-size: 13px;
  color: var(--yt-gray-600);
  margin-top: 2px;
}

.card {
  background: var(--yt-white);
  border: 1px solid var(--yt-gray-150);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
}

.card h2, .card h3 {
  margin-top: 0;
}

/* --- Tablas --- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--yt-gray-150);
}

th {
  color: var(--yt-gray-600);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

tr:last-child td { border-bottom: none; }

.table-wrap { overflow-x: auto; }

/* --- Badges de estado --- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-gris   { background: #EEEEEE; color: #444; }
.badge-azul   { background: #E8F0FE; color: var(--info); }
.badge-ambar  { background: #FEF3E2; color: var(--warn); }
.badge-morado { background: #F0EBFF; color: var(--purple); }
.badge-verde  { background: #E6F4EA; color: var(--ok); }
.badge-rojo   { background: #FDE8E8; color: var(--yt-red-dark); }

/* --- Formularios --- */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--yt-gray-900);
}

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], input[type=url],
select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--yt-gray-300);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--yt-white);
  color: var(--yt-ink);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--yt-red);
  box-shadow: 0 0 0 3px rgba(255,0,0,.08);
}

.field { margin-bottom: 16px; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

/* --- Botones --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 999px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(.97); }

.btn-primary { background: var(--yt-red); color: #fff; }
.btn-primary:hover { background: var(--yt-red-dark); }

.btn-secondary { background: var(--yt-gray-150); color: var(--yt-ink); }
.btn-secondary:hover { background: var(--yt-gray-300); }

.btn-ghost { background: transparent; color: var(--yt-gray-600); padding: 6px 10px; }
.btn-ghost:hover { color: var(--yt-ink); }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* --- Alertas --- */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-success { background: #E6F4EA; color: var(--ok); }
.alert-error   { background: #FDE8E8; color: var(--yt-red-dark); }

/* --- Login / setup --- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--yt-white);
  border: 1px solid var(--yt-gray-150);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 32px 28px;
}

.auth-card .brand { justify-content: center; padding-bottom: 24px; font-size: 20px; }

.muted { color: var(--yt-gray-600); font-size: 13px; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--yt-gray-600);
}

/* --- Nav badge (mensajes sin leer) --- */
.nav-badge {
  display: inline-block;
  background: var(--yt-red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  margin-left: 4px;
}

/* --- Presencia (en línea / desconectado) --- */
.presence {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.dot-on, .dot-off {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-on { background: var(--ok); box-shadow: 0 0 0 3px rgba(30,142,62,.15); }
.dot-off { background: var(--yt-gray-300); }

.presence-on { color: var(--ok); }
.presence-off { color: var(--yt-gray-600); font-weight: 500; }

/* --- Calendario mensual --- */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-dow {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--yt-gray-600);
  text-transform: uppercase;
  padding-bottom: 6px;
}

.calendar-day {
  min-height: 96px;
  background: var(--yt-white);
  border: 1px solid var(--yt-gray-150);
  border-radius: var(--radius-sm);
  padding: 6px;
  font-size: 12px;
}

.calendar-day.outside { background: var(--yt-gray-100); color: var(--yt-gray-300); }
.calendar-day.today { border-color: var(--yt-red); border-width: 2px; }

.calendar-day .day-num { font-weight: 700; font-size: 13px; margin-bottom: 4px; }

.calendar-item {
  display: block;
  padding: 2px 5px;
  border-radius: 5px;
  margin-bottom: 3px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Chat --- */
.chat-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
  height: 70vh;
  min-height: 460px;
}

.chat-editor-list {
  background: var(--yt-white);
  border: 1px solid var(--yt-gray-150);
  border-radius: var(--radius-md);
  overflow-y: auto;
}

.chat-editor-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--yt-gray-150);
  font-size: 14px;
  font-weight: 600;
}

.chat-editor-item.active { background: #FFF1F1; }

.chat-panel {
  background: var(--yt-white);
  border: 1px solid var(--yt-gray-150);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-bubble {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
}

.chat-bubble .meta { font-size: 11px; opacity: .7; margin-top: 3px; }

.chat-bubble.mine {
  align-self: flex-end;
  background: var(--yt-red);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble.theirs {
  align-self: flex-start;
  background: var(--yt-gray-100);
  color: var(--yt-ink);
  border-bottom-left-radius: 4px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--yt-gray-150);
}

.chat-input-row textarea {
  flex: 1;
  resize: none;
  min-height: 42px;
}

.chat-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--yt-gray-600);
  text-align: center;
  padding: 30px;
}

/* --- Métricas de canal (YouTube) --- */
.yt-metrics {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.yt-metric {
  font-size: 13px;
  color: var(--yt-gray-600);
}

.yt-metric strong {
  color: var(--yt-ink);
  font-size: 15px;
  display: block;
}

.yt-error {
  font-size: 12px;
  color: var(--yt-red-dark);
}

/* ==========================================================================
   Navegación estilo app (barra superior + barra inferior tipo tab bar)
   Solo se muestran en pantallas angostas; en escritorio se usa el sidebar.
   ========================================================================== */

.mobile-topbar,
.bottom-nav,
.more-sheet-backdrop,
.more-sheet {
  display: none;
}

@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sidebar { display: none; }
  .content {
    padding: 16px 16px calc(84px + env(safe-area-inset-bottom, 0px));
  }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-editor-list { max-height: 200px; }
  .calendar-day { min-height: 60px; font-size: 11px; }
  .chat-panel { height: calc(100vh - 260px) !important; }

  /* --- Barra superior --- */
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--yt-white);
    padding: 12px 16px calc(12px + env(safe-area-inset-top, 0px));
    padding-top: 12px;
    border-bottom: 1px solid var(--yt-gray-150);
    box-shadow: var(--shadow-sm);
  }
  .mobile-topbar .brand { padding: 0; font-size: 16px; }
  .mobile-topbar-more {
    border: none;
    background: var(--yt-gray-100);
    color: var(--yt-gray-900);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .mobile-topbar-more:active { transform: scale(.92); }

  /* --- Barra inferior (tab bar) --- */
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: var(--yt-white);
    border-top: 1px solid var(--yt-gray-150);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 10px rgba(0,0,0,.06);
  }
  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px;
    border: none;
    background: none;
    color: var(--yt-gray-600);
    font-size: 10.5px;
    font-weight: 600;
    font-family: inherit;
    position: relative;
    border-radius: var(--radius-sm);
    transition: color .15s ease;
  }
  .bottom-nav-item svg { opacity: .8; }
  .bottom-nav-item.active { color: var(--yt-red-dark); }
  .bottom-nav-item.active svg { opacity: 1; }
  .bottom-nav-item:active { transform: scale(.94); }
  .nav-badge-bottom {
    position: absolute;
    top: 0;
    right: 18%;
    margin: 0;
    padding: 1px 5px;
  }

  /* --- Hoja "Más" (bottom sheet) --- */
  .more-sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15,15,15,.4);
    z-index: 49;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .more-sheet-backdrop.open { opacity: 1; pointer-events: auto; }

  .more-sheet {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    background: var(--yt-white);
    border-radius: 18px 18px 0 0;
    padding: 8px 12px calc(20px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 24px rgba(0,0,0,.18);
    transform: translateY(105%);
    transition: transform .25s ease;
    max-height: 70vh;
    overflow-y: auto;
  }
  .more-sheet.open { transform: translateY(0); }

  .more-sheet-handle {
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: var(--yt-gray-300);
    margin: 6px auto 14px;
  }

  .more-sheet-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 10px;
    border-radius: var(--radius-sm);
    color: var(--yt-gray-900);
    font-size: 15px;
    font-weight: 500;
  }
  .more-sheet-item:active { background: var(--yt-gray-100); }
  .more-sheet-item.active { color: var(--yt-red-dark); }
}

/* En pantallas anchas jamás se muestran los componentes móviles, aunque
   el usuario haya abierto la hoja "Más" antes de rotar/agrandar la ventana. */
@media (min-width: 721px) {
  .more-sheet, .more-sheet-backdrop, .bottom-nav, .mobile-topbar { display: none !important; }
}
