:root {
    --bg-primary: linear-gradient(135deg, #ffffff 0%, #f8fafc 25%, #f1f5f9 50%, #e2e8f0 75%, #cbd5e1 100%);
    --bg-secondary: linear-gradient(135deg, #ffffff 0%, #f8fafc 50%, #f1f5f9 100%);
    --bg-card: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.9) 100%);
    --bg-input: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --accent: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --accent-hover: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
    --border: rgba(226, 232, 240, 0.6);
    --border-focus: rgba(102, 126, 234, 0.4);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --error: #e53e3e;
    --success: #38a169;
}

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

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Login Page Styles */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--bg-primary);
}

.login-container {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2rem;
    max-width: 800px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin: 0 auto;
}

.login-header {
    text-align: center;
}

.login-logo {
    font-size: 3rem;
    font-weight: 700;
    background: var(--accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

.login-tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.login-form-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    width: 100%;
    max-width: 400px;
    margin: 2rem auto 0;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.phone-input-container {
    display: flex;
    gap: 0.5rem;
}

.country-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.875rem;
    font-size: 0.85rem;
    color: var(--text-primary);
    min-width: 120px;
    max-width: 140px;
    transition: all 0.2s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.country-select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

input[type="tel"], input[type="text"] {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.875rem 1rem;
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

input[type="tel"]:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.login-btn {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

.login-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.sms-instructions {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 2rem;
    border: 1px solid var(--border);
}

.sms-instructions h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.sms-instructions p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Main App Styles */
.main-app {
    min-height: 100vh;
    background: var(--bg-primary);
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.header {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow);
    text-align: center;
    position: relative;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.logo {
    font-size: 2rem;
    font-weight: 700;
    background: var(--accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.user-info {
    position: absolute;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.stats {
    background: var(--bg-secondary);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 500;
    border: 1px solid var(--border);
}



.logout-btn {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.logout-btn:hover {
    background: linear-gradient(135deg, #c53030 0%, #9c2626 100%);
    transform: translateY(-1px);
}

.main-content {
    padding: 2rem;
}

.chat-section {
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    backdrop-filter: blur(10px);
    max-width: 800px;
    margin: 0 auto;
}

.chat-messages {
    height: 500px;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--bg-secondary);
}

.system-message {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2rem;
    border: 1px solid var(--border);
    text-align: center;
    backdrop-filter: blur(10px);
}

.system-message h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.command-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.command-card {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    text-align: center;
    font-size: 0.9rem;
}

.message-bubble {
    max-width: 70%;
    padding: 1rem 1.5rem;
    border-radius: 20px;
    margin-bottom: 0.5rem;
    word-wrap: break-word;
    backdrop-filter: blur(10px);
}

.message-bubble.user {
    background: var(--accent);
    color: white;
    align-self: flex-end;
    margin-left: auto;
}

.message-bubble.assistant {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    align-self: flex-start;
}

.message-bubble.system {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    align-self: center;
    max-width: 90%;
    text-align: center;
    font-size: 0.9rem;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 0.5rem;
}

.input-section {
    padding: 2rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-container {
    display: flex;
    gap: 1rem;
    align-items: center;
}

#messageInput {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 25px;
    padding: 0.875rem 1.5rem;
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

#messageInput:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.send-btn {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 0.875rem 2rem;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

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

.input-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
}

.payment-link {
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-container {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.modal-header h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-primary);
}

.payment-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.payment-info {
    text-align: center;
}

.price-tag {
    font-size: 2rem;
    font-weight: 700;
    background: var(--accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

.card-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    transition: all 0.2s ease;
}

.card-input:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.primary-btn {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.primary-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.full-width {
    width: 100%;
}

.error-message {
    color: var(--error);
    font-size: 0.875rem;
    text-align: center;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

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

.loading-content {
    text-align: center;
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Error Toast */
.error-toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: var(--error);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 3000;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
}

.error-toast button {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .login-container {
        padding: 1.5rem;
        margin: 1rem;
    }

    .login-form-container {
        max-width: none;
    }

    .phone-input-container {
        flex-direction: column;
        gap: 0.75rem;
    }

    .country-select {
        min-width: auto;
        max-width: none;
    }

    .header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .header-left {
        order: 1;
    }

    .user-info {
        position: static;
        transform: none;
        order: 2;
        flex-wrap: wrap;
        justify-content: center;
    }

    .input-container {
        flex-direction: column;
    }

    .command-grid {
        grid-template-columns: 1fr;
    }

    .chat-messages {
        height: 400px;
    }

    .main-content {
        padding: 1rem;
    }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-input);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}