/* =============================
   GTChat - Global Styles
   ============================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --gihan-color: #6c63ff;
    --gihan-light: #ede9ff;
    --teah-color: #ff6584;
    --teah-light: #ffe9ee;
    --bg: #f0f2f5;
    --white: #ffffff;
    --text-dark: #1a1a2e;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
    --radius: 18px;
    --radius-sm: 8px;
}

html,
body {
    height: 100%;
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text-dark);
    -webkit-font-smoothing: antialiased;
}

/* =============================
   HOME PAGE
   ============================= */

.home-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.home-logo {
    margin-bottom: 12px;
    font-size: 52px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }
}

.home-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.home-subtitle {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: 48px;
    font-weight: 400;
}

.home-cards {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
    max-width: 360px;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 22px 24px;
    background: var(--white);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-dark);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 2px solid transparent;
}

.user-card:hover,
.user-card:active {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
}

.user-card.gihan {
    border-color: var(--gihan-color);
}

.user-card.teah {
    border-color: var(--teah-color);
}

.user-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    flex-shrink: 0;
}

.gihan .user-avatar {
    background: var(--gihan-light);
    color: var(--gihan-color);
}

.teah .user-avatar {
    background: var(--teah-light);
    color: var(--teah-color);
}

.user-info h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.user-info p {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.user-card .arrow {
    margin-left: auto;
    font-size: 1.2rem;
    color: var(--text-muted);
}

/* =============================
   CHAT PAGE
   ============================= */

.chat-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 480px;
    margin: 0 auto;
    background: var(--white);
    position: relative;
}

/* Header */
.chat-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.header-gihan {
    background: linear-gradient(135deg, #6c63ff, #8b85ff);
}

.header-teah {
    background: linear-gradient(135deg, #ff6584, #ff99b0);
}

.chat-header .back-btn {
    color: var(--white);
    text-decoration: none;
    font-size: 1.3rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    padding: 4px;
    border-radius: 50%;
    transition: opacity 0.2s;
}

.chat-header .back-btn:hover {
    opacity: 1;
}

.header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--white);
    flex-shrink: 0;
}

.header-info h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--white);
    line-height: 1.2;
}

.header-info p {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.75);
}

.header-calls {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

.call-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
}

.call-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

.call-btn:active {
    transform: scale(0.9);
}

/* =============================
   CALL OVERLAY
   ============================= */

.call-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.call-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.call-content {
    text-align: center;
    width: 100%;
}

.caller-avatar {
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 700;
}

.call-content h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    opacity: 0.8;
}

.call-content p {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 40px;
}

.video-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 9/16;
    background: #000;
    margin: 0 auto 40px;
    border-radius: 20px;
    overflow: hidden;
}

.remote-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.local-video {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 120px;
    aspect-ratio: 9/16;
    background: #222;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    object-fit: cover;
}

.call-actions {
    display: flex;
    gap: 30px;
    justify-content: center;
}

.action-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.action-btn:active {
    transform: scale(0.9);
}

.action-btn.decline {
    background: #ff4b5c;
}

.action-btn.answer {
    background: #2ecc71;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.4);
    }

    70% {
        box-shadow: 0 0 0 20px rgba(46, 204, 113, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0);
    }
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bg);
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* Message bubbles */
.message-row {
    display: flex;
    flex-direction: column;
    max-width: 78%;
    animation: pop-in 0.2s ease;
}

@keyframes pop-in {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message-row.sent {
    align-self: flex-end;
    align-items: flex-end;
}

.message-row.received {
    align-self: flex-start;
    align-items: flex-start;
}

/* Time + tick sit inline below bubble */
.message-row .bubble-time {
    display: flex;
    align-items: center;
    gap: 3px;
}

.bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.92rem;
    line-height: 1.5;
    word-break: break-word;
    max-width: 100%;
}

/* Sent bubble colours depend on who is the logged-in user */
.bubble.sent-gihan {
    background: var(--gihan-color);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.bubble.sent-teah {
    background: var(--teah-color);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.bubble.received {
    background: var(--white);
    color: var(--text-dark);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border);
}

.bubble-time {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 3px;
    padding: 0 4px;
}

.bubble-sender-label {
    font-size: 0.72rem;
    font-weight: 600;
    margin-bottom: 4px;
    padding: 0 4px;
    color: var(--text-muted);
}

.empty-state {
    margin: auto;
    text-align: center;
    color: var(--text-muted);
    padding: 32px 16px;
}

.empty-state .emoji {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.empty-state p {
    font-size: 0.9rem;
}

/* Input bar */
.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--white);
    border-top: 1px solid var(--border);
    position: sticky;
    bottom: 0;
}

