/* ==================== RESET & BASE ==================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #075e54;
    --primary-dark: #054d44;
    --secondary: #25d366;
    --bg-chat: #e5ddd5;
    --bg-pattern: #d4cdc4;
    --bubble-user: #dcf8c6;
    --bubble-bot: #ffffff;
    --text-primary: #111b21;
    --text-secondary: #667781;
    --border-color: #e9edef;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 16px;
    color: var(--text-primary);
    background: var(--primary);
}

#app {
    height: 100%;
    max-width: 600px;
    margin: 0 auto;
    background: white;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 30px rgba(0,0,0,0.3);
    position: relative;
}

/* ==================== SCREENS ==================== */
.screen {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* ==================== PWA INSTALL BANNER ==================== */
.install-banner,
.notification-banner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    z-index: 200;
    animation: slideDown 0.3s ease;
}

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

.install-content,
.notification-content {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
}

.install-icon,
.notification-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.install-text,
.notification-text {
    flex: 1;
}

.install-text strong,
.notification-text strong {
    display: block;
    font-size: 15px;
    margin-bottom: 2px;
}

.install-text p,
.notification-text p {
    font-size: 13px;
    opacity: 0.9;
    margin: 0;
}

.install-btn,
.notification-btn {
    background: white;
    color: #667eea;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.1s;
}

.install-btn:active,
.notification-btn:active {
    transform: scale(0.95);
}

.install-dismiss,
.notification-dismiss {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    opacity: 0.7;
    flex-shrink: 0;
}

.install-dismiss:hover,
.notification-dismiss:hover {
    opacity: 1;
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 90%;
    text-align: center;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ==================== REGISTER SCREEN ==================== */
#register-screen {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.register-container {
    background: white;
    border-radius: 20px;
    padding: 40px 30px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.register-logo {
    font-size: 64px;
    margin-bottom: 10px;
}

.register-container h1 {
    font-size: 28px;
    color: var(--primary);
    margin-bottom: 5px;
}

.register-subtitle {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.2);
}

.btn-primary {
    width: 100%;
    padding: 16px;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover {
    background: #22c55e;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-arrow {
    transition: transform 0.2s;
}

.btn-primary:hover .btn-arrow {
    transform: translateX(4px);
}

.disclaimer {
    margin-top: 24px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Loading spinner */
.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==================== CHAT HEADER ==================== */
.chat-header {
    background: var(--primary);
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.avatar {
    width: 44px;
    height: 44px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.header-info h1 {
    font-size: 17px;
    font-weight: 600;
}

.header-info p {
    font-size: 13px;
    opacity: 0.9;
}

.icon-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.1);
}

.header-right {
    display: flex;
    gap: 4px;
}

/* ==================== MENU DROPDOWN ==================== */
.menu-dropdown {
    position: absolute;
    top: 60px;
    right: 10px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    overflow: hidden;
    z-index: 100;
    min-width: 200px;
}

.menu-section {
    padding: 12px 16px;
}

.menu-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.language-selector {
    display: flex;
    gap: 8px;
}

.lang-btn {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-btn:hover {
    border-color: var(--secondary);
}

.lang-btn.active {
    background: var(--secondary);
    border-color: var(--secondary);
    color: white;
}

.menu-divider {
    height: 1px;
    background: var(--border-color);
}

.menu-dropdown button:not(.lang-btn) {
    display: block;
    width: 100%;
    padding: 14px 20px;
    border: none;
    background: none;
    text-align: left;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.menu-dropdown button:not(.lang-btn):hover {
    background: var(--border-color);
}

.menu-install-btn {
    color: #667eea;
    font-weight: 500;
}

/* ==================== CHAT MESSAGES ==================== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-chat);
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.message {
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
    animation: fadeIn 0.3s ease;
}

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

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

.message.bot {
    align-items: flex-start;
}

.message-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
    box-shadow: var(--shadow);
}

.message.user .message-bubble {
    background: var(--bubble-user);
    border-bottom-right-radius: 4px;
}

.message.bot .message-bubble {
    background: var(--bubble-bot);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    padding: 0 4px;
}

/* Welcome message */
.welcome-message {
    text-align: center;
    padding: 20px;
    margin-bottom: 16px;
}

.welcome-message .avatar {
    width: 80px;
    height: 80px;
    font-size: 40px;
    margin: 0 auto 16px;
}

.welcome-message h2 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.welcome-message p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ==================== TYPING INDICATOR ==================== */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--bg-chat);
}

.typing-bubble {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bubble-bot);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow);
}

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

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

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

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

.typing-indicator p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ==================== CHAT INPUT ==================== */
.chat-input {
    background: #f0f2f5;
    padding: 10px 16px;
    flex-shrink: 0;
}

.chat-input form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input input {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 24px;
    font-size: 16px;
    background: white;
    outline: none;
}

.chat-input input::placeholder {
    color: var(--text-secondary);
}

#send-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: var(--secondary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, background 0.2s;
    flex-shrink: 0;
}

#send-btn:hover {
    background: #22c55e;
}

#send-btn:active {
    transform: scale(0.9);
}

#send-btn:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 600px) {
    #app {
        max-width: 100%;
        box-shadow: none;
    }
}

/* Desktop centering */
@media (min-width: 601px) {
    body {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px;
    }
    
    #app {
        height: 90vh;
        max-height: 800px;
        border-radius: 16px;
        overflow: hidden;
    }
}

/* ==================== SCROLLBAR ==================== */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 3px;
}

/* ==================== LOADING STATE ==================== */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* ==================== DATE DIVIDER ==================== */
.date-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 16px 0;
}

.date-divider span {
    background: rgba(225, 218, 208, 0.9);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    box-shadow: var(--shadow);
}

/* ==================== iOS SAFE AREAS ==================== */
@supports (padding-top: env(safe-area-inset-top)) {
    .chat-header {
        padding-top: calc(12px + env(safe-area-inset-top));
    }
    
    .chat-input {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
}
