/* ============================================================================
   B-Agentic Concierge Demo - Styles
   ============================================================================ */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.screen {
    display: none;
    height: 100%;
}

.screen.active {
    display: flex;
}

/* ============================================================================
   Login Screen
   ============================================================================ */

#login-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a1a2e 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
}

.logo {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.login-card h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.login-card .subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-google {
    background: #fff;
    color: #333;
}

.btn-google:hover {
    background: #f1f1f1;
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

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

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
}

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

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    width: auto;
}

.divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider span {
    padding: 0 1rem;
}

#email-login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

input[type="email"],
input[type="password"],
input[type="text"] {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
}

input::placeholder {
    color: var(--text-muted);
}

.terms {
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

.terms a {
    color: var(--primary-light);
    text-decoration: none;
}

.features {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 2rem;
}

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

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

/* ============================================================================
   OAuth Screen
   ============================================================================ */

#oauth-screen {
    justify-content: center;
    align-items: center;
}

.oauth-container {
    text-align: center;
}

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

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

/* ============================================================================
   Chat Screen
   ============================================================================ */

#chat-screen {
    flex-direction: column;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

.header-left h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
    background: var(--bg-input);
}

.status .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
}

.status.connected .dot {
    background: var(--secondary);
}

.status .text {
    color: var(--text-secondary);
}

#user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: none;
}

#user-name {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

.banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(90deg, var(--primary) 0%, #8b5cf6 100%);
    color: white;
    font-size: 0.875rem;
}

.banner.hidden {
    display: none;
}

.btn-icon-small {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.btn-icon-small:hover {
    opacity: 1;
}

#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

#messages {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    display: flex;
    gap: 0.75rem;
    animation: fadeIn 0.3s ease;
}

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

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

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

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

.message-content {
    max-width: 70%;
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    line-height: 1.5;
    white-space: pre-wrap;  /* Preserve line breaks */
}

.message.assistant .message-content {
    background: var(--bg-card);
}

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

.message.system .message-content {
    background: var(--bg-input);
    border-left: 3px solid var(--warning);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.tool-execution {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.tool-execution .tool-name {
    color: var(--primary-light);
    font-weight: 500;
}

.tool-execution .tool-status {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.5rem;
}

.tool-execution .tool-status.success {
    color: var(--secondary);
}

.tool-execution .tool-status.pending {
    color: var(--warning);
}

.chat-footer {
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

#chat-form {
    display: flex;
    gap: 0.75rem;
    max-width: 800px;
    margin: 0 auto;
}

#message-input {
    flex: 1;
}

#send-btn {
    width: 48px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* ============================================================================
   Modal
   ============================================================================ */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s ease;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 90%;
    max-width: 480px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

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

.modal-header h3 {
    font-size: 1.125rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.details {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.modal-actions .btn {
    flex: 1;
}

/* ============================================================================
   Responsive
   ============================================================================ */

@media (max-width: 600px) {
    .login-container {
        padding: 1rem;
    }
    
    .features {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    #user-name {
        display: none;
    }
}

/* ============================================================================
   OAuth Connect Button (Inline in Chat)
   ============================================================================ */

.auth-required-message {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    padding: 1rem !important;
}

.oauth-connect-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #4285f4 0%, #34a853 50%, #fbbc05 75%, #ea4335 100%);
    background-size: 300% 100%;
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
}

.oauth-connect-button:hover {
    background-position: 100% 0;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(66, 133, 244, 0.4);
}

.oauth-connect-button:active {
    transform: translateY(0);
}

.oauth-connect-button svg {
    flex-shrink: 0;
}

.scope-descriptions ul {
    list-style: none;
    padding-left: 0 !important;
}

.scope-descriptions li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.25rem;
}

.scope-descriptions li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--secondary);
}

/* ============================================================================
   PHASE 1: ASYNC UX COMPONENTS
   ============================================================================ */

/* Task Progress Indicator */
.task-progress-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    background: rgba(99, 102, 241, 0.1);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.progress-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.progress-text {
    flex: 1;
}

.progress-percent {
    font-weight: 600;
    color: var(--primary-light);
}

/* Question Modal */
.question-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.question-modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    max-width: 480px;
    width: 90%;
    animation: slideUp 0.3s ease;
}

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

.question-from {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.question-text {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.question-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.option-btn {
    padding: 0.6rem 1.2rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}

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

.question-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.question-input:focus {
    outline: none;
    border-color: var(--primary);
}

.question-submit-btn {
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.question-submit-btn:hover {
    background: var(--primary-dark);
}

/* Notification Banner */
.notification-banner {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--bg-card);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    animation: slideIn 0.3s ease;
}

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

.notification-banner.success { border-left-color: var(--secondary); }
.notification-banner.warning { border-left-color: var(--warning); }
.notification-banner.error { border-left-color: var(--danger); }

.notification-icon {
    font-size: 1.25rem;
}

.notification-text {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text-primary);
}

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

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

/* Retry Prompt Modal */
.retry-prompt-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.retry-modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: slideUp 0.3s ease;
}

.retry-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.retry-text {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.retry-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.retry-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.retry-btn.primary {
    background: var(--primary);
    color: white;
}

.retry-btn.primary:hover {
    background: var(--primary-dark);
}

.retry-btn.secondary {
    background: var(--bg-input);
    color: var(--text-secondary);
}

.retry-btn.secondary:hover {
    background: var(--border);
}

