/* OneBiteSafer Allergen Chatbot Widget Styles */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

* {
    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.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    padding: 2rem;
}

/* Chatbot Widget Container */
.chatbot-widget {
    max-width: 600px;
    margin: 0 auto;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #1d4ed8 100%);
    color: white;
    padding: 1.5rem;
    text-align: center;
}

.chatbot-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.logo {
    font-size: 2rem;
}

.chatbot-subtitle {
    font-size: 0.95rem;
    opacity: 0.95;
}

/* Restaurant Selector */
.restaurant-selector {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.restaurant-selector label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.select-wrapper {
    position: relative;
}

.restaurant-dropdown {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.restaurant-dropdown:hover {
    border-color: var(--primary-color);
}

.restaurant-dropdown:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Restaurant Info Card */
.restaurant-info {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.info-row:last-child {
    margin-bottom: 0;
}

.info-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge.high {
    background: #d1fae5;
    color: #065f46;
}

.badge.medium {
    background: #fed7aa;
    color: #92400e;
}

.badge.low {
    background: #fee2e2;
    color: #991b1b;
}

.badge-source {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 500;
}

.badge-source.restaurant {
    background: #dbeafe;
    color: #1e40af;
}

.badge-source.crowdsourced {
    background: #fef3c7;
    color: #92400e;
}

.coverage-text {
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* Quick Actions - Button Style */
.quick-actions {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

.action-buttons-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.action-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.125rem;
    background: #dbeafe;
    color: #1e40af;
    border: none;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.action-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-button:not(:disabled):hover {
    background: #bfdbfe;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
}

.action-button.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.action-button .action-icon {
    font-size: 1rem;
    line-height: 1;
}

.action-button .action-text {
    line-height: 1;
}

.action-panes-container {
    border-top: 1px solid var(--border-color);
}

.action-pane {
    display: none;
}

.action-pane.expanded {
    display: block;
    animation: slideDown 0.3s ease-out;
}

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

.pane-content {
    padding: 1.5rem;
    background: var(--bg-secondary);
}

.pane-intro {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Crowdsourcing Message */
.crowdsourcing-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%);
    border-top: 1px solid var(--border-color);
}

.message-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    line-height: 1;
}

.message-content {
    font-size: 0.8125rem;
    color: var(--text-primary);
    line-height: 1.4;
}

/* Pane content scrolling - Keep allergen selection visible */
.pane-intro {
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Sticky allergen selection controls */
.pane-content .allergen-grid-horizontal {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    padding: 0.5rem 0;
    margin-bottom: 0.75rem;
    z-index: 10;
}

.pane-content .primary-button {
    position: sticky;
    top: 3.5rem;
    z-index: 9;
    margin-bottom: 0.75rem;
}

.results-area {
    margin-top: 0.5rem;
}

.items-list {
    max-height: 500px;
    overflow-y: auto;
}

/* Allergen Checkboxes - Horizontal Layout (More Compact) */
.allergen-grid-horizontal {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.75rem;
}

.allergen-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem 0.5rem;
    background: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.allergen-checkbox:hover {
    border-color: var(--primary-color);
    background: #eff6ff;
    transform: translateY(-1px);
}

.allergen-checkbox.checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.allergen-checkbox.checked label {
    color: white;
}

.allergen-checkbox input[type="checkbox"] {
    width: 0.8rem;
    height: 0.8rem;
    cursor: pointer;
    margin: 0;
}

.allergen-checkbox label {
    cursor: pointer;
    user-select: none;
    font-size: 0.75rem;
    font-weight: 500;
    margin: 0;
    line-height: 1;
}

/* Primary Button */
.primary-button {
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.primary-button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.primary-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Results Area */
.results-area {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
}

.results-header {
    margin-bottom: 1rem;
}

.results-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.results-summary {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* Warning Banner */
.warning-banner {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.warning-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.warning-banner span:not(.warning-icon) {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.5;
}

/* Items List */
.items-list {
    display: grid;
    gap: 1rem;
    padding-right: 0.5rem;
}

/* Custom scrollbar styling */
.results-area::-webkit-scrollbar,
.pane-content::-webkit-scrollbar,
.items-list::-webkit-scrollbar {
    width: 8px;
}

.results-area::-webkit-scrollbar-track,
.pane-content::-webkit-scrollbar-track,
.items-list::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.results-area::-webkit-scrollbar-thumb,
.pane-content::-webkit-scrollbar-thumb,
.items-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.results-area::-webkit-scrollbar-thumb:hover,
.pane-content::-webkit-scrollbar-thumb:hover,
.items-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.item-card {
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.avoid-item-card {
    background: #fef2f2;
    border: 2px solid #fca5a5;
}

.item-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.allergen-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.allergen-tag {
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.allergen-tag.contains {
    background: #fee2e2;
    color: #991b1b;
}

.allergen-tag.safe {
    background: #d1fae5;
    color: #065f46;
}

.allergen-tag.unknown {
    background: #e5e7eb;
    color: #4b5563;
}

/* Statistics */
.stats-summary {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.stat-row:last-child {
    margin-bottom: 0;
}

.stat-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.stat-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* Allergen Stats */
.allergen-stats {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.allergen-stat-card {
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.allergen-stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.allergen-stat-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.allergen-stat-confidence {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
}

.allergen-stat-bars {
    display: grid;
    gap: 0.5rem;
}

.stat-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-bar-label {
    width: 120px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stat-bar-visual {
    flex: 1;
    height: 1.5rem;
    background: var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    transition: width 0.3s;
}

.stat-bar-fill.contains {
    background: linear-gradient(90deg, #f87171 0%, #ef4444 100%);
}

.stat-bar-fill.safe {
    background: linear-gradient(90deg, #34d399 0%, #10b981 100%);
}

.stat-bar-fill.unknown {
    background: linear-gradient(90deg, #9ca3af 0%, #6b7280 100%);
}

.stat-bar-value {
    width: 60px;
    text-align: right;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Data Gap Visualization */
.data-gap-section {
    padding: 1.5rem;
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: var(--radius-md);
}

.data-gap-section h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.gap-description {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.gap-chart {
    display: grid;
    gap: 0.75rem;
}

.gap-bar-container {
    display: grid;
    gap: 0.25rem;
}

.gap-bar-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.gap-bar {
    height: 2rem;
    background: var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
}

.gap-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    transition: width 0.3s;
}

.gap-segment.known {
    background: var(--success-color);
}

.gap-segment.unknown {
    background: #9ca3af;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    color: white;
    font-size: 1rem;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 600px) {
    body {
        padding: 1rem;
    }

    .chatbot-widget {
        border-radius: var(--radius-md);
    }

    /* Mobile button adjustments */
    .quick-actions {
        padding: 1rem;
    }

    .action-button {
        padding: 0.5rem 0.875rem;
        font-size: 0.8125rem;
    }

    .action-button .action-icon {
        font-size: 0.9rem;
    }

    .allergen-grid-horizontal {
        gap: 0.25rem;
    }

    .allergen-checkbox {
        padding: 0.25rem 0.4rem;
    }

    .allergen-checkbox label {
        font-size: 0.7rem;
    }

    .allergen-checkbox input[type="checkbox"] {
        width: 0.75rem;
        height: 0.75rem;
    }

    .pane-content {
        padding: 1rem;
    }

    .crowdsourcing-message {
        padding: 0.75rem 1rem;
        font-size: 0.75rem;
    }

    .message-icon {
        font-size: 1rem;
    }

    .stat-bar-label {
        width: 100px;
        font-size: 0.8rem;
    }
}
