@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #f3efe7;
    --surface: #ffffff;
    --surface-alt: #f8f6f1;
    --surface-dark: #111827;
    --line: rgba(17, 24, 39, 0.12);
    --text: #111827;
    --muted: #6b7280;
    --accent: #1f5eff;
    --accent-strong: #163fb6;
    --danger: #c24156;
    --shadow: 0 18px 50px rgba(17, 24, 39, 0.08);
    --radius-xl: 24px;
}

* {
    box-sizing: border-box;
}

html, body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(31, 94, 255, 0.06), transparent 28%),
        radial-gradient(circle at right center, rgba(17, 24, 39, 0.04), transparent 22%),
        var(--bg);
    overflow: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: linear-gradient(rgba(17, 24, 39, 0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(17, 24, 39, 0.03) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent 90%);
    pointer-events: none;
}

.page-shell {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100vh;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pageFadeIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
    overflow: hidden;
}

.auth-shell {
    width: min(1080px, 100%);
    height: auto;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 24px;
    align-items: stretch;
}

.auth-shell--single {
    width: min(520px, 100%);
    grid-template-columns: 1fr;
}

.brand-panel,
.auth-card,
#chat-container {
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    will-change: transform, opacity;
}

.brand-panel {
    border-radius: var(--radius-xl);
    padding: clamp(28px, 4vw, 44px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    min-height: 560px;
    background: var(--surface-dark);
    color: #f8fafc;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: fit-content;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(248, 250, 252, 0.78);
    font-size: 0.85rem;
}

.eyebrow-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #9db4ff;
}

.brand-title {
    margin: 22px 0 14px;
    font-size: clamp(2.7rem, 5vw, 5.25rem);
    line-height: 0.95;
    letter-spacing: -0.05em;
    max-width: 9ch;
}

.brand-copy {
    margin: 0;
    max-width: 34rem;
    color: rgba(248, 250, 252, 0.72);
    font-size: 1.02rem;
    line-height: 1.7;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 28px;
}

.feature-card {
    padding: 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.feature-card strong {
    display: block;
    margin-bottom: 6px;
    font-size: 0.98rem;
}

.feature-card span {
    color: rgba(248, 250, 252, 0.68);
    font-size: 0.92rem;
    line-height: 1.5;
}

.auth-card {
    border-radius: var(--radius-xl);
    padding: clamp(28px, 4vw, 42px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: var(--surface);
    animation: cardRise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.auth-shell--single .auth-card {
    padding: 32px;
}

.auth-shell--single .auth-card h1 {
    margin-top: 14px;
}

.auth-shell--single .auth-card .eyebrow {
    animation: chipPop 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.auth-shell--single .auth-card h1 {
    animation: textRise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: 0.08s;
}

.auth-shell--single .auth-card p {
    animation: textRise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: 0.14s;
}

.auth-shell--single .field-stack {
    animation: textRise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: 0.22s;
}

.auth-shell--single #login-form button {
    animation: textRise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: 0.3s;
}

.auth-shell--single .auth-note {
    animation: textRise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: 0.38s;
}

.auth-shell--single .auth-note {
    margin-top: 18px;
}

.auth-card h1 {
    margin: 0 0 10px;
    font-size: clamp(2rem, 3vw, 2.6rem);
    letter-spacing: -0.04em;
}

.auth-card p {
    margin: 0 0 26px;
    color: var(--muted);
    line-height: 1.6;
}

#login-form,
#chat-form {
    display: flex;
    gap: 12px;
}

#login-form {
    flex-direction: column;
}

.field-stack {
    display: grid;
    gap: 12px;
}

input[type='text'],
input[type='password'],
#message-input {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--surface-alt);
    color: var(--text);
    border-radius: 16px;
    padding: 15px 16px;
    font: inherit;
    outline: none;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.28s cubic-bezier(0.22, 1, 0.36, 1), background 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

input::placeholder,
#message-input::placeholder {
    color: #9ca3af;
}

input:focus,
#message-input:focus {
    border-color: rgba(31, 94, 255, 0.6);
    box-shadow: 0 0 0 4px rgba(31, 94, 255, 0.12);
    background: #fff;
}

button {
    border: 0;
    border-radius: 16px;
    padding: 14px 18px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.28s cubic-bezier(0.22, 1, 0.36, 1), filter 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

button:hover {
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

#login-form button,
#chat-form button {
    background: var(--accent);
    color: white;
    box-shadow: 0 10px 24px rgba(31, 94, 255, 0.2);
}

#login-form button {
    width: 100%;
    padding: 15px 18px;
}

.auth-note {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    color: var(--muted);
    font-size: 0.92rem;
}

.auth-lock {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: #edf2ff;
    color: var(--accent-strong);
    font-weight: 700;
}

#error-message {
    margin: 8px 0 0;
    color: var(--danger);
    min-height: 1.25em;
    font-size: 0.95rem;
    opacity: 0;
    transform: translateY(-4px);
}

#error-message.is-visible {
    animation: errorPop 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
    opacity: 1;
    transform: translateY(0);
}

.chat-shell {
    width: min(1200px, 100%);
    height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    margin: 0 auto;
}

