/* style.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.app-container {
    max-width: 800px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
    gap: 1rem;
}

.header h1 {
    color: #4a5568;
    font-size: 1.8rem;
    font-weight: 700;
}

.anycoder-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.anycoder-link:hover {
    color: #5a67d8;
    text-decoration: underline;
}

.device-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    border: 2px solid #e2e8f0;
    font-size: 0.9rem;
}

.device-selector label {
    font-weight: 500;
    color: #4a5568;
}

.device-selector select {
    background: none;
    border: none;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    padding: 1rem 2rem 2rem;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: calc(100vh - 200px);
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 transparent;
}

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

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

.chat-container::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.message {
    max-width: 80%;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    border-radius: 18px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.3s ease-out;
}

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.assistant-message {
    background: white;
    border: 1px solid #e2e8f0;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.system-message {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    text-align: center;
    max-width: 100%;
    font-style: italic;
    color: #718096;
}

.message.info {
    background: #bee3f8;
    border-color: #90cdf4;
    color: #2b6cb0;
}

.message-content {
    line-height: 1.6;
    word-wrap: break-word;
}

.message-content strong {
    font-weight: 600;
}

.input-container {
    padding-bottom: 2rem;
    position: relative;
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    background: white;
    padding: 1rem;
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 2px solid #e2e8f0;
    transition: all 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: #667eea;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
}

#message-input {
    flex: 1;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    resize: none;
    max-height: 120px;
    background: transparent;
    color: #2d3748;
}

#message-input::placeholder {
    color: #a0aec0;
}

.send-button {
    width: 44px;
    height: 44px;
    border: none;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.send-button svg {
    width: 20px;
    height: 20px;
}

.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    color: #667eea;
    font-weight: 500;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.hidden {
    display: none !important;
}

.error-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #f56565;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(245, 101, 101, 0.4);
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
    max-width: 350px;
}

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

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

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

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding: 1rem;
    }

    .header h1 {
        text-align: center;
        font-size: 1.5rem;
    }

    .device-selector {
        justify-content: center;
    }

    .main-content {
        padding: 1rem;
    }

    .message {
        max-width: 95%;
        padding: 0.75rem 1.25rem;
    }

    .input-wrapper {
        padding: 0.75rem;
    }

    .error-toast {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.3rem;
    }
    
    .message-content {
        font-size: 0.95rem;
    }
}

/* Focus styles for accessibility */
#message-input:focus,
.send-button:focus,
.device-selector select:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .message {
        border-width: 2px;
    }
    
    .input-wrapper {
        border-width: 3px;
    }
}

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