.chat-input-bar textarea {
    flex: 1;
    resize: none;
    border: 1.5px solid var(--border);
    border-radius: 22px;
    padding: 10px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 0.92rem;
    line-height: 1.4;
    outline: none;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color 0.2s;
    background: var(--bg);
    color: var(--text-dark);
}

.chat-input-bar textarea:focus {
    border-color: var(--gihan-color);
    background: var(--white);
}

.send-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.send-btn:active {
    transform: scale(0.93);
}

.send-btn-gihan {
    background: var(--gihan-color);
    color: var(--white);
}

.send-btn-teah {
    background: var(--teah-color);
    color: var(--white);
}

/* Date divider */
.date-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 500;
    margin: 6px 0;
}

.date-divider::before,
.date-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* =============================
   ATTACH BUTTON
   ============================= */

.attach-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s ease, opacity 0.15s;
    background: var(--bg);
    border: 1.5px solid var(--border);
}

.attach-btn:hover {
    opacity: 0.8;
    transform: scale(1.08);
}

.attach-btn:active {
    transform: scale(0.93);
}

/* =============================
   FILE PREVIEW BAR
   ============================= */

.file-preview-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--white);
    border-top: 1px solid var(--border);
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fp-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.fp-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.fp-pill {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fp-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
    padding: 4px;
    border-radius: 50%;
    line-height: 1;
    transition: color 0.15s;
    flex-shrink: 0;
}

.fp-remove:hover {
    color: #ef4444;
}

/* =============================
   IMAGE BUBBLE
   ============================= */

.bubble-media {
    padding: 6px !important;
}

/* Responsive image — fills bubble width, never overflows */
.msg-image {
    display: block;
    width: 100%;
    max-width: 280px;
    height: auto;
    max-height: 320px;
    object-fit: cover;
    border-radius: 12px;
    cursor: zoom-in;
    transition: opacity 0.18s, transform 0.18s;
}

.msg-image:hover {
    opacity: 0.88;
    transform: scale(1.01);
}

.media-caption {
    font-size: 0.85rem;
    margin: 6px 4px 2px;
    line-height: 1.4;
    word-break: break-word;
}

/* =============================
   DOCUMENT PILL
   ============================= */

.doc-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    text-decoration: none;
    color: inherit;
    border-radius: 10px;
    min-width: 180px;
    max-width: 260px;
    transition: opacity 0.15s;
}

.doc-pill:hover {
    opacity: 0.8;
}

.doc-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.doc-name {
    flex: 1;
    font-size: 0.82rem;
    font-weight: 500;
    word-break: break-all;
    line-height: 1.3;
}

.doc-dl {
    font-size: 1rem;
    flex-shrink: 0;
    opacity: 0.7;
}

/* =============================
   STATUS TICKS
   ============================= */

.msg-status {
    font-size: 0.72rem;
    margin-top: 1px;
    margin-left: 2px;
    user-select: none;
    line-height: 1;
}

.status-sent {
    color: var(--text-muted);
}

.status-delivered {
    color: var(--text-muted);
}

.status-seen {
    color: #4fc3f7;
}

/* WhatsApp-style blue */

/* =============================
   LIGHTBOX
   ============================= */

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    padding: 16px;
}

.lightbox.active {
    opacity: 1;
    pointer-events: all;
}

.lb-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 1.3rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    z-index: 1001;
}

.lb-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lb-img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    transform: scale(0.95);
    transition: transform 0.22s ease;
    display: block;
}

.lightbox.active .lb-img {
    transform: scale(1);
}

.lb-caption {
    margin-top: 12px;
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.85rem;
    max-width: 80%;
    text-align: center;
    line-height: 1.4;
}

/* =============================
   LINKS IN MESSAGES
   ============================= */

.msg-link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    opacity: 0.9;
    word-break: break-all;
}

.msg-link:hover {
    opacity: 1;
}

/* =============================
   LINK PREVIEW CARD
   ============================= */

.link-preview {
    display: flex;
    flex-direction: column;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-top: 6px;
    max-width: 280px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s, transform 0.2s;
}

.link-preview:hover {
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.14);
    transform: translateY(-1px);
}

.lp-img {
    width: 100%;
    max-height: 150px;
    object-fit: cover;
    display: block;
    background: var(--border);
}

.lp-body {
    padding: 10px 12px;
}

.lp-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 4px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.lp-desc {
    font-size: 0.74rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.lp-url {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
    opacity: 0.75;
}

/* =============================
   RESPONSIVE
   ============================= */

@media (min-width: 480px) {
    .chat-wrapper {
        margin-top: 0;
        box-shadow: var(--shadow);
        border-radius: 0;
    }
}