#chat-container {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-xl);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    position: relative;
    overflow: hidden;
    background: var(--surface);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.chat-friend-name {
    min-width: 0;
}

.chat-friend-name h1 {
    margin: 0;
    font-size: 1.25rem;
    letter-spacing: -0.03em;
    color: var(--text);
}



.status-pill {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--surface-alt);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.9rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #9ca3af;
    transition: background-color 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.28s cubic-bezier(0.22, 1, 0.36, 1), transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.status-dot.is-online {
    background: #16a34a;
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.12);
}

.status-dot.is-offline {
    background: #9ca3af;
}

.status-separator {
    color: rgba(107, 114, 128, 0.7);
}

#messages {
    padding: 22px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
    scroll-behavior: smooth;
}

#messages::-webkit-scrollbar {
    width: 10px;
}

#messages::-webkit-scrollbar-thumb {
    background: rgba(17, 24, 39, 0.18);
    border-radius: 999px;
    border: 3px solid transparent;
    background-clip: padding-box;
}

.message {
    max-width: min(72%, 560px);
    word-wrap: break-word;
    padding: 14px 16px;
    border-radius: 22px;
    position: relative;
    animation: fadeInUp 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
    display: flex;
    flex-direction: column;
    gap: 6px;
    line-height: 1.5;
}

.message span:first-child {
    font-size: 0.98rem;
}

.my-message {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 6px;
}

.other-message {
    align-self: flex-start;
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--line);
    border-bottom-left-radius: 6px;
}

.timestamp {
    font-size: 0.76rem;
    color: rgba(255, 255, 255, 0.78);
    text-align: right;
}

.other-message .timestamp {
    color: var(--muted);
}

#chat-form {
    padding: 20px 22px;
    border-top: 1px solid var(--line);
    background: var(--surface);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: flex-end;
}

.input-wrapper {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: flex-end;
}

#message-input {
    min-height: 54px;
    font-size: 16px;
}

#chat-form .send-btn {
    min-width: 120px;
    padding: 16px 20px;
    font-size: 0.95rem;
}

.icon-btn {
    width: 54px;
    height: 54px;
    min-width: 54px;
    padding: 0;
    border-radius: 16px;
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--line);
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    transition: all 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.icon-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(31, 94, 255, 0.3);
}

.icon-btn:active {
    transform: translateY(0);
}

.recording-ui {
    position: absolute;
    bottom: 20px;
    left: 22px;
    right: 22px;
    padding: 16px 20px;
    background: var(--danger);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: white;
    animation: slideUp 0.28s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    z-index: 10;
}

.recording-ui.hidden {
    display: none;
}

.recording-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.recording-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    animation: pulse 0.8s ease-in-out infinite;
}

#recording-time {
    font-weight: 600;
    font-size: 0.95rem;
}

.recording-buttons {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.btn-cancel,
.btn-send {
    border: none;
    padding: 10px 16px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.btn-send {
    background: white;
    color: var(--danger);
    font-weight: 700;
}

.btn-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.voice-message {
    margin: 8px 0;
}

/* Custom WhatsApp-style audio player */
.voice-player {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface-alt);
    padding: 8px 12px;
    border-radius: 12px;
    max-width: 420px;
}

.voice-player .play-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: white;
    display: grid;
    place-items: center;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(31,94,255,0.12);
}

.voice-player .play-btn:active { transform: translateY(0); }

.progress-wrap {
    position: relative;
    flex: 1;
    height: 12px;
    background: rgba(17,24,39,0.06);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-strong));
}

.time-elapsed,
.time-duration {
    font-size: 0.8rem;
    color: var(--muted);
    min-width: 40px;
    text-align: right;
}

.hidden {
    display: none !important;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pageFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cardRise {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes textRise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes chipPop {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes errorPop {
    0% {
        opacity: 0;
        transform: translateY(-6px);
    }
    55% {
        opacity: 1;
        transform: translateY(0);
    }
    75% {
        transform: translateX(-3px);
    }
    100% {
        transform: translateX(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .page-shell,
    .message {
        animation: none !important;
    }
}

@media screen and (max-width: 920px) {
    .auth-shell {
        grid-template-columns: 1fr;
    }

    .brand-panel {
        min-height: auto;
    }
}

@media screen and (max-width: 700px) {
    body {
        overflow: auto;
    }

    .page-shell {
        padding: 12px;
    }

    .chat-shell {
        max-height: 100vh;
    }

    .auth-card,
    .brand-panel,
    #chat-container {
        border-radius: 24px;
    }

    .feature-grid {
        grid-template-columns: 1fr;
    }

    .chat-header {
        padding: 16px;
    }

    #messages {
        padding: 16px;
    }

    .message {
        max-width: 90%;
    }

    #chat-form {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    #chat-form button {
        width: 100%;
    }
}

@media screen and (max-width: 480px) {
    .brand-title {
        font-size: clamp(2.1rem, 14vw, 3rem);
    }

    .auth-card,
    .brand-panel {
        padding: 20px;
    }

    .chat-avatar {
        width: 42px;
        height: 42px;
        border-radius: 14px;
    }
}

