/* =======================================================================
   RK CHAT - GLOBAL UI THEME
   Complete CSS for auth, chat layout, sidebar, messages, modals, toasts
   All classes/IDs used in HTML + JS are covered here.
   ======================================================================= */

/* -----------------------------------------------------------------------
   1. ROOT VARIABLES (LIGHT THEME) + DARK THEME OVERRIDES
   ----------------------------------------------------------------------- */
:root {
    /* primary palette (blue) */
    --hue-primary: 220;
    --primary-50: hsl(var(--hue-primary), 100%, 97%);
    --primary-100: hsl(var(--hue-primary), 95%, 92%);
    --primary-500: hsl(var(--hue-primary), 80%, 55%);
    --primary-600: hsl(var(--hue-primary), 80%, 48%);

    --primary-alpha-10: hsla(var(--hue-primary), 80%, 55%, 0.10);
    --primary-alpha-20: hsla(var(--hue-primary), 80%, 55%, 0.20);
    --primary-alpha-40: hsla(var(--hue-primary), 80%, 55%, 0.40);

    /* neutrals */
    --gray-0: #ffffff;
    --gray-25: #f9fafb;
    --gray-50: #f3f4f6;
    --gray-100: #e5e7eb;
    --gray-200: #d1d5db;
    --gray-700: #374151;
    --gray-800: #111827;
    --gray-900: #020617;

    /* legacy compat variables (old chat.css/auth.css) */
    --primary: var(--primary-500);
    --secondary: #22c55e;
    --light: var(--gray-50);
    --dark: var(--gray-900);
    --gray-light: var(--gray-100);
    --gray: #9ca3af;

    /* semantic base (light theme) */
    --bg-body: var(--gray-25);
    --bg-sidebar: #ffffff;
    --bg-chat: #f1f5f9;
    --bg-panel: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: #e5e7eb;

    --text-main: #0f172a;
    --text-muted: #6b7280;
    --border-light: #e5e7eb;

    --msg-own-bg: var(--primary-500);
    --msg-own-text: #ffffff;
    --msg-other-bg: #ffffff;
    --msg-other-text: #0f172a;

    --shadow-sm: 0 1px 3px rgba(15,23,42,0.10);
    --shadow-md: 0 10px 25px rgba(15,23,42,0.18);
    --shadow-lg: 0 24px 48px rgba(15,23,42,0.30);

    --radius-xs: 8px;
    --radius-sm: 10px;
    --radius: 16px;
    --radius-xl: 24px;

    --sidebar-width: 330px;
    --header-height: 70px;
}

/* Dark theme (body has .dark-theme) */
.dark-theme {
    --bg-body: #020617;
    --bg-sidebar: #020617;
    --bg-chat: #020617;
    --bg-panel: rgba(15,23,42,0.98);
    --bg-input: #020617;
    --bg-hover: rgba(148,163,184,0.18);

    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --border-light: rgba(148,163,184,0.35);

    --msg-own-bg: var(--primary-500);
    --msg-own-text: #ffffff;
    --msg-other-bg: rgba(15,23,42,0.9);
    --msg-other-text: #e5e7eb;

    --shadow-sm: 0 1px 3px rgba(15,23,42,0.25);
    --shadow-md: 0 10px 25px rgba(15,23,42,0.55);
    --shadow-lg: 0 22px 45px rgba(15,23,42,0.85);
}

/* -----------------------------------------------------------------------
   2. GLOBAL RESET & BASE
   ----------------------------------------------------------------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    outline: none;
}

html, body {
    width: 100%;
    height: 100%;
}

body {
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background:
        radial-gradient(circle at top left, rgba(37,99,235,0.20), transparent 55%),
        radial-gradient(circle at bottom right, rgba(79,70,229,0.25), transparent 60%),
        var(--bg-body);
    color: var(--text-main);
    overflow: hidden;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

input, textarea {
    font-family: inherit;
    border: none;
    background: transparent;
    color: inherit;
}

img { max-width: 100%; display: block; }
textarea { resize: none; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(148,163,184,0.70);
    border-radius: 999px;
}

/* Simple fade animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* -----------------------------------------------------------------------
   3. AUTH PAGE (LOGIN / REGISTER)
   ----------------------------------------------------------------------- */
