/* ==========================================================================
   Zsófi & b_ Chat Archívum - Modern Stíluslap & iPhone / Mobil Optimalizáció
   ========================================================================== */

:root {
  --bg-main: #0b0e14;
  --bg-surface: #151921;
  --bg-surface-elevated: #1e232d;
  --bg-surface-hover: #262c38;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-focus: rgba(138, 75, 255, 0.5);
  
  --text-primary: #f0f3f6;
  --text-secondary: #9da7b7;
  --text-muted: #626d7f;

  /* Buborék színek */
  --bubble-incoming-bg: #202632;
  --bubble-incoming-text: #f0f3f6;
  --bubble-outgoing-bg: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
  --bubble-outgoing-text: #ffffff;
  
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-danger: #ef4444;
  
  --zsofi-color: #ec4899;
  --me-color: #8b5cf6;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);

  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --header-height: 68px;
  --bottom-bar-height: 60px;
}

/* Világos téma */
body.light-theme {
  --bg-main: #f4f6fa;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f0f2f7;
  --bg-surface-hover: #e5e9f2;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-color-focus: rgba(138, 75, 255, 0.5);

  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;

  --bubble-incoming-bg: #e5e7eb;
  --bubble-incoming-text: #111827;
  --bubble-outgoing-bg: linear-gradient(135deg, #6366f1 0%, #4338ca 100%);
  --bubble-outgoing-text: #ffffff;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);
}

/* Alap reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: -webkit-fill-available;
  overflow: hidden;
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   BEJELENTKEZŐ PANEL (LOCK SCREEN)
   ========================================================================== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-main);
}

.login-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, rgba(139, 92, 246, 0.18), transparent 60%),
              radial-gradient(circle at 80% 80%, rgba(236, 72, 153, 0.15), transparent 50%);
  pointer-events: none;
}

.login-card {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.login-avatar-group {
  display: flex;
  align-items: center;
  margin-bottom: 18px;
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-input-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.login-icon {
  position: absolute;
  left: 14px;
  font-size: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.login-input-wrapper input {
  width: 100%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 42px 12px 40px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-input-wrapper input:focus {
  border-color: var(--border-color-focus);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.btn-toggle-pw {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  font-size: 15px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
}

.login-error {
  font-size: 12px;
  color: var(--accent-danger);
  font-weight: 500;
  margin-top: -6px;
}

.login-remember-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
}

.remember-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.remember-label input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--accent-purple);
}

.btn-login {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  margin-top: 6px;
  display: flex;
  justify-content: center;
  gap: 8px;
}

/* Shake animáció hibás jelszó esetén */
.shake {
  animation: shakeAnimation 0.4s ease;
}

@keyframes shakeAnimation {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* ==========================================================================
   Fő Alkalmazás Keret
   ========================================================================== */
.app-layout {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* Fejléc */
.app-header {
  height: var(--header-height);
  padding-top: max(10px, env(safe-area-inset-top));
  padding-bottom: 10px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 40;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  gap: 12px;
}

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

.chat-avatar-group {
  display: flex;
  align-items: center;
  position: relative;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  box-shadow: 0 0 0 2px var(--bg-surface);
  user-select: none;
}

.avatar-zsofi {
  background: linear-gradient(135deg, #ec4899, #f43f5e);
  z-index: 2;
}

.avatar-me {
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  margin-left: -12px;
  z-index: 1;
}

.chat-info {
  display: flex;
  flex-direction: column;
}

.chat-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.chat-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.meta-badge {
  background: var(--bg-surface-elevated);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.meta-dot {
  color: var(--text-muted);
}

.meta-dates {
  font-size: 11px;
  color: var(--text-muted);
}

/* Navigációs eszköztár */
.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.header-nav-mobile {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-divider {
  width: 1px;
  height: 24px;
  background-color: var(--border-color);
  margin: 0 4px;
}

.nav-control {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface-elevated);
  padding: 4px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.nav-icon {
  font-size: 14px;
}

.nav-select, .nav-date-input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

.nav-select option {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.nav-date-input::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
  cursor: pointer;
}

/* Gombok */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  user-select: none;
  touch-action: manipulation;
}

.btn-primary {
  background: var(--accent-purple);
  color: #ffffff;
}

.btn-primary:hover {
  background: #7c3aed;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-icon {
  padding: 7px 10px;
  min-width: 34px;
  min-height: 34px;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

/* ==========================================================================
   Fő tartalom és Csevegés
   ========================================================================== */
.main-content {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
  height: calc(100vh - var(--header-height));
  height: calc(100dvh - var(--header-height));
}

.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  height: 100%;
  overflow: hidden;
}

/* Lebegő dátum jelző */
.sticky-date-pill {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(21, 25, 33, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  z-index: 20;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}

/* Üzenet görgető konténer */
.chat-scroll-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 40px 16px 80px 16px;
  display: flex;
  flex-direction: column;
  scroll-behavior: auto;
  -webkit-overflow-scrolling: touch;
}

.chat-scroll-container::-webkit-scrollbar {
  width: 6px;
}

.chat-scroll-container::-webkit-scrollbar-track {
  background: transparent;
}

.chat-scroll-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
}

.loader-sentinel {
  text-align: center;
  padding: 12px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hidden {
  display: none !important;
}

/* Lebegő lefelé görgető FAB */
.fab-scroll-bottom {
  position: absolute;
  bottom: 24px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 25;
  transition: transform 0.2s ease, background 0.2s ease;
}

.fab-scroll-bottom:hover {
  background: var(--bg-surface-hover);
  transform: translateY(-2px);
}

/* ==========================================================================
   Üzenetek és Buborékok
   ========================================================================== */
.messages-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

.date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 22px 0 12px 0;
  position: relative;
  text-align: center;
}

.date-divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--border-color);
  z-index: 1;
}

.date-divider-text {
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  position: relative;
  z-index: 2;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.msg-row {
  display: flex;
  flex-direction: column;
  position: relative;
  margin-bottom: 2px;
}

.msg-row.msg-incoming {
  align-items: flex-start;
}

.msg-row.msg-outgoing {
  align-items: flex-end;
}

.msg-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 78%;
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ec4899, #f43f5e);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 4px;
  user-select: none;
}

.msg-bubble-container {
  display: flex;
  flex-direction: column;
  position: relative;
}

.msg-sender-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 2px;
  padding-left: 4px;
}

.msg-bubble {
  padding: 9px 14px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.msg-incoming .msg-bubble {
  background-color: var(--bubble-incoming-bg);
  color: var(--bubble-incoming-text);
  border-bottom-left-radius: 4px;
}

.msg-outgoing .msg-bubble {
  background: var(--bubble-outgoing-bg);
  color: var(--bubble-outgoing-text);
  border-bottom-right-radius: 4px;
}

.msg-text {
  white-space: pre-wrap;
}

.msg-text a {
  color: inherit;
  text-decoration: underline;
  word-break: break-all;
}

.msg-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  margin-left: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.msg-outgoing .msg-time {
  align-self: flex-end;
  margin-right: 2px;
}

.msg-highlight {
  animation: highlightPulse 2.2s cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes highlightPulse {
  0% {
    background-color: rgba(139, 92, 246, 0.45);
    border-radius: var(--radius-md);
  }
  70% {
    background-color: rgba(139, 92, 246, 0.2);
  }
  100% {
    background-color: transparent;
  }
}

.msg-reactions {
  display: flex;
  align-items: center;
  gap: 4px;
  position: absolute;
  bottom: -10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
  cursor: pointer;
  z-index: 5;
}

.msg-incoming .msg-reactions {
  left: 12px;
}

.msg-outgoing .msg-reactions {
  right: 12px;
}

/* ==========================================================================
   Média elemek a csevegésben
   ========================================================================== */
.msg-media-grid {
  display: grid;
  gap: 4px;
  margin-bottom: 4px;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.msg-media-grid.single {
  grid-template-columns: 1fr;
  max-width: 320px;
}

.msg-media-grid.double {
  grid-template-columns: 1fr 1fr;
  max-width: 380px;
}

.msg-media-grid.multi {
  grid-template-columns: repeat(3, 1fr);
  max-width: 420px;
}

.media-thumbnail-wrapper {
  position: relative;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1 / 1;
}

.msg-media-grid.single .media-thumbnail-wrapper {
  aspect-ratio: auto;
  max-height: 400px;
}

.media-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.msg-video-player {
  max-width: 340px;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  margin-top: 4px;
}

.msg-video-player video {
  width: 100%;
  max-height: 380px;
  display: block;
  outline: none;
}

.msg-audio-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 10px;
  border-radius: var(--radius-md);
  margin-top: 4px;
  max-width: 280px;
  width: 100%;
}

.msg-audio-card audio {
  width: 100%;
  height: 30px;
  outline: none;
}

.msg-share-card {
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-top: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.share-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-pink);
}

.share-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  max-height: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.share-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--accent-purple);
  text-decoration: none;
  font-weight: 600;
}

