:root {
    --primary: #1F201F;
    --primary-light: #2a2b2a;
    --primary-dark: #141514;
    --primary-bg: #f5f5f5;
    --accent: #7CB342;
    --accent-dark: #689F38;
    --surface: #ffffff;
    --surface-elevated: #f8f9fa;
    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-light: #f0f0f0;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

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

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

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 6px 16px;
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.brand-name {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand-tagline {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-left: 12px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.lang-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.8);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-btn:hover { background: rgba(255,255,255,0.25); color: white; }
.lang-btn.active { background: white; color: var(--accent); font-weight: 600; }

.btn-reset {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: white;
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-reset:hover { background: rgba(255,255,255,0.25); }

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Chat Panel */
.chat-panel {
    flex: 6;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.4s ease;
}

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

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

.assistant-message .message-avatar {
    background: #2d2e2d;
    color: var(--accent);
}

.user-message .message-avatar {
    background: #4a4a4a;
    color: white;
}

.message-content {
    background: var(--surface-elevated);
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.user-message .message-content {
    background: #e8e8e8;
    border-bottom-right-radius: 4px;
}

.assistant-message .message-content {
    border-bottom-left-radius: 4px;
}

.message-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.message-text {
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Chat Input */
.chat-input-area {
    height: 70px;
    max-height: 70px;
    padding: 10px 24px;
    background: var(--surface);
    display: flex;
    align-items: center;
}

.chat-form {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
}

/* Thinking overlay - sits on top of textarea */
.thinking-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    pointer-events: none;
    z-index: 1;
}

.thinking-overlay.active {
    display: flex;
}

.thinking-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.4;
    animation: thinking-pulse 1.4s ease-in-out infinite both;
}

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

.thinking-text {
    font-size: 0.85rem;
    color: var(--accent);
    margin-left: 4px;
    font-weight: 500;
}

@keyframes thinking-pulse {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

#chatInput {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 16px;
    font-size: 0.9rem;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

#chatInput:focus { border-color: var(--accent); }

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

.btn-send:hover:not(:disabled) { background: var(--accent-dark); transform: scale(1.05); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* Quote Panel */
.quote-panel {
    flex: 4;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    overflow: hidden;
}

.quote-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 50px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-elevated);
}

.quote-panel-header h2 {
    font-size: 1rem;
    font-weight: 700;
}

.quote-status {
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 12px;
    background: #fef3c7;
    color: #92400e;
    font-weight: 500;
}

.quote-sections {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.quote-section {
    margin-bottom: 20px;
    animation: slideIn 0.3s ease;
}

.quote-section h3 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--primary-bg);
}

.quote-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    padding: 6px 0;
}

.detail-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-value {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.detail-value.updated {
    animation: highlight 1s ease;
}

/* Tent Info */
.tent-info {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}

.tent-size {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
}

.tent-area {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Capacity Indicator */
.capacity-indicator {
    margin: 10px 0;
}

.capacity-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.capacity-bar-container {
    width: 100%;
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
}

.capacity-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease, background-color 0.3s;
    background: var(--success);
}

.capacity-bar.warning { background: var(--warning); }
.capacity-bar.danger { background: var(--danger); }

.capacity-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.tent-notes {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 8px;
}

/* Equipment List */
.equipment-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.equipment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--surface-elevated);
    border-radius: var(--radius);
    font-size: 0.85rem;
    animation: slideIn 0.3s ease;
}

.equipment-item .eq-check {
    color: var(--accent);
    font-weight: 700;
}

.equipment-item .eq-qty {
    color: var(--text-secondary);
    font-size: 0.75rem;
    min-width: 28px;
}

.equipment-item .eq-category {
    font-size: 0.65rem;
    color: var(--text-muted);
    background: var(--primary-bg);
    padding: 1px 6px;
    border-radius: 3px;
    margin-left: auto;
}

/* Completeness */
.completeness-bar-container {
    width: 100%;
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.completeness-bar {
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
    transition: width 0.5s ease;
}

.completeness-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.gaps-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.gap-item {
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding-left: 12px;
    position: relative;
}

.gap-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
}

.gap-item.required::before { background: var(--danger); }
.gap-item.optional::before { background: var(--warning); }