.auth-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100vh;
}

.auth-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    padding: 40px 38px;
    border-radius: var(--radius-xl);
    background: radial-gradient(circle at top, var(--bg-panel), rgba(15,23,42,0.96));
    border: 1px solid rgba(148,163,184,0.35);
    box-shadow: var(--shadow-lg);
    color: var(--text-main);
    animation: fadeIn 0.5s ease-out;
}

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.brand-logo {
    width: 72px;
    height: 72px;
    border-radius: 22px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    color: #f9fafb;
    background: linear-gradient(135deg, #2563eb, #6366f1);
    box-shadow: 0 18px 40px rgba(37,99,235,0.65);
}

.auth-header h1 {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 4px;
}

.auth-header p {
    font-size: 13px;
    color: var(--text-muted);
}

.auth-tabs {
    display: flex;
    background: rgba(15,23,42,0.04);
    padding: 5px;
    border-radius: 14px;
    border: 1px solid rgba(148,163,184,0.35);
    margin-bottom: 26px;
}

.tab-btn {
    flex: 1;
    padding: 10px 0;
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    transition: 0.25s;
}

.tab-btn.active {
    background: radial-gradient(circle at top left, rgba(37,99,235,0.9), rgba(79,70,229,0.95));
    color: #f9fafb;
    box-shadow: 0 10px 30px rgba(37,99,235,0.7);
}

.auth-form { display: none; }
.auth-form.active { display: block; animation: fadeIn 0.3s ease-out; }

.input-group {
    position: relative;
    margin-bottom: 18px;
}

.input-group > i {
    position: absolute;
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    color: rgba(148,163,184,0.8);
    font-size: 17px;
}

.input-group input {
    width: 100%;
    padding: 14px 42px 14px 42px;
    border-radius: 12px;
    border: 1px solid rgba(148,163,184,0.45);
    background: rgba(15,23,42,0.02);
    font-size: 14px;
    color: var(--text-main);
}

.input-group input::placeholder { color: rgba(148,163,184,0.75); }

.input-group input:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 1px rgba(37,99,235,0.55);
}

.toggle-pass {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(148,163,184,0.85);
    font-size: 17px;
}

.toggle-pass:hover { color: var(--text-main); }

.submit-btn {
    width: 100%;
    padding: 13px 0;
    border-radius: 999px;
    border: none;
    background: linear-gradient(90deg, #2563eb, #6366f1);
    color: #f9fafb;
    font-weight: 700;
    font-size: 15px;
    margin-top: 14px;
    box-shadow: 0 15px 40px rgba(37,99,235,0.65);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 20px 55px rgba(37,99,235,0.8);
}

.form-footer {
    margin-top: 20px;
    font-size: 12px;
    text-align: center;
    color: rgba(148,163,184,0.9);
}

.form-footer a {
    color: #2563eb;
    font-weight: 600;
    text-decoration: none;
}

.form-footer a:hover { text-decoration: underline; }

/* -----------------------------------------------------------------------
   3.1 LOADING SCREEN (index.html #loadingScreen)
   ----------------------------------------------------------------------- */
.loading-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, rgba(37,99,235,0.5), transparent 55%),
                radial-gradient(circle at bottom right, rgba(79,70,229,0.55), transparent 55%),
                #020617;
    color: #e5e7eb;
    z-index: 5000;
}

.loading-icon {
    width: 82px;
    height: 82px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    box-shadow: 0 22px 45px rgba(15,23,42,0.9);
    margin-bottom: 18px;
}

.loading-title {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 4px;
}