.call-ended-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  margin: 4px 0;
}

/* ==========================================================================
   Kereső Drawer (Oldalsáv)
   ========================================================================== */
.search-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 100%;
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  z-index: 35;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: 16px 18px 12px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-surface);
}

.drawer-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-title-row h2 {
  font-size: 16px;
  font-weight: 600;
}

.search-input-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-box input {
  width: 100%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 36px 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.btn-clear-search {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
}

.search-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-size: 11px;
  color: var(--text-muted);
  width: 58px;
  flex-shrink: 0;
}

.pill-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.pill {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill.active {
  background: var(--accent-purple);
  color: #fff;
  border-color: var(--accent-purple);
}

.date-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-filter-row > div {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.filter-date-input {
  width: 100%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 11px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  outline: none;
}

.search-results-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.search-results-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.search-result-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.res-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}

.res-sender {
  font-weight: 600;
}

.res-sender.sender-zsofi { color: var(--zsofi-color); }
.res-sender.sender-me { color: var(--me-color); }
.res-date { color: var(--text-muted); }

.res-body {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-word;
}

.res-body mark {
  background: rgba(234, 179, 8, 0.35);
  color: #fef08a;
  padding: 1px 3px;
  border-radius: 2px;
}

.res-media-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--accent-purple);
  margin-top: 2px;
}

