/* ==========================================
   Base Foundation - Shared Styles
   ========================================== */

:root {
  --primary-gradient: linear-gradient(135deg, #ff4500, #ff8717);
  --premium-gradient: linear-gradient(135deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  --reddit-blue: #0079d3;
  --base-font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  width: 100%;
  font-family: var(--base-font);
  color: #1f2937;
  overflow-x: hidden;
  position: relative;
}

/* Shared utility classes or basic tag resets */
a {
  text-decoration: none;
  color: inherit;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, textarea {
  font-family: inherit;
}
/* Botón de Regresar Estándar (Favorito del usuario) */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: white;
    border: 1px solid #f1f5f9;
    border-radius: 16px;
    color: #64748b; /* text-muted */
    font-weight: 700;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    text-decoration: none;
    cursor: pointer;
}

.back-btn:hover {
    background: #fff2ec; /* primary-light */
    color: #ff4500; /* primary */
    border-color: #ff4500;
    transform: translateX(-5px);
    box-shadow: 0 8px 20px rgba(255, 69, 0, 0.15);
}

.back-btn i {
    font-size: 1.1rem;
}

/* Premium Badge styling */
.premium-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #ff4500 0%, #ff8717 100%);
    color: white;
    border-radius: 50%;
    font-size: 0.65rem;
    vertical-align: middle;
    margin-left: 6px;
    box-shadow: 0 4px 10px rgba(255, 69, 0, 0.3);
    border: 1.5px solid white;
    flex-shrink: 0;
}

.premium-badge i {
    font-size: 0.65rem;
}

/* ── Streak Badge ── */
.streak-badge {
    background: linear-gradient(135deg, #ff8717, #ff4500);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 800;
    display: none; /* Hidden by default */
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(255, 69, 0, 0.3);
    border: 2px solid white;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.streak-badge:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(255, 69, 0, 0.4);
}

.streak-badge i {
    font-size: 0.9rem;
    color: #ffeb3b;
    filter: drop-shadow(0 0 2px rgba(255,255,255,0.5));
}

/* Mentions Autocomplete */
.mentions-suggestions {
  position: absolute;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  border: 1px solid #e2e8f0;
  z-index: 2000;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 5px;
}

.mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  cursor: pointer;
  transition: background 0.2s;
  border-bottom: 1px solid #f1f5f9;
}

.mention-item:last-child {
  border-bottom: none;
}

.mention-item:hover {
  background: #fff2ec;
}

.mention-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  background: #f1f5f9;
}

.mention-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #1e293b;
}

/* Mention Live Highlighter (Técnica de Superposición) */
.mention-highlighter-wrapper {
  position: relative;
  display: flex;
  width: 100%;
  flex: 1;
}

.mention-highlighter-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: inherit;
  margin: inherit;
  border: 1px solid transparent; /* Para que coincida con el borde del textarea si tuviera */
  font: inherit;
  line-height: inherit;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #1f2937; /* El color que verá el usuario */
  pointer-events: none;
  overflow: hidden;
  background: transparent;
}

.mention-highlighter-backdrop strong {
  font-weight: 800;
  color: #ef4444; /* Un toque de color para que se note que es especial */
  background-color: rgba(239, 68, 68, 0.05);
  border-radius: 3px;
  padding: 0 2px;
}

/* El textarea real se vuelve invisible pero funcional */
.mention-highlighter-textarea {
  background: transparent !important;
  color: transparent !important;
  caret-color: #1f2937 !important; /* El cursor sí se debe ver */
  position: relative;
  z-index: 1;
  width: 100% !important;
}

/* Highlighting Overlay System */
.highlight-wrapper {
  position: relative;
  width: 100%;
  height: auto;
  background: transparent;
}

.highlight-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: inherit;
  margin: inherit;
  border: 1px solid transparent;
  width: 100%;
  height: 100%;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: transparent; /* No mostramos el texto normal, solo el formateado */
  pointer-events: none;
  overflow: hidden;
  font: inherit;
  line-height: inherit;
  z-index: 1;
}

.highlight-backdrop strong {
  color: #ff4500; /* Naranja corporativo */
  font-weight: 800;
  font-style: normal;
  background: rgba(255, 69, 0, 0.1);
  border-radius: 4px;
  padding: 0 2px;
}