.loading-status {
    font-size: 14px;
    color: rgba(209,213,219,0.9);
    margin-bottom: 10px;
}

.typing-dots {
    display: flex;
    gap: 6px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: rgba(226,232,240,0.95);
    animation: loadingDot 1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes loadingDot {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
    40% { transform: translateY(-4px); opacity: 1; }
}

/* -----------------------------------------------------------------------
   4. APP LAYOUT & SIDEBAR
   ----------------------------------------------------------------------- */
.app-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: radial-gradient(circle at top left, rgba(15,23,42,0.03), rgba(15,23,42,0.04));
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(148,163,184,0.25);
    display: flex;
    flex-direction: column;
    z-index: 40;
}

.dark-theme .sidebar {
    background: radial-gradient(circle at top left, rgba(15,23,42,0.9), rgba(15,23,42,0.98));
    border-right: 1px solid rgba(30,64,175,0.55);
}

.sidebar-header {
    padding: 18px 18px 14px;
    border-bottom: 1px solid rgba(148,163,184,0.3);
    position: relative;
}

.profile-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 16px;
    background: var(--bg-panel);
    border: 1px solid rgba(148,163,184,0.40);
    box-shadow: var(--shadow-sm);
}

.profile-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid rgba(30,64,175,0.8);
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.profile-name {
    font-size: 14px;
    font-weight: 700;
}

.profile-email {
    font-size: 11px;
    color: var(--text-muted);
}

.mobile-back-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    margin-right: 6px;
}

.mobile-back-btn i {
    font-size: 16px;
}

.settings-btn {
    margin-left: auto;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: transparent;
}

.settings-btn:hover {
    background: var(--bg-hover);
    color: var(--primary-500);
}

/* profile dropdown (three dots) */
.dropdown-menu {
    position: absolute;
    top: 78px;
    left: 18px;
    right: 18px;
    border-radius: 14px;
    background: var(--bg-panel);
    border: 1px solid rgba(148,163,184,0.6);
    box-shadow: var(--shadow-md);
    padding: 4px 0;
    display: none;
    z-index: 200;
}

.dropdown-menu.show { display: block; }

.dropdown-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dropdown-header {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 6px 14px;
    border-bottom: 1px solid rgba(148,163,184,0.5);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text-main);
}

.dropdown-item i { font-size: 13px; opacity: 0.85; }

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--primary-500);
}

.sidebar .auth-tabs {
    margin: 14px 18px 6px;
    background: var(--bg-panel);
    border: 1px solid rgba(148,163,184,0.4);
}

.sidebar .tab-btn {
    padding: 8px 0;
    font-size: 12px;
}

.sidebar-content {
    flex: 1;
    padding: 12px 10px 10px;
    overflow-y: auto;
}

.nav-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(148,163,184,0.9);
    margin: 10px 10px 6px;
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-read-receipt {
    margin-top: 3px;
    font-size: 11px;
    opacity: 0.7;
    text-align: right;
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    border-radius: 12px;
    color: var(--text-main);
    background: transparent;
    transition: background 0.15s ease, transform 0.1s ease;
}

.nav-item:hover {
    background: var(--bg-hover);
    transform: translateY(-1px);
}

.nav-item.active {
    background: var(--primary-alpha-10);
    color: var(--primary-600);
    box-shadow: 0 8px 24px rgba(15,23,42,0.15);
}

.nav-item-main {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.nav-unread-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #2563eb;
    color: #f9fafb;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
}

.nav-item.active .nav-unread-badge {
    background: #0f172a;
    color: #bfdbfe;
}

.sidebar-footer {
    padding: 14px 16px 18px;
    border-top: 1px solid rgba(148,163,184,0.35);
    display: flex;
    gap: 10px;
    align-items: center;
}

