/* ChattyToilet - Web3 Dark Theme */

/* CSS Variables - Web3 Dark Theme */
:root {
    /* Dark backgrounds */
    --bg-primary: #0A0A0F;
    --bg-secondary: #12121A;
    --bg-tertiary: #1A1A25;
    --bg-card: rgba(26, 26, 37, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.03);
    
    /* Accent gradients - Purple to Cyan (Web3 signature) */
    --accent-primary: #A855F7;
    --accent-secondary: #06B6D4;
    --accent-gradient: linear-gradient(135deg, #A855F7 0%, #06B6D4 100%);
    --accent-gradient-hover: linear-gradient(135deg, #9333EA 0%, #0891B2 100%);
    
    /* Neon glows */
    --glow-purple: 0 0 20px rgba(168, 85, 247, 0.4);
    --glow-cyan: 0 0 20px rgba(6, 182, 212, 0.4);
    --glow-mixed: 0 0 30px rgba(168, 85, 247, 0.3), 0 0 60px rgba(6, 182, 212, 0.2);
    
    /* Text colors */
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    
    /* Borders */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(168, 85, 247, 0.3);
    
    /* Status colors */
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    
    /* Spacing & sizing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --header-height: 60px;
    --input-height: 68px;
    --min-tap-target: 44px;
}

/* Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animated background gradient */
.animated-bg {
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(168, 85, 247, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(6, 182, 212, 0.1) 0%, transparent 50%),
        var(--bg-primary);
    z-index: -1;
}

/* ==================== */
/* Home Page Styles     */
/* ==================== */

.home-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: var(--spacing-lg);
    background: 
        radial-gradient(ellipse at 30% 0%, rgba(168, 85, 247, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 100%, rgba(6, 182, 212, 0.15) 0%, transparent 50%),
        var(--bg-primary);
}

.home-container {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg), var(--glow-mixed);
}

.logo {
    font-size: 72px;
    margin-bottom: var(--spacing-md);
    filter: drop-shadow(0 0 20px rgba(168, 85, 247, 0.5));
    animation: float 3s ease-in-out infinite;
}

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

.home-container h1 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: var(--spacing-xs);
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
    font-size: 1.1rem;
}

.instructions {
    text-align: left;
    margin-bottom: var(--spacing-lg);
}

.instructions h2 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: var(--spacing-md);
    font-weight: 600;
}

.step {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) 0;
}

.step-number {
    width: 36px;
    height: 36px;
    background: var(--accent-gradient);
    color: white;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
    box-shadow: var(--glow-purple);
}

.step-text {
    font-size: 1rem;
    color: var(--text-primary);
}

.info-box {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
}

.info-box p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: var(--spacing-xs) 0;
}

/* ==================== */
/* Error Page Styles    */
/* ==================== */

.error-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: var(--spacing-lg);
    background: 
        radial-gradient(ellipse at 50% 50%, rgba(239, 68, 68, 0.1) 0%, transparent 50%),
        var(--bg-primary);
}

.error-container {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.error-icon {
    font-size: 64px;
    margin-bottom: var(--spacing-md);
}

.error-container h1 {
    font-size: 1.5rem;
    color: var(--error);
    margin-bottom: var(--spacing-sm);
}

.error-container p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--min-tap-target);
    padding: var(--spacing-sm) var(--spacing-lg);
    background: var(--accent-gradient);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: var(--glow-purple);
    border: none;
    cursor: pointer;
}

.btn:hover {
    background: var(--accent-gradient-hover);
    transform: translateY(-2px);
    box-shadow: var(--glow-mixed);
}

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

/* ==================== */
/* Chat Page Styles     */
/* ==================== */

.chat-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    background: 
        radial-gradient(ellipse at 0% 0%, rgba(168, 85, 247, 0.08) 0%, transparent 40%),
        radial-gradient(ellipse at 100% 100%, rgba(6, 182, 212, 0.06) 0%, transparent 40%),
        var(--bg-primary);
}

/* Header */
.chat-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-md);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo-small {
    font-size: 1.6rem;
    filter: drop-shadow(0 0 8px rgba(168, 85, 247, 0.5));
}

