/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #f3f4f6;
    --accent-color: #10b981;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-chat: #f3f4f6;
    --border-color: #e5e7eb;
    --border-light: #f3f4f6;
    --hover-color: #f3f4f6;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 50px;
}

[data-theme="dark"] {
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-light: #9ca3af;
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-chat: #374151;
    --border-color: #374151;
    --border-light: #4b5563;
    --hover-color: #4b5563;
}

/* Light theme explicit (for better switching) */
body.light-theme {
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-chat: #f3f4f6;
    --border-color: #e5e7eb;
    --border-light: #f3f4f6;
    --hover-color: #f3f4f6;
}

/* Dark theme specific message bubble - using CSS variables for consistency */
[data-theme="dark"] .message.received .message-bubble {
    background: #1e1b4b !important;
    color: #c7d2fe !important;
    border: 1px solid #4338ca !important;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3) !important;
}

/* Dark theme modal support */
[data-theme="dark"] .modal {
    background: rgba(17, 24, 39, 0.8) !important;
}

[data-theme="dark"] .modal-content {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .modal-header h3 {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .modal-body {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .modal-body h4 {
    color: var(--warning-color) !important;
}

[data-theme="dark"] .modal-body p {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .modal-body strong {
    color: var(--text-primary) !important;
}

/* Dark theme main content areas */
[data-theme="dark"] .main-content {
    background: var(--bg-primary) !important;
}

[data-theme="dark"] .empty-state {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .empty-state h3 {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .empty-state p {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .search-container {
    background: var(--bg-primary) !important;
}

[data-theme="dark"] .chat-list {
    background: var(--bg-primary) !important;
}

/* Force dark background for all main areas */
[data-theme="dark"] #app {
    background: var(--bg-primary) !important;
}

[data-theme="dark"] .view.active {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] #chatListView {
    background: var(--bg-primary) !important;
}

/* Ensure body background is also dark */
body[data-theme="dark"] {
    background: var(--bg-primary) !important;
}

/* Ensure html background is also dark */
html[data-theme="dark"] {
    background: var(--bg-primary) !important;
}

/* Force dark theme on all containers */
[data-theme="dark"] * {
    scrollbar-color: var(--border-color) var(--bg-secondary);
}

[data-theme="dark"] *::-webkit-scrollbar {
    width: 8px;
}

[data-theme="dark"] *::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

[data-theme="dark"] *::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

[data-theme="dark"] *::-webkit-scrollbar-thumb:hover {
    background: var(--hover-color);
}

/* Dark theme profile view fixes */
[data-theme="dark"] .profile-content {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .profile-tag-display {
    background: var(--bg-secondary) !important;
    border-color: var(--primary-color) !important;
}

[data-theme="dark"] .profile-tag-display label {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .user-tag-large {
    background: rgba(99, 102, 241, 0.2) !important;
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

[data-theme="dark"] .tag-info {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .contact-input input {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .contact-input label {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .view {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.auth-view-active {
    overflow: hidden;
}

html, body, #app {
    height: 100%;
    min-height: 0;
    background: var(--bg-primary);
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 100vw; /* Akadályozza meg a vízszintes túlnyúlást */
    overflow-x: hidden; /* Elrejti a vízszintes scrollbart */
    word-wrap: break-word; /* Globális word wrap */
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* Header Styles */
.header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: fixed; /* Fixed position */
    top: 0;
    left: 0;
    right: 0;
    z-index: 200; /* Magasabb z-index */
    backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    max-width: 100%;
}

.app-title-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: logoGlow 3s ease-in-out infinite alternate;
}

.app-logo svg {
    height: 2.1rem; /* Kicsit nagyobb mint a CSETTING szöveg (1.75rem) */
    width: 2.1rem;  /* Tartsa meg a kör alakot */
    filter: drop-shadow(0 2px 8px rgba(99, 102, 241, 0.3));
}

.app-title {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary-color);
    letter-spacing: -0.02em;
    text-shadow: 0 1px 2px rgba(99, 102, 241, 0.1);
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

@keyframes logoGlow {
    0% {
        filter: drop-shadow(0 2px 8px rgba(99, 102, 241, 0.3));
    }
    100% {
        filter: drop-shadow(0 2px 12px rgba(139, 92, 246, 0.5));
    }
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Button Styles */
.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-icon:active {
    transform: scale(0.95);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.btn-secondary:hover {
    background: var(--border-color);
}

/* Main Content */
.main-content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    max-width: 100%;
    overflow-x: hidden;
    padding-top: 73px; /* Hely a fixed header-nek */
    background: var(--bg-primary);
}

/* View Management */
.view {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.view.active {
    display: flex;
}

/* Search Container */
.search-container {
    padding: 1rem 1.5rem;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    padding: 0.75rem 1rem;
}

.search-box svg {
    color: var(--text-light);
    margin-right: 0.75rem;
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-light);
}

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 1rem;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.chat-item:hover {
    background: var(--bg-secondary);
}

.chat-item:active {
    background: var(--border-color);
}

.chat-avatar {
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-full);
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    margin-right: 1rem;
    flex-shrink: 0;
    overflow: hidden;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-avatar svg {
    opacity: 0.9;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-name-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online {
    background: var(--success-color);
}

.status-dot.offline {
    background: #ef4444;
}

.chat-info h4 {
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-preview {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    word-break: break-all; /* Agresszívebb tördelés a preview-ban */
}

.chat-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.chat-time {
    color: var(--text-light);
    font-size: 0.75rem;
}

.chat-badge {
    background: var(--primary-color);
    color: white;
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-full);
    min-width: 1.25rem;
    text-align: center;
}

/* Empty State */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.empty-icon {
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

.empty-state h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    max-width: 20rem;
}

/* Chat View */
.chat-header {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
    gap: 0.75rem;
    position: fixed; /* Fixed position */
    top: 73px; /* A header magassága alatt */
    left: 0;
    right: 0;
    z-index: 150; /* Header alatt, de messages felett */
}

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

/* 🟢 Online Indicator */
.online-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: #10b981;
    border: 2px solid var(--bg-primary);
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
}

.online-indicator.offline {
    background: #9ca3af;
    box-shadow: none;
}

.chat-avatar-header {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
    overflow: hidden;
}

.chat-avatar-header img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-avatar-header svg {
    opacity: 0.9;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-info h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-subtitle {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status {
    display: inline-block;
    font-size: 0.8rem;
    color: var(--success-color);
    margin-top: 2px;
    font-weight: 500;
}

.status.offline {
    color: #ef4444;
}

.chat-actions {
    display: flex;
    gap: 0.5rem;
}

/* ===== EREDETI CHAT CSS (KOMMENTBEN HÁTRAHAGYVA) =====
Eredeti selectorok: .messages-container, .messages, .message, .message.sent, .message.received, .message-bubble, .message.sent .message-bubble, .message.received .message-bubble, .message-text, .message-time, .local-indicator, .message.sent .message-time, .message.received .message-time, [data-theme="dark"] .message.received .message-time, .message-input-container, .message-input-wrapper, .message-input-box, .message-input-box textarea, .message-input-box textarea::placeholder, .send-btn
Eredeti stílusok kikommentelve, lásd előző verzióban!
*/

/* ===== ÚJ MODERN CHAT ABLAK STÍLUSOK ===== */

.messages-container {
    /* Rocket.Chat pattern: Stable container with fixed dimensions */
    position: fixed;
    top: 73px;    /* header height */
    bottom: 80px; /* input panel height */
    left: 0;
    right: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg-secondary);
    /* Performance optimizations */
    will-change: scroll-position;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: auto;
    overscroll-behavior: contain;
    /* ✅ ROCKET.CHAT: Automatikus scroll az aljára */
    display: flex;
    flex-direction: column;
    /* Layer promotion for GPU acceleration */
    transform: translateZ(0);
}



.messages {
    /* Rocket.Chat display-from-bottom pattern */
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* Natural bottom alignment */
    gap: 1rem;
    padding: 1rem 1rem 6rem 1rem; /* Increased to 6rem for extra input clearance */
    position: relative;
    /* Performance optimizations */
    will-change: scroll-position;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    /* Ensure smooth scrolling behavior */
    scroll-behavior: auto; /* Disable smooth for performance */
}

/* Scroll sentinel for bottom detection */
#scroll-sentinel {
    flex-shrink: 0;
}

/* Message Groups */
.message-group {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    margin-bottom: 1rem; /* ✅ MESSENGER: Nagyobb távolság csoportok között */
    max-width: 80%; /* ✅ MESSENGER: Max szélesség, de dinamikus */
}

.message-group.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
    margin-left: auto; /* ✅ Teljesen jobbra */
}

.message-group.received {
    align-self: flex-start;
    margin-right: auto; /* ✅ Teljesen balra */
}

/* Message Avatar */
.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    overflow: hidden;
    margin-top: auto;
}

/* ✅ MESSENGER STYLE: Saját üzeneteknél NINCS avatar */
.message-group.sent .message-avatar {
    display: none;
    margin-bottom: 20px;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-avatar svg {
    width: 16px;
    height: 16px;
    opacity: 0.9;
}

/* Messages in Group */
.messages-in-group {
    display: flex;
    flex-direction: column;
    gap: 0.1rem; /* ✅ MESSENGER: Még kisebb gap az egymás utáni üzenetek között */
    flex: 1;
    min-width: 0;
}

.sender-name {
    display: none; /* Hide sender names above message bubbles */
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    padding-left: 0.75rem;
}

.message {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* ✅ JAVÍTVA: A class a message-group-ra kerül, nem a message-re */
.message-group.sent .message {
    align-items: flex-end;
    justify-content: flex-end; /* ✅ Saját üzenetek jobbra */
}

.message-group.received .message {
    align-items: flex-start;
    justify-content: flex-start; /* ✅ Partner üzenetek balra */
}

/* Legacy support (ha valahol mégis a message-re kerül) */
.message.sent {
    align-items: flex-end;
    justify-content: flex-end;
}

.message.received {
    align-items: flex-start;
    justify-content: flex-start;
}

.message-bubble {
    padding: 0.5rem 0.85rem; /* ✅ MESSENGER: Kompaktabb padding */
    border-radius: 18px; /* ✅ MESSENGER: Nagyobb kerekítés */
    font-size: 0.95rem;
    position: relative;
    word-break: break-word;
    max-width: 100%; /* ✅ MESSENGER: Teljes szélesség a csoporton belül */
    min-width: 60px; /* ✅ Kisebb minimum (rövid üzenetekhez) */
    line-height: 1.45; /* ✅ MESSENGER: Kicsit nagyobb sorköz */
    width: fit-content; /* ✅ MESSENGER: Dinamikus szélesség */
}

/* ✅ SAJÁT ÜZENETEK - Jobbra, kék háttér, SIMA HASÁB */
.message.sent .message-bubble {
    background: #6366f1;
    color: #fff;
}

/* ✅ PARTNER ÜZENETEK - Balra, fehér/szürke háttér, SIMA HASÁB */
.message.received .message-bubble {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.message-text {
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-link {
    color: #60a5fa;
    text-decoration: underline;
    transition: color 0.2s;
}

.message.sent .message-link {
    color: #93c5fd;
}

.message-link:hover {
    color: #3b82f6;
}

.message.sent .message-link:hover {
    color: #dbeafe;
}

/* Link Preview */
.link-preview {
    margin-top: 0.5rem;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(255,255,255,0.1);
}

.message.received .link-preview {
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.link-preview:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-1px);
}

.message.received .link-preview:hover {
    background: var(--hover-color);
}

.link-preview-content {
    display: flex;
    overflow: hidden;
}

.link-preview-image {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    overflow: hidden;
}

.link-preview-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.link-preview-text {
    flex: 1;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.link-preview-title {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    color: rgba(255,255,255,0.9);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message.received .link-preview-title {
    color: var(--text-primary);
}

.link-preview-description {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.7);
    margin-bottom: 0.25rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
}

.message.received .link-preview-description {
    color: var(--text-secondary);
}

.link-preview-url {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.6);
    font-weight: 500;
    text-transform: lowercase;
}

.message.received .link-preview-url {
    color: var(--text-light);
}

.message-time {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.6); /* ✅ MESSENGER: Még halvány */
    margin-top: 0.25rem;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
    white-space: nowrap; /* ✅ Időpont nem törik új sorba */
    flex-shrink: 0; /* ✅ Nem zsugorodik */
    opacity: 0; /* ✅ MESSENGER: Alapból rejtett */
    transition: opacity 0.2s ease;
}

/* ✅ MESSENGER: Csak az utolsó üzenetnél látszik az időpont */
.message-group .message:last-child .message-time {
    opacity: 1;
}

.message.received .message-time {
    color: var(--text-secondary);
    text-align: left;
    justify-content: flex-start;
}

.message-status {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    opacity: 0.8;
}

.local-indicator {
    margin-left: 0.25rem;
}

/* Typing Indicator */
.typing-indicator {
    margin-bottom: 1rem;
}

.typing-bubble {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border-color) !important;
    padding: 0.75rem 1rem !important;
    min-width: 60px !important;
}

.typing-dots {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    justify-content: center;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typingDot 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Message Reactions */
.reaction-picker {
    position: absolute;
    top: -50px;
    right: 0;
    z-index: 1000;
    animation: fadeInUp 0.2s ease;
}

.message.sent .reaction-picker {
    right: 0;
}

.message.received .reaction-picker {
    left: 0;
}

.reaction-picker-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 25px;
    padding: 0.5rem;
    display: flex;
    gap: 0.25rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.reaction-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.reaction-btn:hover {
    background: var(--hover-color);
    transform: scale(1.2);
}

.message-reactions {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.25rem;
    flex-wrap: wrap;
}

.reaction-count {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-secondary);
}

.reaction-count:hover {
    background: var(--hover-color);
    transform: translateY(-1px);
}

.reaction-count.own-reaction {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Message Action Menu */
.message-action-menu {
    position: absolute;
    top: -8px;
    right: -8px;
    z-index: 1001;
    animation: fadeInUp 0.2s ease;
}

.message.sent .message-action-menu {
    right: -8px;
}

.message.received .message-action-menu {
    left: -8px;
}

.action-menu-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 120px;
}

.action-btn {
    border: none;
    background: transparent;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-primary);
    transition: all 0.2s;
    white-space: nowrap;
}

.action-btn:hover {
    background: var(--hover-color);
}

.action-btn.delete-btn:hover {
    background: #fee;
    color: #dc2626;
}

.action-icon {
    font-size: 1rem;
}

.action-text {
    font-weight: 500;
}

/* Reply Preview */
.reply-preview {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0;
    padding: 0.75rem 1rem;
    margin: 0 0 -1px 0;
    animation: slideDown 0.3s ease;
}

.reply-preview-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.reply-icon {
    font-size: 1.1rem;
    color: var(--primary-color);
    flex-shrink: 0;
}

.reply-info {
    flex: 1;
    min-width: 0;
}

.reply-sender {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.1rem;
}

.reply-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reply-cancel {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    font-size: 1.2rem;
    line-height: 1;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.reply-cancel:hover {
    background: var(--hover-color);
    color: var(--text-primary);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Message Search Modal */
.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.search-modal-content {
    background: var(--bg-primary);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideInUp 0.3s ease;
}

.search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.search-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.close-search {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.close-search:hover {
    background: var(--hover-color);
    color: var(--text-primary);
}

.search-input-container {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

#messageSearchInput {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
}

#messageSearchInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-results-count {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.search-results {
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
}

.search-placeholder,
.search-loading,
.search-no-results,
.search-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
}

.search-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.search-placeholder p,
.search-loading p,
.search-no-results p,
.search-error p {
    margin: 0;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.search-result-item {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
}

.search-result-item:hover {
    background: var(--hover-color);
}

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

.search-result-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.search-result-text {
    font-size: 0.95rem;
    line-height: 1.4;
    color: var(--text-primary);
    word-break: break-word;
}

.search-result-text mark {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-color);
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
    font-weight: 600;
}

.search-result-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.search-result-sender {
    font-weight: 600;
}

.search-actions {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--hover-color);
}

/* Highlighted Message */
.highlighted-message {
    animation: highlightPulse 3s ease-in-out;
}

@keyframes highlightPulse {
    0% { background: rgba(99, 102, 241, 0.3); }
    50% { background: rgba(99, 102, 241, 0.15); }
    100% { background: transparent; }
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-input-container {
    /* Rocket.Chat pattern: Stable input panel */
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 80px; /* Fixed height for accurate container calculations */
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    /* GPU acceleration */
    will-change: transform;
    transform: translateZ(0);
}

.message-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 2rem;
    padding: 0.5rem 1rem;
}

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

.message-input-box textarea {
    width: 100%;
    min-height: 2.2rem;
    max-height: 6rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
    padding: 0.5rem 2.5rem 0.5rem 0;
}

.message-input-box textarea::placeholder {
    color: var(--text-light);
}

.emoji-btn {
    position: absolute;
    right: 0.25rem;
    bottom: 0.25rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.375rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    width: 32px;
    height: 32px;
}

.emoji-btn:hover {
    background: var(--hover-color);
    color: var(--text-primary);
    transform: scale(1.1);
}

/* Emoji Picker */
.emoji-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 0.5rem;
    z-index: 1000;
    animation: slideInUp 0.3s ease;
}

.emoji-picker-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    overflow: hidden;
    max-width: 320px;
    margin: 0 auto;
}

.emoji-categories {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem;
    gap: 0.25rem;
    overflow-x: auto;
}

.emoji-category-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.2s;
    opacity: 0.6;
    flex-shrink: 0;
}

.emoji-category-btn:hover,
.emoji-category-btn.active {
    background: var(--hover-color);
    opacity: 1;
    transform: scale(1.1);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.25rem;
    padding: 0.75rem;
    max-height: 200px;
    overflow-y: auto;
}

.emoji-item {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.2s;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-item:hover {
    background: var(--hover-color);
    transform: scale(1.2);
}

.emoji-picker-footer {
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.emoji-picker-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    display: block;
}

.send-btn {
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 2.75rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: relative;
}

.send-btn:hover {
    background: #4f46e5;
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

/* ✅ Felfelé nyíl SVG */
.send-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
}

/* New Chat View */
.new-chat-header {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    gap: 1rem;
}

.new-chat-header h3 {
    font-weight: 600;
    color: var(--text-primary);
}

.new-chat-content {
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.contact-input {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.contact-input label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.contact-input input {
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

.contact-input input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.contact-input input::placeholder {
    color: var(--text-light);
}

.phone-input-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    transition: all 0.2s ease;
}

.phone-input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.country-indicator {
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-right: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-top-left-radius: var(--radius-md);
    border-bottom-left-radius: var(--radius-md);
    white-space: nowrap;
    font-weight: 500;
}

.phone-input-wrapper input {
    border: none !important;
    border-radius: 0 !important;
    border-top-right-radius: var(--radius-md) !important;
    border-bottom-right-radius: var(--radius-md) !important;
    flex: 1;
    box-shadow: none !important;
}

.required {
    color: var(--primary-color);
    font-weight: 600;
}

.input-hint {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Authentication */
#authView {
    position: fixed;
    top: 73px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    overflow: hidden;
    z-index: 100;
}

#authView.active {
    display: flex !important;
}

.auth-container {
    max-width: 400px;
    padding: 1rem;
    height: auto;
    max-height: calc(100vh - 150px);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    width: 100%;
    margin: 0 auto;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-header {
    text-align: center;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.auth-header h1 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin: 0;
}

.auth-tabs {
    display: flex;
    margin-bottom: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 0.2rem;
    flex-shrink: 0;
}

.auth-tab {
    flex: 1;
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.auth-tab.active {
    background: var(--primary-color);
    color: white;
}

.auth-form {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.auth-form.active {
    display: flex;
    flex-direction: column;
}

.auth-form .contact-input {
    margin-bottom: 0.7rem;
}

.auth-info {
    margin-top: 0.8rem;
    padding: 0.6rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
    flex-shrink: 0;
}

.auth-info p {
    margin: 0.15rem 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Remember Me Checkbox Styles */
.remember-me-container {
    margin: 12px 0;
}

.checkbox-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 12px;
    margin-bottom: 8px;
}

.checkbox-container input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    opacity: 0;
    position: absolute;
}

.checkmark {
    width: 20px;
    height: 20px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.checkbox-container:hover .checkmark {
    border-color: var(--primary-color);
}

.checkbox-container input[type="checkbox"]:checked + .checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-container input[type="checkbox"]:checked + .checkmark::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 12px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-text {
    color: var(--text-color);
    font-size: 15px;
    font-weight: 500;
    user-select: none;
}

.remember-info {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0;
    padding-left: 32px;
    line-height: 1.4;
}

/* Nickname with Tag Preview */
.nickname-preview {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.6rem;
    gap: 0;
}

.nickname-preview #tagPreview {
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    margin-right: 0.5rem;
    min-width: 60px;
    text-align: center;
}

.nickname-preview input {
    border: none !important;
    background: transparent !important;
    flex: 1;
    font-size: 1rem;
    outline: none;
}

.nickname-preview input:focus {
    box-shadow: none !important;
}

/* Profile Button */
.profile-btn {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.profile-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    transform: scale(1.05);
}

.profile-btn:active {
    transform: scale(0.95);
}

.profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Profile View */
.profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.profile-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.profile-content {
    padding: 24px 20px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.profile-avatar-section {
    text-align: center;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.profile-avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin: 0 auto 16px;
    overflow: hidden;
}

.profile-avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-tag-display {
    margin-bottom: 24px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 2px solid var(--primary-color);
}

.profile-tag-display label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tag-display-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.user-tag-large {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    padding: 8px 16px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 8px;
    border: 2px solid var(--primary-color);
}

.copy-btn {
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    padding: 12px;
    height: 48px;
    min-width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: #2563eb;
    transform: scale(1.05);
}

.copy-btn.copied {
    background: #10b981;
}

.tag-info {
    color: var(--text-secondary);
    font-size: 12px;
    text-align: center;
    font-style: italic;
}

.profile-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.btn-danger {
    background: #ef4444;
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    text-decoration: none;
    display: inline-block;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.btn-danger:active {
    transform: translateY(0);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-weight: 600;
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
}

.setting-item label {
    font-weight: 500;
    color: var(--text-primary);
}

.setting-item input[type="checkbox"] {
    width: 2.5rem;
    height: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    appearance: none;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.setting-item input[type="checkbox"]:checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.setting-item input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 1.125rem;
    height: 1.125rem;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.setting-item input[type="checkbox"]:checked::after {
    transform: translateX(1rem);
}

/* New Chat Actions */
.new-chat-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.new-chat-actions .btn-secondary {
    background: var(--surface-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.new-chat-actions .btn-secondary:hover {
    background: var(--hover-color);
}

/* QR Scanner Styles */
.qr-scanner-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: calc(100vh - 80px);
    overflow-y: auto;
}

.scanner-info {
    text-align: center;
}

.scanner-info h4 {
    margin: 0 0 8px 0;
    color: var(--text-color);
    font-size: 18px;
}

.scanner-info p {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}

.camera-container {
    position: relative;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface-color);
    border: 2px solid var(--border-color);
}

.camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scanner-frame {
    width: 200px;
    height: 200px;
    border: 3px solid var(--primary-color);
    border-radius: 12px;
    position: relative;
    animation: scanner-pulse 2s ease-in-out infinite;
}

.scanner-frame::before,
.scanner-frame::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid var(--primary-color);
}

.scanner-frame::before {
    top: -3px;
    left: -3px;
    border-right: none;
    border-bottom: none;
}

.scanner-frame::after {
    bottom: -3px;
    right: -3px;
    border-left: none;
    border-top: none;
}

@keyframes scanner-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.scanner-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.scanner-fallback {
    background: var(--surface-color);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.scanner-fallback h4 {
    margin: 0 0 8px 0;
    color: var(--text-color);
    font-size: 16px;
}

.scanner-fallback p {
    margin: 0 0 16px 0;
    color: var(--text-muted);
    font-size: 14px;
}

.scanner-fallback .contact-input {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.scanner-fallback input {
    flex: 1;
    text-transform: uppercase;
}

.scanner-fallback button {
    flex-shrink: 0;
    height: 44px;
}

/* QR Share Styles */
.qr-share-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    max-width: 400px;
    margin: 0 auto;
}

.qr-info {
    text-align: center;
}

.qr-info h4 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.qr-info p {
    color: var(--text-secondary);
    line-height: 1.5;
}

.qr-code-container {
    background: white;
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 2px solid var(--primary-color);
}

.qr-code {
    width: 280px;
    height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.qr-user-info {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 300px;
}

.qr-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.qr-user-details h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.qr-user-details p {
    font-size: 14px;
    color: var(--primary-color);
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.qr-actions {
    text-align: center;
    width: 100%;
}

.qr-actions button {
    width: 100%;
    max-width: 280px;
    margin-bottom: 12px;
}

.qr-hint {
    font-size: 14px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Install Prompt */
.install-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    padding: 1rem 1.5rem;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 200;
}

.install-prompt.show {
    transform: translateY(0);
}

.install-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.install-icon {
    color: var(--primary-color);
    flex-shrink: 0;
}

.install-text {
    flex: 1;
}

.install-text h4 {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.install-text p {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.install-actions {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

.install-actions .btn-primary,
.install-actions .btn-secondary {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

/* Responsive Design */
@media (min-width: 768px) {
    .header-content {
        padding: 1rem 2rem;
    }
    
    .search-container {
        padding: 1rem 2rem;
    }
    
    .chat-item {
        padding: 1rem 2rem;
    }
    
    .chat-header {
        padding: 1rem 2rem;
    }
    
    .message-input-container {
        padding: 1rem 2rem;
    }
    
    .new-chat-content {
        padding: 2rem;
    }
    
    .modal-content {
        max-width: 500px;
    }
}

@media (min-width: 1024px) {
    #app {
        max-width: 800px;
        margin: 0 auto;
        box-shadow: var(--shadow-lg);
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* Loading Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== LOCATION SHARING STYLES ===== */

.location-sharing-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.location-status-bar {
    display: flex;
    padding: 1rem;
    gap: 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.user-location-status {
    flex: 1;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar.small {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-details {
    flex: 1;
}

.user-details span {
    font-weight: 600;
    color: var(--text-primary);
    display: block;
}

.location-status {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    display: inline-block;
}

.location-status.online {
    background: #dcfce7;
    color: #166534;
}

.location-status.offline {
    background: #fef2f2;
    color: #991b1b;
}

.location-map {
    flex: 1;
    min-height: 300px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
}

.location-actions {
    display: flex;
    padding: 1rem;
    gap: 0.75rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.location-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.location-btn:hover {
    background: var(--bg-hover);
    transform: translateY(-1px);
}

.location-btn .btn-icon {
    font-size: 1.5rem;
}

.location-btn .btn-text {
    font-weight: 600;
    color: var(--text-primary);
}

.location-info {
    padding: 1rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

.info-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.info-card:last-child {
    margin-bottom: 0;
}

.info-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.info-content {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.4;
}

/* Location Request Modal */
.location-request-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.location-request-content {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    margin: 1rem;
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.location-request-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.location-request-content h4 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.location-request-content p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.5;
}

.location-request-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.location-request-actions button {
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* Dark Mode Location Styles */
[data-theme="dark"] .location-status.online {
    background: #14532d;
    color: #bbf7d0;
}

[data-theme="dark"] .location-status.offline {
    background: #7f1d1d;
    color: #fecaca;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Chat üzenetek mobilra optimalizálva */
    .message {
        max-width: 85%; /* Kicsit több hely mobilon */
    }
    
    .message-bubble {
        padding: 0.5rem 0.75rem; /* ✅ Több padding mobilon (Messenger style) */
        font-size: 0.9rem; /* ✅ Nem túl kicsi font */
    }
    
    .messages {
        padding: 0.5rem 0.75rem; /* Még kisebb oldalsó padding */
        padding-bottom: 0.5rem; /* Kompakt bottom padding */
        gap: 0.15rem; /* Még kisebb gap mobilon */
    }
    
    .message-input-container {
        padding: 0.5rem 0.75rem; /* Kisebb input padding mobilon */
    }
    
    /* ✅ MOBILON: Időpont ne lógjon ki */
    .message-time {
        font-size: 0.65rem; /* Kicsit kisebb */
        margin-top: 0.2rem;
        padding: 0 0.25rem; /* ✅ Kis padding hogy ne lógjon ki */
        flex-wrap: nowrap; /* ✅ Soha ne törjön */
    }
    
    .chat-info h4 {
        font-size: 1rem; /* Kisebb névméret */
    }
    
    .chat-preview {
        font-size: 0.8rem; /* Kisebb preview szöveg */
    }
    
    /* Location specifikus mobilok */
    .location-status-bar {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .location-actions {
        flex-wrap: wrap;
    }
    
    .location-btn {
        min-width: calc(50% - 0.375rem);
    }
    
    .location-request-content {
        margin: 0.5rem;
        padding: 1.5rem;
    }
    
    .location-request-actions {
        flex-direction: column;
    }
    
    /* Auth container mobilon */
    #authView {
        padding: 0.5rem;
    }
    
    .auth-container {
        padding: 0.8rem;
        max-height: calc(100vh - 80px);
    }
    
    .auth-header {
        margin-bottom: 0.8rem;
    }
    
    .auth-header h1 {
        font-size: 1.1rem;
    }
    
    .auth-tabs {
        margin-bottom: 0.8rem;
    }
    
    .auth-form .contact-input {
        margin-bottom: 0.6rem;
    }
    
    .auth-info {
        margin-top: 0.6rem;
        padding: 0.5rem;
    }
    
    .remember-me-container {
        margin: 10px 0;
    }
    
    .checkbox-text {
        font-size: 14px;
    }
    
    .remember-info {
        font-size: 12px;
    }
}

/* Load More Messages Indicator (Rocket.Chat pattern) */
.load-more-messages {
    position: relative;
    text-align: center;
    margin: 2rem 0;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.load-more-messages:hover {
    background: var(--bg-secondary);
    border-radius: 8px;
}

.load-more-messages::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
    z-index: 1;
}

.load-more-messages-content {
    background: var(--bg-primary);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    display: inline-block;
    position: relative;
    z-index: 2;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.load-more-messages-content:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.load-more-messages.loading .load-more-messages-content {
    pointer-events: none;
    opacity: 0.7;
}

.load-more-messages-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--text-secondary);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.5rem;
}

.load-more-messages-count {
    color: var(--primary-color);
    font-weight: 600;
}

/* Separator line styling */
.message-separator {
    position: relative;
    text-align: center;
    margin: 1.5rem 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-separator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-color);
}

.message-separator span {
    background: var(--bg-primary);
    padding: 0 1rem;
    position: relative;
    z-index: 1;
}

/* =======================================
   INDEPENDENT CHAT CONTAINER ARCHITECTURE
   ======================================= */

/* Main Chat Container (Completely Isolated) */
.chat-container {
    position: fixed;
    top: 73px;     /* Header height */
    bottom: 80px;  /* Input panel height */
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    overflow: hidden; /* No scrolling on main container */
    z-index: 1;
}

/* Load More Messages Header (Sticky at top) */
.chat-load-more-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 0;
    min-height: 0;
    transition: all 0.3s ease;
    /* Hidden by default */
    max-height: 0;
    overflow: hidden;
    opacity: 0;
}

.chat-load-more-header.visible {
    max-height: 60px;
    opacity: 1;
    padding: 12px 16px;
}

.load-more-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

.load-more-trigger:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.load-more-trigger:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.load-more-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Messages Scroll Area (Independent) */
.chat-messages-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    /* Optimized scrolling performance */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    will-change: scroll-position;
    /* GPU acceleration */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Messages Content */
.chat-messages-content {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 16px;
    padding-bottom: 20px; /* Extra space at bottom */
}

/* Message Separator (Between old and new) */
.message-separator {
    position: relative;
    text-align: center;
    margin: 20px 0;
    padding: 0 20px;
}

.message-separator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        to right, 
        transparent, 
        var(--border-color) 20%, 
        var(--border-color) 80%, 
        transparent
    );
    z-index: 1;
}

.message-separator-text {
    background: var(--bg-secondary);
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    display: inline-block;
    position: relative;
    z-index: 2;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Scroll Observer Sentinel (for detecting scroll position) */
.scroll-sentinel-top {
    position: absolute;
    top: 0;  
    left: 0;
    width: 100%;
    height: 50px;
    pointer-events: none;
    visibility: hidden;
}

.scroll-sentinel-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50px;
    pointer-events: none;
    visibility: hidden;
}

/* Update existing messages container to use new architecture */
.messages-container {
    /* Remove old fixed positioning */
    position: relative;
    height: auto;
    overflow: visible;
    background: transparent;
    /* Use new architecture */
}

.messages {
    /* ✅ JAVÍTVA: Flex layout kell a jobbra/balra igazításhoz! */
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1rem 1rem 6rem 1rem;
    position: relative;
    /* Remove transforms */
    -webkit-transform: none;
    transform: none;
}

/* Legacy Load More Messages (hide old implementation) */
.load-more-messages {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-container {
        top: 60px; /* Smaller header on mobile */
        bottom: 70px; /* Smaller input on mobile */
    }
    
    .chat-messages-content {
        padding: 12px;
        padding-bottom: 16px;
    }
    
    .load-more-trigger {
        font-size: 13px;
        padding: 6px 12px;
    }
    
    .message-separator {
        margin: 16px 0;
        padding: 0 16px;
    }
} 