.footer-btn {
    flex: 1;
    height: 44px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    color: #f9fafb;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.btn-primary-action {
    background: linear-gradient(90deg, #2563eb, #4f46e5);
    box-shadow: 0 14px 32px rgba(37,99,235,0.75);
}

.btn-primary-action:hover { transform: translateY(-1px); }

.btn-secondary-action {
    background: var(--bg-panel);
    color: var(--text-muted);
    border: 1px solid rgba(148,163,184,0.5);
}

.btn-secondary-action:hover {
    border-color: var(--primary-500);
    color: var(--text-main);
}

.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid rgba(148,163,184,0.4);
    background: var(--bg-panel);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--primary-500);
    transform: translateY(-1px);
}

/* -----------------------------------------------------------------------
   5. CHAT AREA
   ----------------------------------------------------------------------- */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(circle at top left, rgba(30,64,175,0.16), transparent 60%),
        radial-gradient(circle at bottom right, rgba(79,70,229,0.18), transparent 60%),
        var(--bg-chat);
    position: relative;
}

.dark-theme .chat-area::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(15,23,42,0.7) 1px, transparent 1px);
    background-size: 26px 26px;
    opacity: 0.9;
    pointer-events: none;
}

.chat-header {
    position: relative;
    z-index: 10;
    height: var(--header-height);
    padding: 0 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(to right, rgba(255,255,255,0.92), rgba(248,250,252,0.96));
    border-bottom: 1px solid rgba(148,163,184,0.35);
    box-shadow: 0 10px 24px rgba(15,23,42,0.06);
}

.dark-theme .chat-header {
    background: linear-gradient(to right, rgba(15,23,42,0.98), rgba(15,23,42,0.95));
    border-bottom: 1px solid rgba(30,64,175,0.55);
    box-shadow: 0 12px 26px rgba(15,23,42,0.85);
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
}

.chat-title-text {
    display: flex;
    flex-direction: column;
}

.chat-status-text {
    font-size: 11px;
    color: var(--text-muted);
}

.chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.messages-wrapper {
    position: relative;
    z-index: 1;
    flex: 1;
    padding: 20px 5%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    animation: fadeIn 0.4s ease-out;
}

.empty-state i {
    width: 92px;
    height: 92px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    margin-bottom: 14px;
    color: var(--primary-500);
    background: radial-gradient(circle at top, rgba(37,99,235,0.18), rgba(37,99,235,0.06));
}

.empty-state p {
    font-size: 14px;
    max-width: 280px;
}

/* message bubbles */
.message {
    max-width: 72%;
    border-radius: 18px;
    padding: 10px 12px;
    margin-bottom: 4px;
    position: relative;
    display: flex;
    animation: fadeIn 0.25s ease-out;
}

.message.own {
    align-self: flex-end;
    background: var(--msg-own-bg);
    color: var(--msg-own-text);
    box-shadow: 0 10px 24px rgba(15,23,42,0.16);
}

.message.other {
    align-self: flex-start;
    background: var(--msg-other-bg);
    color: var(--msg-other-text);
    box-shadow: 0 10px 24px rgba(15,23,42,0.16);
}

.audio-message.message {
    padding: 0;
    background: transparent;
    box-shadow: none;
}

.audio-message.message.own {
    background: transparent;
    box-shadow: none;
}

.audio-message.message.other {
    background: transparent;
    box-shadow: none;
}

.message-content {
    width: fit-content;
    max-width: 100%;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 12px;
}

.message-avatar-inline {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    overflow: hidden;
    flex-shrink: 0;
}

