@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ================================================================
   Design Tokens (Japanese Traffic Cyan + Deep Violet Base)
   ================================================================ */
:root {
    --bg-primary: #0b0914;
    --bg-secondary: #131021;
    --bg-card: rgba(23, 19, 38, 0.85);
    --bg-glass: rgba(23, 19, 38, 0.6);
    --bg-input: rgba(255, 255, 255, 0.05);

    --text-primary: #f0fdfa;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Японский сине-зелёный (Ao Sign) */
    --accent-purple: #00e6a8;      /* Главный акцентный бирюзовый */
    --accent-violet: #00b386;      /* Тёмный бирюзовый для градиентов */
    --accent-pink: #2dd4bf;        /* Доп. свечение */
    --accent-green: #10b981;
    --accent-red: #f87171;
    --accent-orange: #fb923c;
    --accent-cyan: #22d3ee;

    --gradient-main: linear-gradient(135deg, #00e6a8 0%, #009975 100%);
    --gradient-card: linear-gradient(145deg, rgba(0, 230, 168, 0.08), rgba(0, 153, 117, 0.04));
    --gradient-glow: radial-gradient(ellipse at 50% 0%, rgba(0, 230, 168, 0.15) 0%, transparent 60%);

    --border-subtle: rgba(0, 230, 168, 0.18);
    --border-active: rgba(0, 230, 168, 0.4);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 30px rgba(0, 230, 168, 0.2);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ================================================================
   Reset & Base
   ================================================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Ambient background glow */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(circle at 20% 20%, rgba(0, 230, 168, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(45, 212, 191, 0.04) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(0, 179, 134, 0.03) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    animation: ambientShift 20s ease-in-out infinite alternate;
}

@keyframes ambientShift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-2%, -2%) scale(1.02); }
}

/* ================================================================
   Landing Page
   ================================================================ */
.landing-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.hero {
    text-align: center;
    max-width: 700px;
    margin-bottom: 3rem;
}

.hero-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    display: inline-block;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.hero h1 {
    font-size: 3rem;
    font-weight: 700;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
}

.hero p {
    color: var(--text-secondary);
    font-size: 1.15rem;
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.7;
}

/* Main action card */
.action-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    position: relative;
    overflow: hidden;
}

.action-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-purple), transparent);
    opacity: 0.5;
}

.action-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.75rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--gradient-main);
    color: #0b0914;
    box-shadow: 0 4px 16px rgba(0, 230, 168, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 230, 168, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-active);
}

.btn-full {
    width: 100%;
}

.divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

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

.join-form {
    display: flex;
    gap: 0.75rem;
}

.input {
    flex: 1;
    padding: 0.85rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    transition: all var(--transition);
    outline: none;
}

.input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(0, 230, 168, 0.15);
}

.input::placeholder {
    color: var(--text-muted);
}

/* Features grid */
.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    width: 100%;
    max-width: 700px;
    margin-top: 3rem;
}

.feature-card {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    transition: all var(--transition);
}

.feature-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-active);
    box-shadow: var(--shadow-glow);
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    display: block;
}

.feature-card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.feature-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ================================================================
   Room Page Layout
   ================================================================ */
.room-container {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 100vh;
    gap: 0;
}

/* Sidebar */
.sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.25rem;
    overflow-y: auto;
}

.room-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.room-header .logo {
    font-size: 1.5rem;
}

.room-header h1 {
    font-size: 1.1rem;
    font-weight: 700;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.room-header a {
    text-decoration: none;
}

/* Status bar */
.status-bar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.status-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    transition: all var(--transition);
}

.status-dot.connected { background: var(--accent-green); box-shadow: 0 0 8px rgba(16, 185, 129, 0.5); }
.status-dot.waiting { background: var(--accent-orange); animation: pulse 2s infinite; }
.status-dot.connecting { background: var(--accent-cyan); animation: pulse 1s infinite; }
.status-dot.disconnected { background: var(--text-muted); }
.status-dot.error { background: var(--accent-red); box-shadow: 0 0 8px rgba(248, 113, 113, 0.5); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.encryption-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(100, 116, 139, 0.2);
    color: var(--text-muted);
    transition: all var(--transition);
}

.encryption-badge.active {
    background: rgba(0, 230, 168, 0.15);
    color: var(--accent-purple);
}

.fingerprint-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.fingerprint-value {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--accent-cyan);
    letter-spacing: 0.05em;
    user-select: all;
}

