:root {
    /* Color Palette: Deep Midnight Void */
    --bg-main: #09090B;
    --bg-surface: rgba(24, 24, 27, 0.6);
    --bg-surface-solid: #18181B;
    
    --text-primary: #FAFAFA;
    --text-secondary: #A1A1AA;
    --text-muted: #52525B;
    
    --accent-primary: #3B82F6;
    --accent-hover: #2563EB;
    
    --status-success: #10B981;
    --status-success-bg: rgba(16, 185, 129, 0.1);
    --status-error: #EF4444;
    --status-error-bg: rgba(239, 68, 68, 0.1);
    
    --border-color: rgba(255, 255, 255, 0.08);
    --glass-blur: blur(12px);
    
    /* Typography */
    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'Fira Code', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-ui);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    position: relative;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
    background-color: #0c0c0e;
}

/* Header */
.glass-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-wrapper {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-primary);
    padding: 8px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.shield-icon {
    width: 20px;
    height: 20px;
}

.app-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.app-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.stats-badge {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.live-dot {
    width: 8px;
    height: 8px;
    background-color: var(--status-success);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--status-success);
    animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.5; }
}

/* Chat Area */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 100px 24px 100px 24px; /* Space for header & footer */
    display: flex;
    flex-direction: column;
    gap: 24px;
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) transparent;
}

.chat-area::-webkit-scrollbar {
    width: 6px;
}

.chat-area::-webkit-scrollbar-thumb {
    background-color: var(--text-muted);
    border-radius: 10px;
}

/* Messages */
.message-wrapper {
    display: flex;
    width: 100%;
    animation: messageSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.message-wrapper.user {
    justify-content: flex-end;
}

.message-wrapper.system {
    justify-content: flex-start;
}

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

.message {
    max-width: 85%;
    padding: 16px;
    border-radius: 16px;
    font-size: 16px;
    position: relative;
}

/* User Message */
.message.user {
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-color);
    border-bottom-right-radius: 4px;
    color: var(--text-primary);
}

.message.user .message-body {
    font-family: var(--font-mono);
    font-size: 16px;
    letter-spacing: 0.5px;
    color: var(--accent-primary);
}

/* Bot Message */
.message.bot {
    background: rgba(24, 24, 27, 0.4);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.message.bot.intro-message {
    border-left: 2px solid var(--accent-primary);
}

.message.bot.success {
    background: var(--status-success-bg);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-left: 2px solid var(--status-success);
}

.message.bot.error {
    background: var(--status-error-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-left: 2px solid var(--status-error);
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.bot-icon {
    width: 14px;
    height: 14px;
}

.timestamp {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
}

.message-body {
    line-height: 1.7;
}

.message-body strong, .message-body .mono {
    font-family: var(--font-mono);
    background: rgba(255,255,255,0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.message.bot.success .mono { color: var(--status-success); }
.message.bot.error .mono { color: var(--status-error); }

/* Shake Animation */
@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Copy Badge Styles */
.copy-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--accent-primary);
    padding: 2px 8px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    vertical-align: middle;
}
.copy-badge:hover {
    background: rgba(59, 130, 246, 0.25);
    transform: translateY(-1px);
}
.inline-icon {
    width: 14px;
    height: 14px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.dot {
    width: 4px;
    height: 4px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Input Area */
.glass-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-main);
    border-top: 1px solid var(--border-color);
    padding: 16px 24px 24px 24px;
}

.input-form {
    display: flex;
    gap: 12px;
}

.input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    width: 18px;
    height: 18px;
    pointer-events: none;
}

#ipInput {
    width: 100%;
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 18px 16px 48px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 16px;
    outline: none;
    transition: all 0.2s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

#ipInput::placeholder {
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 14px;
}

#ipInput:focus {
    border-color: rgba(59, 130, 246, 0.5);
    background: rgba(24, 24, 27, 0.8);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1), inset 0 2px 4px rgba(0,0,0,0.1);
}

.send-btn {
    background: var(--text-primary);
    color: var(--bg-main);
    border: none;
    border-radius: 12px;
    width: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.send-btn:hover {
    background: #E4E4E7;
    transform: translateY(-1px);
}

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

.send-btn i {
    width: 20px;
    height: 20px;
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 90px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 50;
}

.toast {
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.error {
    border-left: 3px solid var(--status-error);
}

.toast.success {
    border-left: 3px solid var(--status-success);
}

.toast i {
    width: 16px;
    height: 16px;
}

.toast.error i {
    color: var(--status-error);
}

.toast.success i {
    color: var(--status-success);
}

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastFadeOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .glass-header {
        padding: 12px 16px;
    }
    .chat-area {
        padding: 80px 16px 90px 16px;
    }
    .glass-footer {
        padding: 12px 16px 16px 16px;
    }
    .message {
        max-width: 90%;
    }
    #ipInput {
        font-size: 16px; /* Prevents iOS zoom */
    }
}


/* ==========================================
   AUTHENTICATION UI
   ========================================== */

.hidden {
    display: none !important;
}

.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: var(--bg-main);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    padding: 24px;
}

.auth-card {
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-color);
    padding: 40px;
    border-radius: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    animation: messageSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header .icon-wrapper.large {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    border-radius: 16px;
}

.auth-header .icon-wrapper.large i {
    width: 32px;
    height: 32px;
}

.auth-header h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-group .input-icon {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    width: 20px;
    height: 20px;
    pointer-events: none;
}

.input-group input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 16px 16px 48px;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 16px;
    outline: none;
    transition: all 0.2s ease;
}

.input-group input:focus {
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

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

.primary-btn {
    background: var(--text-primary);
    color: var(--bg-main);
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.primary-btn:hover {
    background: #E4E4E7;
    transform: translateY(-1px);
}

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

.primary-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.text-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    padding: 8px;
    transition: color 0.2s ease;
}

.text-btn:hover {
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.icon-btn i {
    width: 16px;
    height: 16px;
}