.highlight-textarea {
  position: relative;
  z-index: 2;
  background: transparent !important;
  color: #1e293b !important; /* El texto real se ve */
  caret-color: #1e293b;
}

/* Modificamos el parseMentions para el backdrop */
.highlight-backdrop em {
    font-style: normal;
    color: #1e293b;
}

/* Rich Mentions Input (ContentEditable) */
.rich-mention-input {
  width: 100%;
  min-height: 100px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  font-size: 16px;
  background: white;
  color: #1f2937;
  outline: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  transition: border-color 0.2s;
  overflow-y: auto;
}

.rich-mention-input:focus {
  border-color: #ff4500;
  box-shadow: 0 0 0 3px rgba(255, 69, 0, 0.1);
}

.rich-mention-input strong {
  color: #ff4500;
  font-weight: bold;
}

/* Para inputs de una sola línea */
.rich-mention-input.single-line {
  min-height: auto;
  white-space: nowrap;
  overflow-x: hidden;
}

[data-rich-original] {
  display: none !important;
}

/* Estilo global para menciones resaltadas en vistas y edición */
.mention-highlight {
  color: #ff4500 !important;
  font-weight: 800 !important;
}

/* ==========================================
   App Header — Componente Estándar
   ========================================== */
.app-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

.app-header .header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.app-header .header-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 12px;
    border-left: 1px solid rgba(226, 232, 240, 0.8);
}

.app-header .header-title-text {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-weight: 800;
    font-size: 1.2rem;
    background: linear-gradient(135deg, #ff4500, #ff8717);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

.app-header .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.app-header .header-auth-btn {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 3px 14px 3px 3px;
    border-radius: 100px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}
.app-header .header-auth-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.app-header .header-avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
}
.app-header .header-avatar-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.app-header .header-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #64748b;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}
.app-header .header-icon-btn:hover {
    background: #fff2ec;
    color: #ff4500;
    border-color: #ff4500;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255,69,0,0.15);
}

.app-header .header-icon-btn.primary {
    background: linear-gradient(135deg, #ff4500, #ff8717);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(255,69,0,0.3);
}
.app-header .header-icon-btn.primary:hover {
    box-shadow: 0 6px 20px rgba(255,69,0,0.4);
    transform: translateY(-2px) scale(1.05);
}

/* Responsive — Móvil */
@media (max-width: 600px) {
    .app-header {
        padding: 10px 14px;
        height: 60px;
    }
    .app-header .header-title-text {
        font-size: 1.05rem;
    }
    .app-header .header-right {
        gap: 6px;
    }
}

/* El back-btn dentro de app-header es circular, como en forums */
.app-header .back-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: #f1f5f9;
    border: none;
    box-shadow: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 1rem;
    transition: all 0.3s;
    text-decoration: none;
    font-weight: normal;
}
.app-header .back-btn:hover {
    background: #fff2ec;
    color: #ff4500;
    transform: translateX(-4px);
    box-shadow: none;
    border-color: transparent;
}

/* Login Invite Banner */
.login-invite-banner {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 20px;
  padding: 16px;
  z-index: 1000;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.login-invite-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.login-invite-text {
  color: #1e293b;
  flex: 1;
  margin-right: 12px;
}
.login-invite-text strong {
  display: block;
  font-size: 1.05rem;
  margin-bottom: 4px;
  color: #1e293b;
  font-family: 'Outfit', 'Inter', sans-serif;
}
.login-invite-text p {
  font-size: 0.85rem;
  margin: 0;
  color: #64748b;
  line-height: 1.3;
}
.login-invite-banner .auth-primary-btn {
  width: auto;
  padding: 8px 16px;
  font-size: 0.9rem;
  margin: 0;
  white-space: nowrap;
  background: linear-gradient(135deg, #ff4500, #ff8717);
  border-radius: 20px;
  color: white;
  font-weight: 700;
  border: none;
  box-shadow: 0 4px 12px rgba(255, 69, 0, 0.2);
}
.close-invite-btn {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 28px;
  height: 28px;
  background: white;
  color: #64748b;
  border-radius: 50%;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.2s;
}
.close-invite-btn:hover {
  background: #f1f5f9;
  color: #ef4444;
}
@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