/* Special Requests */
.special-list {
    list-style: none;
}

.special-list li {
    font-size: 0.85rem;
    padding: 4px 0;
    color: var(--text-secondary);
}

.special-list li {
    position: relative;
}

.special-list li::before {
    content: '\2022';
    color: var(--accent);
    margin-right: 8px;
}

.btn-remove-special {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 4px;
    margin-left: 4px;
    line-height: 1;
    vertical-align: middle;
}

.btn-remove-special:hover {
    color: var(--danger, #dc3545);
}

.special-list li:hover .btn-remove-special {
    display: inline;
}

/* Action Buttons */
.quote-actions {
    height: 70px;
    padding: 0 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-elevated);
}

.btn-action {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-action:hover:not(:disabled) {
    background: var(--primary-bg);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-action:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-handoff {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-handoff:hover:not(:disabled) {
    background: var(--accent-dark);
    color: white;
}

/* Mobile */
.mobile-quote-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 24px;
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 20;
}

.toggle-badge {
    background: white;
    color: var(--accent);
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 0.75rem;
    margin-right: 4px;
}

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

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes highlight {
    0% { background: #fef9c3; }
    100% { background: transparent; }
}


/* Responsive */
@media (max-width: 768px) {
    .main-content { flex-direction: column; min-height: 0; }

    .chat-panel { flex: 1; border-right: none; min-height: 0; overflow: hidden; }

    .chat-messages { padding: 12px; gap: 10px; }

    .message { max-width: 92%; gap: 8px; }
    .message-avatar { width: 30px; height: 30px; font-size: 0.75rem; }
    .message-content { padding: 10px 12px; }
    .message-name { font-size: 0.7rem; }
    .message-text { font-size: 0.85rem; }

    .chat-input-area { height: 60px; padding: 0 12px; }
    .ai-mode-banner { padding: 8px 12px; font-size: 0.75rem; }
    .btn-return-questionnaire { padding: 5px 10px; font-size: 0.75rem; }

    .wizard-option-btn { padding: 8px 14px; font-size: 0.8rem; }
    .wizard-options { gap: 6px; }

    .app-header { padding: 4px 12px; }
    .brand-name { font-size: 1.1rem; }
    .brand-tagline { display: none; }
    .btn-reset { display: none; }

    .language-selector { gap: 2px; }
    .lang-btn { padding: 3px 7px; font-size: 0.7rem; }

    .quote-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 70vh;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        z-index: 15;
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        box-shadow: var(--shadow-lg);
    }

    .quote-panel.open { transform: translateY(0); }

    .mobile-quote-toggle {
        display: flex !important;
        align-items: center;
        bottom: 80px;
        right: 16px;
        touch-action: none;
        will-change: transform;
    }

    .mobile-quote-toggle.snapping {
        transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .mobile-quote-toggle.dragging {
        transition: none;
        box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    }
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar,
.quote-sections::-webkit-scrollbar {
    width: 6px;
}

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

/* ===== Wizard Flow ===== */

/* Progress bar at top of chat */
.wizard-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 50px;
    padding: 0 20px;
    background: var(--surface-elevated);
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.wizard-progress-bar-container {
    flex: 1;
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
    overflow: hidden;
}

.wizard-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.4s ease;
}

.wizard-progress-text {
    font-weight: 500;
    white-space: nowrap;
}

/* Wizard card within assistant message */
.wizard-card {
    margin-top: 12px;
}

.wizard-question {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 4px;
}

.wizard-subtext {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.4;
}

.wizard-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wizard-option-btn {
    padding: 10px 18px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    line-height: 1.3;
}

.wizard-option-btn:hover:not(:disabled):not(.selected) {
    border-color: var(--accent);
    background: var(--primary-bg);
    color: var(--accent);
}

.wizard-option-btn.selected {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
    font-weight: 500;
}

.wizard-option-btn:disabled:not(.selected) {
    opacity: 0.4;
    cursor: not-allowed;
}

.wizard-option-btn .option-description {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
    font-weight: 400;
}

.wizard-option-btn.selected .option-description {
    color: rgba(255,255,255,0.8);
}

/* Grouped options (by icon/category) */
.wizard-option-group {
    width: 100%;
    margin-bottom: 4px;
}

.wizard-option-group-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.wizard-option-group .wizard-options {
    margin-bottom: 8px;
}

/* Multi-select continue button */
.wizard-multi-continue {
    margin-top: 10px;
    padding: 10px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

.wizard-multi-continue:hover {
    background: var(--accent-dark);
}

.wizard-multi-continue:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Date picker and number input in wizard */
.wizard-input-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
    margin-top: 4px;
}

.wizard-input-row:has(.wizard-freetext-area) {
    flex-direction: column;
    align-items: stretch;
}

.wizard-input-row:has(.wizard-freetext-area) .wizard-input-submit {
    align-self: flex-end;
}

.wizard-date-input,
.wizard-number-input {
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    color: var(--text-primary);
    background: var(--surface);
}

.wizard-date-input:focus,
.wizard-number-input:focus {
    border-color: var(--accent);
}

.wizard-number-input {
    width: 140px;
}

.wizard-input-submit {
    padding: 10px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
    height: 42px;
}

.wizard-input-submit:hover { background: var(--accent-dark); }

/* Seasonal highlight */
.wizard-seasonal-highlight {
    border-left: 3px solid var(--warning);
    padding-left: 12px;
    margin-bottom: 12px;
}

.wizard-seasonal-highlight.summer {
    border-left-color: #3b82f6;
}

.wizard-seasonal-highlight.winter {
    border-left-color: #8b5cf6;
}

/* Chat bottom area wrapper */
.chat-bottom-area {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

/* AI mode banner - shown above input when chatting with Rory */
.ai-mode-banner {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--primary-bg);
    border-bottom: 1px solid var(--border-light);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.ai-mode-banner.active {
    display: flex;
}

.btn-return-questionnaire {
    background: var(--accent);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.15s;
}

.btn-return-questionnaire:hover {
    background: var(--accent-dark);
}


/* Info card (intro/summary) */
.wizard-info-card {
    padding: 16px;
    background: var(--primary-bg);
    border-radius: var(--radius);
    border: 1px solid rgba(124, 179, 66, 0.15);
    margin-top: 8px;
    animation: cardFadeIn 0.6s ease;
}

@keyframes cardFadeIn {
    0% { opacity: 0; transform: translateY(12px); }
    100% { opacity: 1; transform: translateY(0); }
}

.wizard-info-card .wizard-question {
    color: var(--accent-dark);
}

/* Summary actions */
.wizard-summary-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.wizard-summary-actions .btn-action {
    flex: none;
    padding: 10px 20px;
}

/* Answered state */
.wizard-card.answered .wizard-options {
    pointer-events: none;
}

.wizard-card.answered .wizard-option-btn:not(.selected) {
    display: none;
}

.wizard-card.answered .wizard-multi-continue {
    display: none;
}

.wizard-card.answered .wizard-input-row {
    pointer-events: none;
}

.wizard-card.answered .wizard-input-submit {
    display: none;
}

/* Edit button on answered cards */
.wizard-edit-btn {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 3px 8px;
    gap: 4px;
    align-items: center;
    transition: all 0.15s ease;
}

.wizard-edit-btn svg {
    vertical-align: -1px;
    margin-right: 2px;
}

.wizard-edit-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--primary-bg);
}

.wizard-card {
    position: relative;
    transition: opacity 0.3s ease;
}

.wizard-card.answered:hover .wizard-edit-btn {
    display: inline-flex;
}

/* Summary callouts */
.wizard-summary-callouts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0;
}

.summary-callout {
    background: var(--primary-bg);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 10px 14px;
}

.summary-callout.callout-note {
    background: var(--surface-elevated);
    border-left-color: var(--text-muted);
}

.callout-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--accent-dark);
    margin-bottom: 4px;
}

.callout-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.wizard-special-input {
    margin: 12px 0;
    padding: 10px 0;
    border-top: 1px solid var(--border);
}

/* Free text wizard input area */
.wizard-freetext-area {
    width: 100%;
    min-height: 60px;
    max-height: 120px;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.wizard-freetext-area:focus {
    border-color: var(--accent);
}