.message-avatar-inline img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.message-header span:first-child {
    font-weight: 600;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-time {
    font-size: 11px;
    opacity: 0.75;
    margin-left: auto;
}

.message-text {
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
}

.message-media {
    margin-top: 5px;
}

.message-media img,
.message-media video {
    max-width: 260px;
    max-height: 260px;
    border-radius: 16px;
    display: block;
    object-fit: cover;
}

/* voice message bubble */
.message-media.voice-bubble {
    border-radius: 999px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 240px;
    max-width: 100%;
    box-shadow: 0 10px 26px rgba(15,23,42,0.20);
}

.message.own .message-media.voice-bubble {
    background: var(--msg-own-bg);
    color: var(--msg-own-text);
}

.message.other .message-media.voice-bubble {
    background: var(--msg-other-bg);
    color: var(--msg-other-text);
}

.message-media.voice-bubble audio {
    display: none;
}

/* reply inside bubble */
.message-reply-preview {
    margin-bottom: 4px;
    padding: 6px 8px;
    border-radius: 10px;
    border: 1px solid rgba(148,163,184,0.55);
    background: rgba(15,23,42,0.04);
    font-size: 12px;
}

.dark-theme .message-reply-preview {
    background: rgba(15,23,42,0.9);
}

.message-reply-preview-name {
    font-weight: 600;
    margin-bottom: 1px;
    color: var(--primary-600);
}

.message-reply-preview-text { color: var(--text-muted); }

/* custom voice player */
.voice-player {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.voice-play-btn {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(15,23,42,0.15);
    color: inherit;
    cursor: pointer;
}

.voice-play-btn i {
    font-size: 12px;
}

.voice-progress-bar {
    flex: 1;
    height: 4px;
    border-radius: 999px;
    background: rgba(15,23,42,0.22);
    overflow: hidden;
    cursor: pointer;
}

.voice-progress-fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: rgba(59,130,246,0.85);
}

.voice-time {
    font-size: 11px;
    opacity: 0.8;
    min-width: 38px;
    text-align: right;
}

/* links inside messages */
.message-text .msg-link {
    color: #60a5fa;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.message-text .msg-link:hover {
    color: #93c5fd;
}

.message-link-preview.youtube-preview {
    margin-top: 6px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(148,163,184,0.5);
    background: rgba(15,23,42,0.85);
    box-shadow: 0 16px 36px rgba(15,23,42,0.70);
}

.message-link-preview.youtube-preview iframe {
    display: block;
    width: 260px;
    height: 146px;
    max-width: 100%;
    border: none;
}

/* header edit/delete icons */
.message-actions {
    margin-left: auto;
    display: flex;
    gap: 4px;
}

.msg-btn {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    opacity: 0.65;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.msg-btn:hover {
    background: var(--bg-hover);
    color: var(--primary-500);
    opacity: 1;
}

/* message right-click context menu */
.message-context-menu {
    position: fixed;
    z-index: 3000;
    background: var(--bg-panel);
    border-radius: 12px;
    border: 1px solid rgba(148,163,184,0.6);
    padding: 4px 0;
    min-width: 170px;
    box-shadow: var(--shadow-md);
}

.message-context-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text-main);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.message-context-item i { font-size: 12px; opacity: 0.8; }

.message-context-item:hover {
    background: var(--bg-hover);
    color: var(--primary-500);
}

.message-context-item.danger:hover { color: #ef4444; }

/* -----------------------------------------------------------------------
   6. CHAT INPUT AREA
   ----------------------------------------------------------------------- */
.chat-input-container {
    position: relative;
    z-index: 10;
    padding: 12px 22px 18px;
    background: linear-gradient(to top, var(--bg-panel), rgba(248,250,252,0.96));
    border-top: 1px solid rgba(148,163,184,0.35);
    box-shadow: 0 -10px 24px rgba(15,23,42,0.10);
}

.dark-theme .chat-input-container {
    background: linear-gradient(to top, rgba(15,23,42,0.98), rgba(15,23,42,0.96));
    border-top: 1px solid rgba(30,64,175,0.6);
    box-shadow: 0 -12px 26px rgba(15,23,42,0.9);
}

.typing-indicator {
    display: none; /* varsayilan gizli, kimse yazmiyorken gozukmesin */
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.typing-indicator.active {
    display: flex;
}

.typing-indicator i { font-size: 10px; }

.input-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 12px;
    border-radius: 999px;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    box-shadow: 0 10px 24px rgba(15,23,42,0.15);
}

.emoji-picker {
    position: absolute;
    right: 26px;
    bottom: 70px;
    display: grid;
    grid-template-columns: repeat(8, 1.8rem);
    gap: 4px;
    padding: 8px;
    border-radius: 14px;
    background: var(--bg-panel-elevated);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-lg);
    z-index: 40;
}

.emoji-picker button {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 999px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
}

.emoji-picker button:hover {
    background: var(--bg-hover);
}

#messageInput {
    flex: 1;
    min-height: 20px;
    max-height: 120px;
    padding: 6px 4px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-main);
}

