/* Critical CSS for AI-Powered Customer Interview PWA */

:root {
    /* Google Brand Colors */
    --google-blue: #4285f4;
    --google-red: #ea4335;
    --google-yellow: #fbbc05;
    --google-green: #34a853;
    
    /* Google Text Colors */
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --text-disabled: #9aa0a6;
    
    /* Google Surface Colors */
    --surface-primary: #ffffff;
    --surface-secondary: #f8f9fa;
    --surface-variant: #e8eaed;
    
    /* Shadows */
    --shadow-light: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-medium: 0 2px 8px rgba(0,0,0,0.15);
    
    /* Legacy colors for compatibility */
    --primary-color: #4285f4;
    --secondary-color: #f8f9fa;
    --success-color: #34a853;
    --warning-color: #fbbc05;
    --error-color: #ea4335;
    --background-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --border-radius: 18px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--background-gradient);
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* App Container */
.app-container {
    display: flex;
    height: calc(100vh - 80px); /* More space at bottom */
    height: calc(100dvh - 80px); /* Dynamic viewport height for mobile */
    flex-direction: column;
    background: white;
    border-radius: 20px 20px 0 0;
    margin-top: 40px;
    margin-bottom: 40px; /* Add bottom margin */
    position: relative;
    overflow: hidden;
}

/* Google-style Header */
.app-header {
    background: #ffffff;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.business-info {
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: left;
}

.business-logo {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: #4285f4; /* Google blue */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    flex-shrink: 0;
}

.business-details {
    display: flex;
    flex-direction: column;
}