/* ==========================================================================
   MOBIL ALSÓ TAB SÁV (IPHONE STYLE)
   ========================================================================== */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-bar-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(21, 25, 33, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 45;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.25);
}

.bottom-tab-item {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease;
  touch-action: manipulation;
}

.bottom-tab-item .tab-icon {
  font-size: 18px;
}

.bottom-tab-item .tab-label {
  font-size: 10px;
  font-weight: 500;
}

.bottom-tab-item.active {
  color: var(--accent-purple);
}

/* ==========================================================================
   MOBIL IDŐ NAVIGÁCIÓS BOTTOM SHEET
   ========================================================================== */
.mobile-bottom-sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.sheet-content {
  position: relative;
  z-index: 2;
  background: var(--bg-surface);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom)) 20px;
  box-shadow: var(--shadow-lg);
  border-top: 1px solid var(--border-color);
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border-color);
  border-radius: var(--radius-full);
  margin: 0 auto 12px auto;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sheet-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sheet-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sheet-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.sheet-select, .sheet-date-input {
  width: 100%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  outline: none;
}

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

.sheet-btn {
  flex: 1;
  padding: 12px 8px;
  font-size: 12px;
}

/* ==========================================================================
   Média Galéria Modális
   ========================================================================== */
.full-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 50;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.full-modal-inner {
  width: 100%;
  max-width: 1200px;
  height: 90vh;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.full-modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg-surface);
}

.gallery-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gallery-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.gallery-grid {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  -webkit-overflow-scrolling: touch;
}

.gallery-card {
  position: relative;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-card.audio-card {
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  text-align: center;
}

.gallery-card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 10px;
  color: #fff;
}

.gallery-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, transparent 60%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 10px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.gallery-card:hover .gallery-card-overlay {
  opacity: 1;
}

.gallery-card-date {
  font-size: 11px;
  color: #fff;
  font-weight: 500;
}