#messageInput::placeholder { color: var(--text-muted); }

.action-btn {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
}

.action-btn:hover {
    background: var(--bg-hover);
    color: var(--primary-500);
}

.send-btn {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: #f9fafb;
    box-shadow: 0 12px 32px rgba(37,99,235,0.8);
    font-size: 15px;
}

.send-btn:hover { transform: translateY(-1px); }

/* reply preview above input */
#replyPreview { margin-bottom: 6px; }

.reply-preview-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border-radius: 14px;
    border: 1px solid rgba(148,163,184,0.6);
    padding: 6px 10px;
}

.reply-preview-strip {
    width: 3px;
    align-self: stretch;
    border-radius: 999px;
    background: var(--primary-500);
}

.reply-preview-main { flex: 1; min-width: 0; }

.reply-preview-meta {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary-500);
    margin-bottom: 2px;
}

.reply-preview-text {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-preview-close {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--text-muted);
}

.reply-preview-close:hover {
    background: var(--bg-hover);
    color: var(--primary-500);
}

/* -----------------------------------------------------------------------
   7. FRIEND LIST ACTIONS & GROUP SELECT LISTS
   ----------------------------------------------------------------------- */
.friend-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.friend-item:hover .friend-actions { opacity: 1; }

.action-btn-del:hover i { color: #f97373 !important; }
.action-btn-del:hover { background: rgba(248,113,113,0.12); }

.action-btn-block:hover i { color: #f87171 !important; }
.action-btn-block:hover { background: rgba(248,113,113,0.18); }

/* group create / search lists */
.select-friends-list {
    margin-top: 8px;
    max-height: 260px;
    overflow-y: auto;
    padding-right: 4px;
}

.select-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    transition: 0.15s ease-in-out;
    border: 1px solid transparent;
}

.select-item:hover { background: var(--bg-hover); }

.select-item img {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(148,163,184,0.45);
}

.dark-theme .select-item img {
    box-shadow: 0 0 0 1px rgba(15,23,42,0.9);
}

.select-item span {
    flex: 1;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.select-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 999px;
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: transparent;
    background: transparent;
}

.select-checkbox i { font-size: 11px; }

.select-item.selected {
    background: rgba(59,130,246,0.08);
    border-color: rgba(59,130,246,0.65);
}

.select-item.selected .select-checkbox {
    background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.35);
}

.user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
}

.user-item:hover { background: var(--bg-hover); }

/* -----------------------------------------------------------------------
   8. TOAST NOTIFICATIONS (helpers.js, #toastContainer)
   ----------------------------------------------------------------------- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 6000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(22,163,74,0.1);
    border: 1px solid rgba(22,163,74,0.5);
    color: #16a34a;
    font-size: 13px;
    backdrop-filter: blur(12px);
    animation: fadeIn 0.25s ease-out;
}

.toast i { font-size: 14px; }

.toast.error {
    background: rgba(248,113,113,0.07);
    border-color: rgba(248,113,113,0.7);
    color: #f97373;
}

/* -----------------------------------------------------------------------
   9. MEDIA LIGHTBOX
   ----------------------------------------------------------------------- */
.media-lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
}

.media-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    background: #020617;
}

