/*
 * 🚀 Built by Selva Pandi Francis
 * 👑 Tech Empire Builder | 🧠 Knowledge Seeker
 */
:root {
            --bg-deep: #0a0e14;
            --bg-panel: #111720;
            --bg-sidebar: #0d1219;
            --bg-chat: #0e1621;
            --bg-bubble-in: #1a2535;
            --bg-bubble-out: #005c4b;
            --accent: #00c87a;
            --accent-dim: #00a563;
            --accent-glow: rgba(0, 200, 122, 0.18);
            --text-primary: #e8edf3;
            --text-secondary: #8a9ab8;
            --text-meta: #566782;
            --border: rgba(255, 255, 255, 0.06);
            --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
            --radius-bubble: 18px;
        }

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

        html,
        body {
            height: 100%;
            overflow: hidden;
        }

        body {
            font-family: 'Outfit', sans-serif;
            background: var(--bg-deep);
            color: var(--text-primary);
            display: flex;
            flex-direction: column;
            height: 100vh;
        }

        /* ── DROP OVERLAY ─────────────────────────── */
        #dropOverlay {
            position: fixed;
            inset: 0;
            background: rgba(10, 14, 20, 0.96);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            z-index: 100;
            transition: opacity 0.4s;
        }

        #dropOverlay.hidden {
            opacity: 0;
            pointer-events: none;
        }

        .drop-zone {
            width: min(420px, 90vw);
            border: 2px dashed rgba(0, 200, 122, 0.4);
            border-radius: 24px;
            padding: 52px 36px;
            text-align: center;
            cursor: pointer;
            transition: all 0.3s;
            background: rgba(0, 200, 122, 0.03);
            position: relative;
        }

        .drop-zone.drag-over {
            border-color: var(--accent);
            background: var(--accent-glow);
            transform: scale(1.02);
        }

        .drop-icon {
            font-size: 56px;
            margin-bottom: 16px;
            display: block;
            animation: float 3s ease-in-out infinite;
        }

        @keyframes float {

            0%,
            100% {
                transform: translateY(0);
            }

            50% {
                transform: translateY(-8px);
            }
        }

        .drop-title {
            font-size: 22px;
            font-weight: 700;
            color: var(--text-primary);
            margin-bottom: 8px;
        }

        .drop-sub {
            font-size: 14px;
            color: var(--text-secondary);
            line-height: 1.6;
        }

        .drop-btn {
            margin-top: 24px;
            background: var(--accent);
            color: #000;
            border: none;
            border-radius: 12px;
            padding: 12px 28px;
            font-family: 'Outfit', sans-serif;
            font-size: 15px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
        }

        .drop-btn:hover {
            background: #00e98a;
            transform: translateY(-2px);
        }

        #fileInput {
            display: none;
        }

        .drop-hint {
            margin-top: 28px;
            font-size: 12px;
            color: var(--text-meta);
            background: rgba(255, 255, 255, 0.03);
            border: 1px solid var(--border);
            border-radius: 10px;
            padding: 10px 16px;
            text-align: left;
            line-height: 1.8;
        }

        .drop-hint b {
            color: var(--accent);
        }

        /* ── APP LAYOUT ───────────────────────────── */
        #app {
            display: flex;
            flex-direction: column;
            height: 100vh;
        }

        /* ── TOP BAR ──────────────────────────────── */
        #topBar {
            display: flex;
            align-items: center;
            gap: 14px;
            padding: 14px 20px;
            background: var(--bg-panel);
            border-bottom: 1px solid var(--border);
            flex-shrink: 0;
            box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
        }

        .chat-avatar {
            width: 42px;
            height: 42px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--accent) 0%, #007a55 100%);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            font-weight: 700;
            color: #000;
            flex-shrink: 0;
        }

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

        .chat-name {
            font-size: 16px;
            font-weight: 600;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .chat-meta {
            font-size: 12px;
            color: var(--text-secondary);
            margin-top: 1px;
        }

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

        .icon-btn {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid var(--border);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.2s;
            font-size: 16px;
            color: var(--text-secondary);
        }

        .icon-btn:hover {
            background: var(--accent-glow);
            color: var(--accent);
        }

        .icon-btn.active {
            background: var(--accent-glow);
            color: var(--accent);
        }

        /* ── SENDER PICKER ────────────────────────── */
        #senderBar {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 20px;
            background: rgba(0, 200, 122, 0.06);
            border-bottom: 1px solid rgba(0, 200, 122, 0.15);
            flex-shrink: 0;
            flex-wrap: wrap;
            font-size: 13px;
            color: var(--text-secondary);
        }

        #senderBar span {
            font-weight: 500;
        }

        .sender-chip {
            padding: 5px 14px;
            border-radius: 20px;
            background: rgba(255, 255, 255, 0.06);
            border: 1px solid var(--border);
            cursor: pointer;
            transition: all 0.2s;
            font-size: 12px;
            font-weight: 500;
            color: var(--text-secondary);
        }

        .sender-chip:hover {
            border-color: var(--accent);
            color: var(--accent);
        }

        .sender-chip.selected {
            background: var(--accent);
            color: #000;
            border-color: var(--accent);
            font-weight: 600;
        }

        /* ── SEARCH BAR ───────────────────────────── */
        #searchBar {
            padding: 10px 20px;
            background: var(--bg-panel);
            border-bottom: 1px solid var(--border);
            flex-shrink: 0;
            display: none;
        }

        #searchBar.visible {
            display: flex;
        }

        #searchInput {
            width: 100%;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 9px 16px 9px 38px;
            color: var(--text-primary);
            font-family: 'Outfit', sans-serif;
            font-size: 14px;
            outline: none;
            transition: border-color 0.2s;
            position: relative;
        }

        #searchInput:focus {
            border-color: var(--accent);
        }

        .search-wrap {
            position: relative;
            width: 100%;
        }

        .search-icon {
            position: absolute;
            left: 12px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-meta);
            font-size: 14px;
            pointer-events: none;
        }

        #searchCount {
            position: absolute;
            right: 12px;
            top: 50%;
            transform: translateY(-50%);
            font-size: 11px;
            color: var(--text-meta);
        }

        /* ── CHAT AREA ────────────────────────────── */
        #chatArea {
            flex: 1;
            overflow-y: auto;
            padding: 16px 20px;
            display: flex;
            flex-direction: column;
            gap: 2px;
            scroll-behavior: smooth;
        }

        #chatArea::-webkit-scrollbar {
            width: 5px;
        }

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

        #chatArea::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 4px;
        }

        /* ── DATE SEPARATOR ───────────────────────── */
        .date-sep {
            display: flex;
            align-items: center;
            gap: 12px;
            margin: 14px 0 10px;
            color: var(--text-meta);
            font-size: 11px;
            font-weight: 500;
        }

        .date-sep::before,
        .date-sep::after {
            content: '';
            flex: 1;
            height: 1px;
            background: var(--border);
        }

        .date-sep span {
            background: rgba(255, 255, 255, 0.04);
            border: 1px solid var(--border);
            padding: 3px 12px;
            border-radius: 20px;
            white-space: nowrap;
        }

        /* ── SYSTEM MESSAGE ───────────────────────── */
        .sys-msg {
            text-align: center;
            font-size: 11.5px;
            color: var(--text-meta);
            padding: 5px 14px;
            background: rgba(255, 255, 255, 0.03);
            border-radius: 12px;
            margin: 4px auto;
            max-width: 70%;
            font-style: italic;
        }

        /* ── MESSAGE ROW ──────────────────────────── */
        .msg-row {
            display: flex;
            margin: 2px 0;
            content-visibility: auto;
            contain-intrinsic-size: auto 50px;
        }

        @keyframes msgIn {
            from {
                opacity: 0;
                transform: translateY(6px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .msg-row.out {
            justify-content: flex-end;
        }

        .msg-row.in {
            justify-content: flex-start;
        }

        /* ── BUBBLE ───────────────────────────────── */
        .bubble {
            max-width: min(65%, 480px);
            padding: 9px 13px 7px;
            border-radius: var(--radius-bubble);
            position: relative;
            word-break: break-word;
            line-height: 1.5;
            font-size: 14px;
            box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
            transition: background 0.2s;
        }

        .msg-row.out .bubble {
            background: var(--bg-bubble-out);
            border-bottom-right-radius: 5px;
            color: #e8f8f3;
        }

        .msg-row.in .bubble {
            background: var(--bg-bubble-in);
            border-bottom-left-radius: 5px;
            color: var(--text-primary);
        }

        .bubble.highlight {
            outline: 2px solid var(--accent);
            background: rgba(0, 200, 122, 0.12) !important;
        }

        /* sender name inside bubble */
        .bubble-sender {
            font-size: 12px;
            font-weight: 600;
            margin-bottom: 3px;
        }

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

        .bubble-time {
            font-size: 11px;
            color: rgba(255, 255, 255, 0.4);
            text-align: right;
            margin-top: 4px;
            font-family: 'JetBrains Mono', monospace;
        }

        .msg-row.out .bubble-time {
            color: rgba(255, 255, 255, 0.5);
        }

        /* media in bubble */
        .bubble-media {
            max-width: 100%;
            border-radius: 10px;
            display: block;
            margin-bottom: 4px;
            cursor: pointer;
        }

        .media-placeholder {
            display: flex;
            align-items: center;
            gap: 8px;
            background: rgba(255, 255, 255, 0.06);
            border-radius: 10px;
            padding: 10px 14px;
            font-size: 12px;
            color: var(--text-secondary);
            margin-bottom: 4px;
        }

        .media-placeholder .media-icon {
            font-size: 22px;
        }

        /* ── STATS BAR ────────────────────────────── */
        #statsBar {
            padding: 8px 20px;
            background: var(--bg-sidebar);
            border-top: 1px solid var(--border);
            display: flex;
            gap: 20px;
            flex-shrink: 0;
            font-size: 11.5px;
            color: var(--text-meta);
            flex-wrap: wrap;
        }

        .stat-item b {
            color: var(--accent);
        }

        /* ── LOADING ──────────────────────────────── */
        #loadingBar {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 3px;
            background: linear-gradient(90deg, var(--accent), #00e98a);
            z-index: 200;
            display: none;
            animation: loadSlide 1.2s ease-in-out infinite;
        }

        @keyframes loadSlide {
            0% {
                transform: translateX(-100%);
            }

            100% {
                transform: translateX(100%);
            }
        }

        /* ── IMAGE LIGHTBOX ───────────────────────── */
        #lightbox {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.9);
            z-index: 300;
            align-items: center;
            justify-content: center;
            cursor: zoom-out;
        }

        #lightbox.open {
            display: flex;
        }

        #lightboxImg {
            max-width: 90vw;
            max-height: 90vh;
            border-radius: 8px;
        }

        /* ── EMPTY STATE ──────────────────────────── */
        #emptyState {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: var(--text-meta);
            gap: 8px;
            font-size: 14px;
        }

        #emptyState .big {
            font-size: 40px;
        }

        /* color palette for senders */
        .color-0 {
            color: #f0804b;
        }

        .color-1 {
            color: #6bb5f0;
        }

        .color-2 {
            color: #c77cf5;
        }

        .color-3 {
            color: #f5c842;
        }

        .color-4 {
            color: #f06bb5;
        }

        .color-5 {
            color: #42f5c5;
        }