/* ===== RESET ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Inter", system-ui, -apple-system, sans-serif;
}

/* ===== ROOT COLORS ===== */
:root {
    --bg-main: #0f0b1a;
    --bg-panel: #161226;
    --bg-soft: #1f1a33;

    --accent: #ff6ad5;
    --accent-soft: #b65cff;

    --text-main: #f3f3f7;
    --text-soft: #b9b4d0;
    --text-muted: #7a7398;

    --online: #4cff9a;
    --offline: #ff5c5c;

    --radius: 14px;
    --radius-sm: 10px;

    --shadow: 0 10px 30px rgba(0,0,0,0.35);

    --vh: 1vh;
}

/* ===== BODY ===== */
body {
    background: radial-gradient(1200px 600px at top, #1a1230 0%, var(--bg-main) 50%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
}

/* ===== CONTAINER ===== */
.container {
    width: 100%;
    max-width: 1100px;
    height: calc(var(--vh) * 92);
    background: var(--bg-panel);
    border-radius: 22px;
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    position: relative;
    animation: fadeIn 0.6s ease;
    padding-bottom: env(safe-area-inset-bottom);
}

.hidden {
    display: none!important;
}

/* ===== AUTH SCREEN ===== */
#auth-screen {
    width: 100%;
    max-width: 420px;
    margin: auto;
    padding: 40px 30px;
    background: linear-gradient(160deg, #1a1430, #120f24);
    border-radius: 22px;
    box-shadow: var(--shadow);
    text-align: center;
    animation: pop 0.6s ease;
}

#auth-screen h2 {
    margin-bottom: 20px;
    font-size: 26px;
    background: linear-gradient(90deg, var(--accent), var(--accent-soft));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#error-msg {
    color: #ff8c8c;
    margin-bottom: 12px;
    min-height: 18px;
    font-size: 14px;
}

#auth-screen input {
    width: 100%;
    padding: 12px 14px;
    margin: 10px 0;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--bg-soft);
    color: var(--text-main);
    outline: none;
    transition: 0.25s ease;
}

#auth-screen input:focus {
    box-shadow: 0 0 0 2px var(--accent-soft);
}

#auth-screen button {
    width: 100%;
    padding: 12px;
    margin-top: 12px;
    border-radius: var(--radius-sm);
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
    color: #fff;
    cursor: pointer;
    font-weight: 600;
    transition: 0.25s ease;
}

#auth-screen button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(255,106,213,0.35);
}

.switch-btn {
    background: none !important;
    color: var(--text-soft) !important;
    margin-top: 10px;
}

/* ===== CHAT SCREEN ===== */
#chat-screen {
    width: 100%;
    height: 100%;
    background: var(--bg-panel);
    display: flex;
    flex-direction: row;
}

.chat-window {
    display: flex;
    flex-direction: column;
}

/* ===== HEADER ===== */
#chat-screen header {
    width: 100%;
    height: 64px;
    background: linear-gradient(180deg, #1b1632, #15102a);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

#header-username {
    font-weight: 700;
    font-size: 18px;
}

#user-status {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-soft);
    font-size: 13px;
}

#status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

#status-dot.offline {
    background: var(--offline);
}

#chat-screen header button {
    border-radius: 10px;
    border: none;
    background: rgba(255,255,255,0.08);
    color: var(--text-main);
    cursor: pointer;
    transition: 0.25s ease;
}

#chat-screen header button:hover {
    background: rgba(255,255,255,0.15);
}

/* ===== CHAT LIST ===== */
#chat-list {
    width: 260px;
    min-width: 220px;
    background: linear-gradient(180deg, #141027, #100c20);
    border-right: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.chat-list-header {
    padding: 14px 16px;
    font-weight: 700;
    color: var(--text-soft);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.chat-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: 0.25s ease;
}

.chat-item:hover {
    background: rgba(255,255,255,0.05);
}

.chat-item.active {
    background: linear-gradient(90deg, rgba(255,106,213,0.15), transparent);
}

.chat-name {
    font-weight: 600;
}

.chat-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.chat-status.online {
    background: var(--online);
}

.chat-status.offline {
    background: var(--offline);
}

/* ===== MESSAGES ===== */
#messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: radial-gradient(800px 400px at bottom, #1a1433 0%, var(--bg-panel) 50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 14px;
    background: var(--bg-soft);
    animation: slideUp 0.35s ease;
    position: relative;
}

.message.mine {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(255,106,213,0.25), rgba(182,92,255,0.25));
}

.message .meta {
    display: block;
    font-size: 12px;
    color: var(--accent);
    margin-bottom: 2px;
}

.message .timestamp {
    font-size: 11px;
    color: var(--text-muted);
    float: right;
    margin-left: 10px;
}

/* ===== INPUT AREA ===== */
#input-area {
    height: 64px;
    padding: 10px;
    background: linear-gradient(180deg, #15102a, #120e22);
    display: flex;
    gap: 10px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

#input-area input {
    flex: 1;
    border-radius: 14px;
    border: none;
    padding: 0 14px;
    background: var(--bg-soft);
    color: var(--text-main);
    outline: none;
    transition: 0.25s ease;
}

#input-area input:focus {
    box-shadow: 0 0 0 2px var(--accent-soft);
}

#input-area button {
    border-radius: 14px;
    border: none;
    padding: 0 18px;
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: 0.25s ease;
}

#input-area button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(255,106,213,0.35);
}

/* ===== SCROLLBAR ===== */
#chat-list::-webkit-scrollbar,
#messages::-webkit-scrollbar {
    width: 6px;
}

#chat-list::-webkit-scrollbar-thumb,
#messages::-webkit-scrollbar-thumb {
    background: linear-gradient(var(--accent), var(--accent-soft));
    border-radius: 6px;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes pop {
    from { transform: scale(0.9); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

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

@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(76,255,154,0.6); }
    70%  { box-shadow: 0 0 0 8px rgba(76,255,154,0); }
    100% { box-shadow: 0 0 0 0 rgba(76,255,154,0); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .container {
        height: 100vh;
        border-radius: 0;
    }

    #chat-list {
        width: 72px;
        min-width: 72px;
    }

    .chat-name {
        display: none;
    }

    #header-username {
        font-size: 16px;
    }

    .message {
        max-width: 90%;
    }
}