.business-name {
    font-size: 20px;
    font-weight: 500;
    color: #202124; /* Google text color */
    margin: 0 0 4px 0;
    font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.interview-subtitle {
    font-size: 14px;
    color: #5f6368; /* Google secondary text */
    margin: 0;
    font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Chat Interface */
.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.conversation-flow {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Message Bubbles */
.message-bubble {
    max-width: 280px;
    margin: 8px 0;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    word-wrap: break-word;
    animation: slideInUp 0.3s ease-out;
    position: relative;
}

.message-bubble.ai-bubble {
    background: white;
    align-self: flex-start;
    box-shadow: var(--shadow-light);
    border: 1px solid #E5E5EA;
    margin-right: 60px;
}

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

.message-content {
    font-size: 16px;
    line-height: 1.4;
}

.message-timestamp {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    opacity: 0.7;
}

.user-bubble .message-timestamp {
    color: rgba(255,255,255,0.7);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
}

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

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

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

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

/* Streaming Text Animation */
.streaming::after {
    content: '|';
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Input Area */
.input-area {
    display: flex;
    align-items: flex-end;
    padding: 16px 16px 24px 16px; /* Extra bottom padding for Firefox */
    background: white;
    /* Removed border-top line */
    gap: 12px;
    flex-shrink: 0; /* Prevent input from being compressed */
    min-height: 80px; /* Ensure minimum height */
    position: relative;
}

/* Add spacer after input area to ensure full visibility */
.input-area::after {
    content: '';
    display: block;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: transparent;
    pointer-events: none;
}

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

.voice-button:hover {
    background: #E5E5EA;
}

.voice-button.recording {
    background: var(--error-color);
    color: white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.input-wrapper {
    flex: 1;
    display: flex;
    align-items: center; /* FIXED: Center text vertically - was flex-end */
    background: #f8f9fa !important; /* Google's light gray */
    background-color: #f8f9fa !important; /* Double ensure for Firefox */
    border: none; /* Remove outline */
    border-radius: 24px; /* Google-style rounded */
    padding: 12px 16px;
    min-height: 48px; /* Ensure adequate height for centering */
    max-height: 120px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); /* Subtle Google shadow */
}

.input-wrapper:focus-within {
    background: #ffffff !important; /* White on focus */
    background-color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); /* Google focus shadow */
}

.message-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px; /* Prevents iOS zoom */
    font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.3; /* Tighter line height for better centering */
    resize: none;
    outline: none;
    height: 24px; /* Fixed height for single line */
    min-height: 24px;
    max-height: 24px; /* Constrain to single line */
    color: #202124; /* Google text color */
    -webkit-text-fill-color: #202124; /* iOS Safari fix */
    -webkit-opacity: 1; /* iOS Safari fix */
    
    /* Firefox-specific fixes for Linux/Pop OS */
    -moz-appearance: none;
    appearance: none;
    min-width: 0; /* Critical for Firefox flex containers */
    box-sizing: border-box;
    
    /* CRITICAL: Vertical centering fixes */
    padding: 0;
    margin: 0;
    vertical-align: middle;
    align-self: center;
    
    /* Prevent text from going to bottom */
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Firefox autofill override - critical for dark theme issues */
.message-input:-moz-autofill,
.message-input:-moz-autofill-preview {
    background-color: transparent !important;
    color: #1D1D1F !important;
    filter: none !important;
}

/* Firefox-specific input fixes for GTK theme interference */
@-moz-document url-prefix() {
    .message-input {
        background-color: transparent !important;
        color: #1D1D1F !important;
        -moz-text-fill-color: #1D1D1F !important;
    }
}

.message-input::placeholder {
    color: #5f6368; /* Google placeholder color */
    opacity: 1; /* Override iOS default opacity */
}

.send-button {
    width: 36px;
    height: 36px;
    border-radius: 18px;
    border: none;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 8px;
}

.send-button:hover {
    background: #0051D5;
}

.send-button:disabled {
    background: #C7C7CC;
    cursor: not-allowed;
}

/* Review Screen */
.review-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 40px 20px 20px;
    animation: slideInUp 0.4s ease-out;
}

.review-header {
    text-align: center;
    margin-bottom: 40px;
}

.review-header h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.review-header p {
    font-size: 16px;
    color: var(--text-secondary);
}

.review-options {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 40px;
}

.review-option {
    display: flex;
    align-items: center;
    padding: 20px;
    background: white;
    border: 2px solid #E5E5EA;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.review-option:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-medium);
}

.review-option:active {
    transform: scale(0.98);
}

.option-icon {
    font-size: 24px;
    margin-right: 16px;
    flex-shrink: 0;
}

.option-content {
    flex: 1;
}

.option-content h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.option-content p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.3;
}

.option-arrow {
    font-size: 18px;
    color: var(--text-secondary);
    margin-left: 12px;
}

.compliance-notice {
    text-align: center;
    padding: 16px;
    background: var(--secondary-color);
    border-radius: 12px;
    margin-top: auto;
}

.compliance-notice p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Animations */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile viewport fix */
@media (max-height: 700px) {
    .app-container {
        margin-top: 20px;
        height: calc(100vh - 20px);
        height: calc(100dvh - 20px);
    }
    
    .input-area {
        padding: 12px 16px 20px 16px;
        min-height: 60px;
    }
}

/* Firefox-specific height fixes for Linux */
@-moz-document url-prefix() {
    .app-container {
        height: calc(100vh - 60px); /* Extra space for Firefox */
        margin-bottom: 20px;
    }
    
    .input-area {
        padding-bottom: 30px; /* More space for Firefox */
        margin-bottom: 10px;
    }
    
    /* Ensure inputs are fully visible in Firefox flex containers */
    .input-wrapper {
        min-height: 44px;
        overflow: visible; /* Override Firefox's overflow: clip */
    }
}

/* Bottom spacer for Firefox input visibility */
.bottom-spacer {
    height: 40px;
    width: 100%;
    background: transparent;
    flex-shrink: 0;
    display: block;
}

/* Firefox gets extra spacing */
@-moz-document url-prefix() {
    .bottom-spacer {
        height: 60px;
    }
}

/* Responsive Design */
@media (max-width: 375px) {
    .message-bubble {
        max-width: 260px;
    }
    
    .message-bubble.ai-bubble {
        margin-right: 40px;
    }
    
    .message-bubble.user-bubble {
        margin-left: 40px;
    }
    
    .input-area {
        padding: 12px;
    }
    
    .review-screen {
        padding: 30px 16px 16px;
    }
}

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

/* Firefox force light colors AND vertical centering fixes */
@-moz-document url-prefix() {
    .input-wrapper {
        background: #f8f9fa !important;
        background-color: #f8f9fa !important;
        -moz-appearance: none !important;
        appearance: none !important;
        align-items: center !important; /* Force center alignment */
    }
    
    .message-input {
        background: transparent !important;
        background-color: transparent !important;
        color: #202124 !important;
        -moz-text-fill-color: #202124 !important;
        /* Firefox-specific vertical centering */
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        line-height: 24px !important;
        height: 24px !important;
        vertical-align: middle !important;
    }
    
    /* Override any dark theme */
    .input-area {
        background: #FFFFFF !important;
        background-color: #FFFFFF !important;
    }
}

/* WebKit/Safari specific fixes for vertical centering */
@supports (-webkit-appearance: none) {
    .message-input {
        -webkit-appearance: none;
        -webkit-box-sizing: border-box;
        /* Safari text centering */
        line-height: 24px;
        height: 24px;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .message-input {
        -webkit-text-size-adjust: 100%;
        line-height: 24px;
        height: 24px;
        padding: 0;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #FFFFFF;
        --text-secondary: #8E8E93;
        --secondary-color: #1C1C1E;
    }
    
    .app-container {
        background: #000000;
    }
    
    .app-header {
        background: #000000;
    }
    
    .message-bubble.ai-bubble {
        background: #1C1C1E;
        border-color: #2C2C2E;
        color: var(--text-primary);
    }
    
    .input-area {
        background: #000000;
        border-top-color: #2C2C2E;
    }
    
    .review-screen {
        background: #000000;
    }
    
    .review-option {
        background: #1C1C1E;
        border-color: #2C2C2E;
    }
}

/* Print styles */
@media print {
    body {
        background: white !important;
    }
    
    .input-area,
    .voice-button,
    .review-options {
        display: none !important;
    }
}