.gallery-jump-btn {
  margin-top: 6px;
  background: var(--accent-purple);
  color: #fff;
  border: none;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  cursor: pointer;
  width: 100%;
  font-weight: 500;
}

/* ==========================================================================
   Statisztikák Modális
   ========================================================================== */
.stats-modal-inner {
  max-width: 950px;
}

.stats-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  -webkit-overflow-scrolling: touch;
}

.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.kpi-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.kpi-icon { font-size: 22px; }
.kpi-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}
.kpi-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stats-section-box {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.stats-section-box h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.sender-comparison-bar {
  display: flex;
  height: 36px;
  border-radius: var(--radius-full);
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

.bar-portion {
  display: flex;
  align-items: center;
  padding: 0 14px;
}

.portion-zsofi {
  background: linear-gradient(90deg, #ec4899, #f43f5e);
  justify-content: flex-start;
}

.portion-me {
  background: linear-gradient(90deg, #8b5cf6, #6366f1);
  justify-content: flex-end;
}

.chart-container-bars {
  display: flex;
  align-items: flex-end;
  height: 160px;
  gap: 8px;
  padding-top: 24px;
  border-bottom: 1px solid var(--border-color);
}

.chart-bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}

.chart-bar-fill {
  width: 100%;
  max-width: 28px;
  background: linear-gradient(to top, var(--accent-purple), var(--accent-pink));
  border-radius: 4px 4px 0 0;
  transition: height 0.6s ease;
  position: relative;
  cursor: pointer;
}

.chart-bar-tooltip {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.chart-bar-label {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: center;
}

.stats-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.chart-container-weekday, .chart-container-hourly {
  display: flex;
  align-items: flex-end;
  height: 130px;
  gap: 6px;
  border-bottom: 1px solid var(--border-color);
}

/* ==========================================================================
   Lightbox
   ========================================================================== */
.lightbox-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(8px);
}

.lightbox-toolbar {
  position: relative;
  z-index: 102;
  height: 56px;
  padding: 0 16px;
  padding-top: max(8px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(10, 10, 12, 0.7);
}

.lightbox-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lightbox-content {
  position: relative;
  z-index: 101;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.lightbox-img-wrapper {
  max-width: 90%;
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.lightbox-img-wrapper img {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  user-select: none;
}

.lb-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 32px;
  line-height: 1;
  width: 48px;
  height: 58px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 105;
}

.lb-prev { left: 16px; }
.lb-next { right: 16px; }

/* ==========================================================================
   Reszponzivitás & iPhone Finomhangolás
   ========================================================================== */
.mobile-only {
  display: none !important;
}

@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }
  
  .mobile-only {
    display: flex !important;
  }

  .app-header {
    height: auto;
  }

  .main-content {
    /* Helyet hagyunk a mobil alsó sávnak */
    height: calc(100dvh - var(--header-height) - var(--bottom-bar-height) - env(safe-area-inset-bottom));
  }

  .chat-scroll-container {
    padding: 30px 12px calc(20px + var(--bottom-bar-height)) 12px;
  }

  .fab-scroll-bottom {
    bottom: calc(var(--bottom-bar-height) + env(safe-area-inset-bottom) + 16px);
    right: 16px;
  }

  .msg-wrapper {
    max-width: 88%;
  }

  .msg-media-grid.single {
    max-width: 260px;
  }

  .search-drawer {
    width: 100%;
  }

  .full-modal {
    padding: 0;
  }

  .full-modal-inner {
    height: 100dvh;
    border-radius: 0;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    padding: 12px;
  }

  .gallery-card-overlay {
    opacity: 1; /* Érintőképernyőn mindig látszódjon a felirat */
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, transparent 70%);
  }

  .stats-two-col {
    grid-template-columns: 1fr;
  }

  .lb-nav-btn {
    width: 40px;
    height: 50px;
    font-size: 26px;
  }

  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }

  /* iOS Safari automatikus zoom megelőzése (minimum 16px betűméret) */
  input, select, textarea {
    font-size: 16px !important;
  }
}