/* Invite section */
.invite-section {
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.invite-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.qr-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.qr-wrapper img {
    width: 180px;
    height: 180px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-subtle);
    transition: all var(--transition);
}

.qr-wrapper img:hover {
    border-color: var(--accent-purple);
    box-shadow: var(--shadow-glow);
    transform: scale(1.02);
}

.room-link {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    width: 100%;
}

.room-link .input {
    font-size: 0.8rem;
    padding: 0.6rem 0.75rem;
    min-width: 0;
}

.btn-icon {
    padding: 0.6rem 0.85rem;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.btn-icon.copied {
    background: rgba(0, 230, 168, 0.15);
    color: var(--accent-purple);
    border-color: var(--accent-purple);
}

/* Back link */
.back-link {
    margin-top: auto;
    padding-top: 1rem;
}

.back-link a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: color var(--transition);
}

.back-link a:hover {
    color: var(--accent-purple);
}

/* ================================================================
   Chat Area
   ================================================================ */
.chat-area {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-primary);
    position: relative;
}

.chat-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-glow);
    pointer-events: none;
    opacity: 0.5;
}

#chat-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

#chat-container.drag-over {
    outline: 2px dashed var(--accent-purple);
    outline-offset: -8px;
    background: rgba(0, 230, 168, 0.03);
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
}

/* Scrollbar */
#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 230, 168, 0.2);
    border-radius: 3px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 230, 168, 0.4);
}

/* Messages */
.chat-message {
    display: flex;
    max-width: 70%;
    animation: messageIn 0.3s ease-out;
}

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

.chat-message.sent {
    align-self: flex-end;
}

.chat-message.received {
    align-self: flex-start;
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    max-width: 100%;
    word-wrap: break-word;
    position: relative;
}

.sent .message-bubble {
    background: var(--gradient-main);
    color: #0b0914;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 12px rgba(0, 230, 168, 0.25);
    font-weight: 500;
}

.received .message-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-bottom-left-radius: 4px;
}

.message-text {
    font-size: 0.95rem;
    line-height: 1.5;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.6;
    text-align: right;
    margin-top: 0.35rem;
}

/* System messages */
.system-message {
    text-align: center;
    animation: messageIn 0.3s ease-out;
}

.system-message span {
    display: inline-block;
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

/* File messages */
.file-bubble {
    min-width: 260px;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-name {
    font-size: 0.9rem;
    font-weight: 500;
    word-break: break-all;
}

.file-size {
    font-size: 0.75rem;
    opacity: 0.7;
}

.progress-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-main);
    border-radius: 2px;
    transition: width 0.15s ease;
}

.progress-fill.complete {
    background: var(--accent-green);
}

.file-status {
    font-size: 0.75rem;
    opacity: 0.7;
}

.file-status.complete {
    color: var(--accent-green);
    opacity: 1;
}

/* Input area */
.chat-input-area {
    position: relative;
    z-index: 1;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
}

#file-drop-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    margin-bottom: 0.75rem;
    border: 2px dashed var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: all var(--transition);
    cursor: pointer;
    min-height: 40px;
}

#file-drop-zone:hover,
#file-drop-zone.drag-over {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
    background: rgba(0, 230, 168, 0.05);
}

.input-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.input-row .input {
    flex: 1;
    min-height: 44px;
    resize: none;
}

.input-row .btn {
    height: 44px;
    padding: 0 1.25rem;
}

.btn-file {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    font-size: 1.2rem;
    padding: 0 0.85rem;
    height: 44px;
}

.btn-file:hover {
    color: var(--accent-purple);
    border-color: var(--accent-purple);
}

/* ================================================================
   Empty Chat State
   ================================================================ */
.empty-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.empty-chat-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.8;
}

.empty-chat h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.empty-chat p {
    font-size: 0.85rem;
    max-width: 300px;
    line-height: 1.6;
}

/* ================================================================
   Responsive
   ================================================================ */
@media (max-width: 768px) {
    .room-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .sidebar {
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }

    .hero h1 {
        font-size: 2rem;
    }

    .features {
        grid-template-columns: 1fr;
        max-width: 400px;
    }

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

    .join-form {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .action-card {
        padding: 1.5rem;
    }

    .sidebar {
        padding: 1rem;
    }
}

/* Language Switcher */
.lang-switcher {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 100;
    display: flex;
    gap: 0.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 0.25rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.lang-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.35rem 0.75rem;
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition);
}

.lang-btn.active {
    background: var(--gradient-main);
    color: #0b0914;
    box-shadow: var(--shadow-sm);
}

.lang-btn:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}