/* Meta-Style CSS for AI Chat Interface */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Segoe UI Historic, Segoe UI, Helvetica, Arial, sans-serif;
    background: #ffffff;
    color: #050505;
    line-height: 1.34;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    margin: 0 auto;
    background: #ffffff;
    position: relative;
}

.header {
    background: #ffffff;
    border-bottom: 1px solid #e4e6eb;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    max-width: 900px;
    margin: 0 auto;
}

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

.avatar-wrapper {
    position: relative;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0084ff 0%, #44bff5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

.status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.status-indicator.online {
    background: #31a24c;
}

.header-info h1 {
    font-size: 17px;
    font-weight: 600;
    color: #050505;
    margin: 0;
}

.status-text {
    font-size: 13px;
    color: #65676b;
    font-weight: 400;
}

.device-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.device-selector label {
    font-size: 13px;
    color: #65676b;
}

.device-selector select {
    background: #f0f2f5;
    border: none;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    color: #050505;
    cursor: pointer;
    transition: background 0.2s ease;
    font-weight: 500;
}

.device-selector select:hover {
    background: #e4e6eb;
}

.btn-secondary {
    background: #f0f2f5;
    border: none;
    color: #050505;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    transition: background 0.2s ease;
}

.btn-secondary:hover {
    background: #e4e6eb;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    position: relative;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scroll-behavior: smooth;
    background: #ffffff;
}

.message {
    margin-bottom: 4px;
    display: flex;
    gap: 8px;
    animation: fadeIn 0.2s ease-out;
}

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

.assistant-message {
    justify-content: flex-start;
}

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

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 13px;
    color: #65676b;
}

.message-author {
    font-weight: 600;
    color: #050505;
}

.message-time {
    font-size: 12px;
    color: #8a8d91;
}

.message-content {
    padding: 8px 12px;
    border-radius: 18px;
    line-height: 1.4;
    word-wrap: break-word;
    font-size: 15px;
    max-width: 70%;
}

.assistant-message .message-content {
    background: #f0f2f5;
    color: #050505;
    border-radius: 18px 18px 18px 4px;
}

.user-message .message-content {
    background: #0084ff;
    color: #ffffff;
    border-radius: 18px 18px 4px 18px;
}

.welcome-message {
    padding: 20px 0;
}

strong {
    font-weight: 600;
}

em {
    font-style: italic;
}

code {
    background: #f0f2f5;
    padding: 2px 6px;
    border-radius: 6px;
    font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
    font-size: 13px;
    color: #050505;
}

.math-equation {
    background: #f0f2f5;
    padding: 2px 6px;
    border-radius: 6px;
    font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
    color: #0084ff;
    font-size: 14px;
}

.input-container {
    background: #ffffff;
    border-top: 1px solid #e4e6eb;
    padding: 8px 16px;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f0f2f5;
    border-radius: 20px;
    padding: 8px 8px 8px 16px;
    transition: background 0.2s ease;
}

.input-wrapper:focus-within {
    background: #e4e6eb;
}

.input-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e4e6eb;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #65676b;
    font-size: 16px;
    flex-shrink: 0;
    margin-bottom: 2px;
}

#message-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 15px;
    color: #050505;
    resize: none;
    font-family: inherit;
    line-height: 1.34;
    padding: 6px 0;
    max-height: 120px;
    overflow-y: auto;
}

#message-input::placeholder {
    color: #8a8d91;
}

.send-button {
    background: transparent;
    border: none;
    color: #0084ff;
    padding: 6px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    transition: opacity 0.2s ease;
    margin-bottom: 2px;
}

.send-button:hover:not(:disabled) {
    background: rgba(0, 132, 255, 0.1);
}

.send-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    background: #ffffff;
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
}

.loading-spinner i {
    font-size: 32px;
    color: #0084ff;
    margin-bottom: 12px;
    display: block;
}

.loading-spinner p {
    color: #65676b;
    font-size: 15px;
    font-weight: 400;
}

.status-bar {
    background: #f0f2f5;
    padding: 8px 16px;
    border-top: 1px solid #e4e6eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #65676b;
}

.status-bar #status-text {
    font-weight: 400;
}

#model-status {
    background: #e7f3ff;
    color: #0064d2;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.error-message {
    margin: 16px;
}

.system-message .message-content {
    background: #fff5f5;
    border: 1px solid #ffdddd;
    color: #d8000c;
    padding: 12px;
    border-radius: 8px;
    max-width: 100%;
}

.system-message i {
    color: #d8000c;
    margin-right: 8px;
}

/* Scrollbar Styling */
.messages-container::-webkit-scrollbar {
    width: 8px;
}

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

.messages-container::-webkit-scrollbar-thumb {
    background: #bcc0c4;
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: #8a8d91;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        padding: 12px;
    }

    .messages-container {
        padding: 12px;
    }

    .message-content {
        max-width: 85%;
    }

    .input-container {
        padding: 8px 12px;
    }

    .status-bar {
        flex-direction: column;
        gap: 4px;
        text-align: center;
        padding: 8px;
    }

    #message-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media (max-width: 480px) {
    .header-info h1 {
        font-size: 16px;
    }

    .device-selector {
        display: none;
    }

    .message-content {
        font-size: 14px;
        padding: 8px 10px;
    }

    .input-wrapper {
        padding: 6px 6px 6px 12px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body {
        background: #18191a;
        color: #e4e6eb;
    }
    
    .app-container {
        background: #18191a;
    }
    
    .header {
        background: #242526;
        border-bottom-color: #3a3b3c;
    }
    
    .header-info h1 {
        color: #e4e6eb;
    }
    
    .chat-container,
    .messages-container {
        background: #18191a;
    }
    
    .assistant-message .message-content {
        background: #3a3b3c;
        color: #e4e6eb;
    }
    
    .user-message .message-content {
        background: #0084ff;
        color: #ffffff;
    }
    
    .input-container {
        background: #242526;
        border-top-color: #3a3b3c;
    }
    
    .input-wrapper {
        background: #3a3b3c;
    }
    
    .input-wrapper:focus-within {
        background: #4a4b4c;
    }
    
    .input-avatar {
        background: #4a4b4c;
    }
    
    #message-input {
        color: #e4e6eb;
    }
    
    #message-input::placeholder {
        color: #8a8d91;
    }
    
    .device-selector select,
    .btn-secondary {
        background: #3a3b3c;
        color: #e4e6eb;
    }
    
    .device-selector select:hover,
    .btn-secondary:hover {
        background: #4a4b4c;
    }
    
    code,
    .math-equation {
        background: #3a3b3c;
        color: #e4e6eb;
    }
    
    .math-equation {
        color: #2d88ff;
    }
    
    .status-bar {
        background: #242526;
        border-top-color: #3a3b3c;
        color: #b0b3b8;
    }
    
    #model-status {
        background: #263951;
        color: #2d88ff;
    }
    
    .loading-overlay {
        background: rgba(24, 25, 26, 0.9);
    }
    
    .loading-spinner {
        background: #242526;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .message-content {
        border: 1px solid currentColor;
    }
    
    .input-wrapper {
        border: 1px solid currentColor;
    }
}

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