.username {
    font-weight: 700;
    font-size: 1rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.timer, .user-count {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: var(--bg-glass);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
}

.timer-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    min-width: 40px;
    color: var(--text-primary);
}

.timer.warning {
    border-color: var(--warning);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.timer.warning .timer-value {
    color: var(--warning);
}

.timer.danger {
    border-color: var(--error);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
    animation: pulse 1s infinite;
}

.timer.danger .timer-value {
    color: var(--error);
}

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

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--spacing-md);
    padding-top: calc(var(--header-height) + var(--spacing-md));
    padding-bottom: calc(var(--input-height) + var(--spacing-md));
    -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar */
.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Message Styles */
.message {
    margin-bottom: var(--spacing-md);
    max-width: 85%;
    animation: slideIn 0.3s ease-out;
}

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

.message.own {
    margin-left: auto;
}

.message-bubble {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm) var(--spacing-md);
}

.message.own .message-bubble {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.3) 0%, rgba(6, 182, 212, 0.2) 100%);
    border-color: rgba(168, 85, 247, 0.3);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: var(--spacing-xs);
    gap: var(--spacing-sm);
}

.message-username {
    font-weight: 700;
    font-size: 0.85rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.message.own .message-username {
    color: var(--accent-secondary);
    -webkit-text-fill-color: var(--accent-secondary);
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.message-content {
    font-size: 0.95rem;
    word-wrap: break-word;
    white-space: pre-wrap;
    color: var(--text-primary);
}

/* System Messages */
.system-message {
    text-align: center;
    margin: var(--spacing-md) 0;
    max-width: 100%;
}

.system-message-content {
    display: inline-block;
    background: var(--bg-glass);
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
}

/* Input Container */
.input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--input-height);
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    padding: var(--spacing-sm) var(--spacing-md);
    z-index: 100;
}

.message-form {
    display: flex;
    gap: var(--spacing-sm);
    height: 100%;
}

#message-input {
    flex: 1;
    height: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0 var(--spacing-md);
    font-size: 1rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    outline: none;
    transition: all 0.3s ease;
}

#message-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1);
}

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

.send-btn {
    min-width: 80px;
    height: 100%;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 0 var(--spacing-md);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--glow-purple);
}

.send-btn:hover {
    background: var(--accent-gradient-hover);
    transform: translateY(-1px);
    box-shadow: var(--glow-mixed);
}

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

.send-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: var(--spacing-lg);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    max-width: 360px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg), var(--glow-mixed);
    animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-icon {
    font-size: 56px;
    margin-bottom: var(--spacing-md);
}

.modal h2 {
    font-size: 1.4rem;
    margin-bottom: var(--spacing-sm);
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.modal-hint {
    font-size: 0.9rem;
    color: var(--accent-secondary) !important;
    font-weight: 500;
}

#warning-countdown {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--error) !important;
    -webkit-text-fill-color: var(--error) !important;
}

/* Responsive adjustments */
@media (max-width: 380px) {
    .username {
        max-width: 100px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .timer, .user-count {
        padding: 4px 8px;
        font-size: 0.8rem;
    }
}

/* Safe area insets for notched phones */
@supports (padding: max(0px)) {
    .chat-header {
        padding-top: max(0px, env(safe-area-inset-top));
        height: calc(var(--header-height) + max(0px, env(safe-area-inset-top)));
    }
    
    .input-container {
        padding-bottom: max(var(--spacing-sm), env(safe-area-inset-bottom));
        height: calc(var(--input-height) + max(0px, env(safe-area-inset-bottom)));
    }
    
    .messages-container {
        padding-top: calc(var(--header-height) + max(0px, env(safe-area-inset-top)) + var(--spacing-md));
        padding-bottom: calc(var(--input-height) + max(0px, env(safe-area-inset-bottom)) + var(--spacing-md));
    }
}

/* Selection color */
::selection {
    background: rgba(168, 85, 247, 0.3);
    color: var(--text-primary);
}