.media-lightbox-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.media-lightbox-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: rgba(15,23,42,0.85);
    color: #e5e7eb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.media-lightbox-close:hover { background: rgba(15,23,42,1); }

/* -----------------------------------------------------------------------
   10. MODALS (ALL MODAL OVERLAYS)
   ----------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4500;
}

.modal-card {
    width: 100%;
    max-width: 420px;
    border-radius: 18px;
    background: radial-gradient(circle at top, var(--bg-panel), rgba(15,23,42,0.98));
    border: 1px solid rgba(30,64,175,0.7);
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.25s ease-out;
}

.modal-header {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(30,64,175,0.6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.modal-header h3 {
    font-size: 15px;
    font-weight: 700;
}

.close-modal {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.close-modal:hover { background: rgba(15,23,42,0.12); }

.modal-body {
    padding: 14px 18px 10px;
    font-size: 13px;
    color: var(--text-main);
}

.modal-footer {
    padding: 10px 18px 14px;
    border-top: 1px solid rgba(30,64,175,0.6);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.btn-cancel,
.btn-confirm {
    min-width: 86px;
    height: 34px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
}

.btn-cancel {
    background: rgba(15,23,42,0.02);
    color: var(--text-muted);
    border: 1px solid rgba(148,163,184,0.55);
}

.btn-cancel:hover { border-color: rgba(248,250,252,0.85); }

.btn-confirm {
    background: linear-gradient(90deg, #2563eb, #4f46e5);
    color: #f9fafb;
}

.btn-confirm:hover { box-shadow: 0 10px 28px rgba(37,99,235,0.7); }

/* header flash (new message highlight) */
.chat-header.flash {
    animation: headerFlash 0.6s ease-out;
}

@keyframes headerFlash {
    0% {
        box-shadow: 0 0 0 0 rgba(59,130,246,0.5);
        background-color: rgba(30,64,175,0.18);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(59,130,246,0);
        background-color: transparent;
    }
}

/* -----------------------------------------------------------------------
   11. RESPONSIVE
   ----------------------------------------------------------------------- */
@media (max-width: 900px) {
    .sidebar { width: 82px; }

    .sidebar-header .profile-info,
    .nav-title,
    .nav-item span,
    .profile-name,
    .profile-email,
    .tab-btn {
        display: none;
    }

    .nav-unread-badge {
        display: inline-flex;
    }

    .sidebar .auth-tabs {
        flex-direction: column;
    }

    .sidebar-footer {
        flex-direction: column;
        gap: 8px;
    }

    .chat-header { padding: 0 16px; }
    .messages-wrapper { padding: 18px 4%; }
}

@media (max-width: 640px) {
    /* Genel iskelet: tek kolon, yukari/asagi kaydirilabilir */
    .app-layout {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    body {
        overflow-y: auto;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid rgba(148,163,184,0.35);
    }

    /* Varsayilan: liste gorunur, sohbet gizli */
    .app-layout:not(.mobile-chat-open) .chat-area {
        display: none;
    }

    /* Sohbet acildiginda: sadece sohbet ekrani gorunur */
    .app-layout.mobile-chat-open .sidebar {
        display: none;
    }

    .app-layout.mobile-chat-open .chat-area {
        display: flex;
    }

    .sidebar-footer {
        padding: 10px 12px 12px;
    }

    .footer-btn {
        height: 40px;
        font-size: 12px;
    }

    .chat-header {
        height: 56px;
        padding-inline: 10px;
    }

    .chat-title {
        font-size: 14px;
    }

    .chat-actions .icon-btn {
        width: 30px;
        height: 30px;
        font-size: 13px;
    }

    .mobile-back-btn {
        display: inline-flex;
    }

    .messages-wrapper {
        padding: 10px 3% 8px;
    }

    .message {
        max-width: 94%;
        font-size: 13px;
    }

    .message-text {
        font-size: 13px;
    }

    .chat-input-container {
        padding: 8px 12px 10px;
    }
}

