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

:root {
    --primary-color: #10b981;
    --primary-dark: #059669;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #475569;
    --shadow: rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 100%;
    margin: 0 auto;
}

/* Header */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px var(--shadow);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.logo-icon {
    font-size: 1.5rem;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: pulse 2s ease-in-out infinite;
}

.status-dot.online {
    background: var(--primary-color);
}

.status-dot.offline {
    background: #ef4444;
}

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

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 1rem;
}

/* Messages */
.message {
    display: flex;
    gap: 0.75rem;
    animation: slideIn 0.3s ease-out;
}

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

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--primary-color);
}

.message-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.message.user .message-content {
    align-items: flex-end;
}

.message-text {
    background: var(--surface);
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    word-wrap: break-word;
    line-height: 1.5;
}

.message.user .message-text {
    background: var(--primary-color);
    border-radius: 1rem 1rem 0 1rem;
}

.message.assistant .message-text {
    border-radius: 1rem 1rem 1rem 0;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 0 0.5rem;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 0.75rem;
    padding: 0 1rem;
}

.typing-indicator::before {
    content: "🌱";
    font-size: 1.25rem;
}

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

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Container */
.input-container {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 1rem;
    position: sticky;
    bottom: 0;
    box-shadow: 0 -2px 10px var(--shadow);
}

.input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.voice-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--surface-light);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.voice-button:hover {
    background: var(--primary-color);
}

.voice-button:active {
    transform: scale(0.95);
}

.voice-button.recording {
    background: #ef4444;
    animation: recordPulse 1s ease-in-out infinite;
}

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

.message-input {
    flex: 1;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.message-input:focus {
    border-color: var(--primary-color);
}

.send-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.send-button:hover {
    background: var(--primary-dark);
}

.send-button:active {
    transform: scale(0.95);
}

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

/* Install Prompt */
.install-prompt {
    position: fixed;
    bottom: 80px;
    left: 1rem;
    right: 1rem;
    background: var(--surface);
    border: 1px solid var(--primary-color);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 4px 20px var(--shadow);
    z-index: 1000;
    animation: slideUp 0.3s ease-out;
}

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

.install-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.install-icon {
    font-size: 1.5rem;
}

.install-text {
    flex: 1;
    font-size: 0.875rem;
    line-height: 1.4;
}

.install-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--surface);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Responsive */
@media (min-width: 768px) {
    .app-container {
        max-width: 600px;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
}

/* iOS Safe Area */
@supports (padding: max(0px)) {
    .app-header {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
    
    .input-container {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

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

.chat-container::-webkit-scrollbar-track {
    background: var(--background);
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--border);
}
