/* Mobile Chat Interface CSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #0f0f23 0%, #1e1e3f 50%, #2d1b69 100%);
    color: #e2e8f0;
    height: 100vh;
    display: flex;
    flex-direction: column;
	height: 100vh;
    margin: 0;
    overflow: hidden;
}

/* Mobile Header */
.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(15, 15, 35, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(168, 85, 247, 0.3);
    position: sticky;
	top: 0;
    z-index: 100;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(15, 15, 35, 0.8);
    padding: 8px 12px;
    border-radius: 12px;
    border: 2px solid transparent;
    background-clip: padding-box;
    position: relative;
}

.header-logo::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(135deg, #a855f7, #7c3aed, #ec4899, #06b6d4);
    border-radius: 12px;
    z-index: -1;
    animation: borderGlow 3s ease-in-out infinite alternate;
}

@keyframes borderGlow {
    0% { background: linear-gradient(135deg, #a855f7, #7c3aed, #ec4899, #06b6d4); }
    50% { background: linear-gradient(135deg, #ec4899, #06b6d4, #a855f7, #7c3aed); }
    100% { background: linear-gradient(135deg, #06b6d4, #a855f7, #7c3aed, #ec4899); }
}

.ai-avatar {
    font-size: 28px;
    background: rgba(15, 15, 35, 0.9);
    padding: 6px;
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
    position: relative;
}

.ai-avatar::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(135deg, #a855f7, #7c3aed, #ec4899, #06b6d4);
    border-radius: 8px;
    z-index: -1;
    animation: borderGlow 3s ease-in-out infinite alternate;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.ai-name {
    font-size: 18px;
    font-weight: bold;
    color: #a855f7;
    position: relative;
    z-index: 10;
    display: inline-block;
}

.ai-mode {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
}

.header-status {
    flex: 1;
    display: flex;
    justify-content: center;
}

.status-indicator {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.header-menu {
    display: flex;
    align-items: center;
}

.menu-btn {
    background: rgba(15, 15, 35, 0.8);
    border: 1px solid rgba(168, 85, 247, 0.3);
    color: #e2e8f0;
    padding: 8px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.menu-btn:hover {
    background: rgba(168, 85, 247, 0.2);
    border-color: rgba(168, 85, 247, 0.5);
}

/* Mobile Menu */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 300px;
    max-height: 100vh;
    background: rgba(15, 15, 35, 0.95);
    backdrop-filter: blur(20px);
    border-left: 1px solid rgba(168, 85, 247, 0.3);
    z-index: 300;
    overflow-y: scroll;
    overflow-x: hidden;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.mobile-menu.active {
    right: 0;
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid rgba(168, 85, 247, 0.3);
    flex-shrink: 0;
}

.menu-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 40px;
}

.menu-header h3 {
    color: #a855f7;
    font-size: 18px;
}

.menu-close {
    background: none;
    border: none;
    color: #e2e8f0;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.menu-close:hover {
    background: rgba(239, 68, 68, 0.2);
}

.menu-section {
    padding: 16px;
    border-bottom: 1px solid rgba(168, 85, 247, 0.1);
}

.menu-section:last-child {
    padding-bottom: 30px;
    margin-bottom: 20px;
}

.menu-section h4 {
    color: #e2e8f0;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.stat-item {
    background: rgba(168, 85, 247, 0.1);
    padding: 8px;
    border-radius: 6px;
    border: 1px solid rgba(168, 85, 247, 0.2);
}

.stat-label {
    display: block;
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 14px;
    font-weight: bold;
    color: #a855f7;
}

/* Voice Settings */
.voice-settings {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
}

.setting-row label {
    font-size: 12px;
    color: #94a3b8;
    min-width: 60px;
}

.voice-dropdown, .timeout-dropdown {
    background: rgba(15, 15, 35, 0.8);
    border: 1px solid rgba(168, 85, 247, 0.3);
    color: #e2e8f0;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    flex: 1;
}

.speed-slider, .pitch-slider, .volume-slider {
    flex: 1;
    margin: 0 8px;
}

input[type="range"] {
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: rgba(168, 85, 247, 0.3);
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #a855f7;
    cursor: pointer;
    border: 2px solid #e2e8f0;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #a855f7;
    cursor: pointer;
    border: 2px solid #e2e8f0;
}

.voice-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12px;
}

.toggle-slider {
    position: relative;
    width: 36px;
    height: 20px;
    background: rgba(148, 163, 184, 0.3);
    border-radius: 10px;
    transition: background 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #e2e8f0;
    top: 2px;
    left: 2px;
    transition: transform 0.3s ease;
}

input[type="checkbox"]:checked + .toggle-slider {
    background: #a855f7;
}

input[type="checkbox"]:checked + .toggle-slider::before {
    transform: translateX(16px);
}

input[type="checkbox"] {
    display: none;
}

.btn-test-voice {
    background: rgba(168, 85, 247, 0.2);
    border: 1px solid rgba(168, 85, 247, 0.3);
    color: #a855f7;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.btn-test-voice:hover {
    background: rgba(168, 85, 247, 0.3);
}

.menu-action-btn {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #3b82f6;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-bottom: 8px;
}

.menu-action-btn:hover {
    background: rgba(59, 130, 246, 0.3);
}

/* Main Chat Container */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: 0;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 16px;
    scroll-behavior: smooth;
}

/* Welcome Message */
.welcome-message {
    margin-bottom: 20px;
}

.welcome-content {
    background: rgba(15, 15, 35, 0.8);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.zin-intro h2 {
    color: #a855f7;
    margin-bottom: 12px;
    font-size: 20px;
}

.zin-intro p {
    color: #e2e8f0;
    line-height: 1.5;
    margin-bottom: 20px;
}

.quick-actions h3 {
    color: #e2e8f0;
    margin-bottom: 12px;
    font-size: 16px;
}

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 20px;
}

.quick-btn {
    background: rgba(168, 85, 247, 0.2);
    border: 1px solid rgba(168, 85, 247, 0.3);
    color: #a855f7;
    padding: 12px 8px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.quick-btn:hover {
    background: rgba(168, 85, 247, 0.3);
    transform: translateY(-1px);
}

.team-section {
    background: rgba(168, 85, 247, 0.1);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid rgba(168, 85, 247, 0.2);
}

.team-section h3 {
    color: #a855f7;
    margin-bottom: 8px;
    font-size: 16px;
}

.team-section p {
    color: #94a3b8;
    font-size: 12px;
    margin-bottom: 12px;
}

.team-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.team-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 15, 35, 0.6);
    padding: 8px;
    border-radius: 6px;
    border: 1px solid rgba(168, 85, 247, 0.2);
}

.team-icon {
    font-size: 16px;
}

.team-name {
    font-size: 11px;
    color: #e2e8f0;
    font-weight: 500;
}

/* Chat Messages */
.message {
    margin-bottom: 16px;
    animation: slideIn 0.3s ease;
}

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

.message-content {
    background: rgba(15, 15, 35, 0.8);
    padding: 12px 16px;
    border-radius: 16px;
    border: 1px solid rgba(168, 85, 247, 0.3);
    margin-bottom: 4px;
    line-height: 1.5;
}

.user-message .message-content {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.3);
    margin-left: 20px;
}

.ai-message .message-content {
    background: rgba(168, 85, 247, 0.2);
    border-color: rgba(168, 85, 247, 0.3);
    margin-right: 20px;
}

.message-time {
    font-size: 10px;
    color: #64748b;
    text-align: right;
    padding: 0 16px;
}

.user-message .message-time {
    text-align: right;
}

.ai-message .message-time {
    text-align: left;
}

/* Input Section */
.input-section {
    background: rgba(15, 15, 35, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(168, 85, 247, 0.3);
    padding: 16px;
	position: sticky;
    bottom: 0;
    z-index: 100;
}

.input-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 15, 35, 0.8);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 24px;
    padding: 8px;
}

#messageInput {
    flex: 1;
    background: none;
    border: none;
    color: #e2e8f0;
    font-size: 16px;
    padding: 8px 12px;
    outline: none;
    min-height: 20px;
    resize: none;
}

#messageInput::placeholder {
    color: #64748b;
}

.btn-voice, .btn-send {
    background: rgba(168, 85, 247, 0.2);
    border: 1px solid rgba(168, 85, 247, 0.3);
    color: #a855f7;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-voice:hover, .btn-send:hover {
    background: rgba(168, 85, 247, 0.3);
    transform: scale(1.05);
}

.btn-voice.listening {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.5);
    color: #ef4444;
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* Voice Indicator */
.voice-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 15, 35, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    z-index: 400;
    min-width: 280px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.voice-indicator.hidden {
    display: none;
}

.voice-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-animation {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(168, 85, 247, 0.3);
    border-top: 3px solid #a855f7;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.voice-indicator p {
    color: #e2e8f0;
    margin-bottom: 8px;
    font-weight: 600;
}

.voice-status {
    color: #94a3b8;
    font-size: 12px;
}

/* Connection Status (hidden elements for JS compatibility) */
.connection-status {
    display: none;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    margin-left: 4px;
}

.status-dot.connected {
    background: #22c55e;
}

/* Responsive Design */
@media (max-width: 400px) {
    .mobile-header {
        padding: 8px 12px;
    }
    
    .header-logo {
        gap: 8px;
        padding: 6px 8px;
    }
    
    .ai-avatar {
        font-size: 24px;
        padding: 4px;
    }
    
    .ai-name {
        font-size: 16px;
    }
    
    .mobile-menu {
        width: 280px;
    }
    
    .action-buttons {
        grid-template-columns: 1fr;
    }
    
    .team-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Message text formatting */
.message-text {
    margin-top: 0.5rem;
    line-height: 1.6;
}

.message-text p {
    margin: 0.3rem 0; /* Tighter paragraph spacing for mobile */
}

.message-text p:last-child {
    margin-bottom: 0;
}

/* List formatting - mobile optimized */
.list-item {
    margin: 0.2rem 0; /* Tighter spacing for mobile */
    display: flex;
    align-items: flex-start;
    line-height: 1.4;
}

.list-item.numbered-item {
    margin-left: 0.5rem;
}

.list-item.bullet-item {
    margin-left: 0.5rem;
}

/* Style for sub-list items (+ items) */
.list-item.sub-item {
    margin-left: 1.5rem; /* Slightly less indent for mobile */
    margin-top: 0.1rem;
    margin-bottom: 0.1rem;
    font-size: 0.9em;
    color: #94a3b8; /* Slightly muted color for sub-items */
}

.list-number {
    color: #60a5fa;
    font-weight: 600;
    margin-right: 0.25rem; /* Tighter spacing */
    min-width: 1.5rem; /* Smaller for mobile */
    flex-shrink: 0;
}

.bullet {
    color: #60a5fa;
    font-weight: bold;
    margin-right: 0.25rem; /* Tighter spacing */
    flex-shrink: 0;
}

/* Thinking animation for mobile */
.thinking-animation {
    width: 40px; /* Slightly smaller for mobile */
    height: 40px;
    border: 2px solid transparent;
    border-radius: 50%;
    margin: 0 0 0.8rem 0;
    background: linear-gradient(135deg, #a855f7, #06b6d4) padding-box, 
                linear-gradient(135deg, #7c3aed, #ec4899, #06b6d4) border-box;
    animation: thinkingPulse 1.2s ease-in-out infinite;
}

@keyframes thinkingPulse {
    0%, 100% { 
        transform: scale(1);
        opacity: 0.7;
    }
    50% { 
        transform: scale(1.1);
        opacity: 1;
    }
}

.thinking-container {
    display: flex;
    align-items: center;
    padding: 0.8rem; /* Slightly less padding for mobile */
}

.thinking-text {
    margin-left: 0.8rem;
    color: #94a3b8;
    font-style: italic;
    font-size: 0.85rem; /* Slightly smaller for mobile */
}

/* Dark mode optimizations */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 50%, #16213e 100%);
    }
}

/* ========================================
   Threshold Meter Styles 
   ======================================== */
.threshold-meter {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(168, 85, 247, 0.6);
    border-radius: 4px;
    margin: 12px 0 8px 0;
    overflow: hidden;
    position: relative;
    display: block !important;
    visibility: visible !important;
    min-width: 200px;
}

.threshold-bar {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    transition: width 0.3s ease;
    background: linear-gradient(90deg, 
        #00ff88 0%,     /* Green start */
        #00ccff 25%,    /* Blue */
        #6644ff 50%,    /* Purple */
        #ff44e9 75%,    /* Pink */
        #d300ff 100%    /* Magenta end */
    );
}

.threshold-bar.threshold-warning {
    background: linear-gradient(90deg, #f59e0b, #f97316);
    animation: pulsateWarning 2s ease-in-out infinite;
}

.threshold-bar.threshold-critical {
    background: linear-gradient(90deg, #ef4444, #dc2626);
    animation: pulsateCritical 1s ease-in-out infinite;
}

@keyframes pulsateWarning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes pulsateCritical {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Mobile threshold meter tooltip */
.threshold-meter::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    white-space: nowrap;
    margin-bottom: 4px;
}

.threshold-meter:hover::after {
    opacity: 1;
}

/* Memory Limit Notification */
.memory-limit-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    background: rgba(15, 15, 35, 0.98);
    border: 2px solid rgba(168, 85, 247, 0.6);
    border-radius: 16px;
    padding: 24px;
    max-width: 90vw;
    width: 400px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

.memory-limit-content h4 {
    color: #ef4444;
    margin: 0 0 12px 0;
    font-size: 1.2rem;
    text-align: center;
}

.memory-limit-content p {
    color: rgba(255, 255, 255, 0.8);
    margin: 0 0 20px 0;
    text-align: center;
    font-size: 0.9rem;
}

.memory-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.memory-btn {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.8), rgba(139, 92, 246, 0.6));
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 12px;
    color: white;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.memory-btn:hover {
    background: linear-gradient(135deg, rgba(168, 85, 247, 1), rgba(139, 92, 246, 0.8));
    transform: translateY(-2px);
}

.memory-btn small {
    font-size: 0.8rem;
    opacity: 0.8;
}

.compress-btn {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.8), rgba(34, 197, 94, 0.6));
    border-color: rgba(16, 185, 129, 0.3);
}

.compress-btn:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, 1), rgba(34, 197, 94, 0.8));
}

.full-refresh-btn {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.8), rgba(37, 99, 235, 0.6));
    border-color: rgba(59, 130, 246, 0.3);
}

.full-refresh-btn:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 1), rgba(37, 99, 235, 0.8));
}

.partial-refresh-btn {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.8), rgba(217, 119, 6, 0.6));
    border-color: rgba(245, 158, 11, 0.3);
}

.partial-refresh-btn:hover {
    background: linear-gradient(135deg, rgba(245, 158, 11, 1), rgba(217, 119, 6, 0.8));
}

.memory-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.2rem;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.memory-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}