/* Modern Health Assessment UI with AI Chat Integration */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-light: #f9fafb;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.2);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--primary-gradient);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
header {
    background: var(--primary-gradient);
    color: white;
    padding: 60px 40px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><rect fill="rgba(255,255,255,0.05)" x="0" y="0" width="50" height="50"/></svg>');
    opacity: 0.3;
}

.header-content {
    position: relative;
    z-index: 1;
}

.header-icon {
    font-size: 3.5em;
    margin-bottom: 15px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

header h1 {
    font-size: 2.8em;
    margin-bottom: 15px;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.2em;
    opacity: 0.95;
    font-weight: 300;
}

/* Main Content */
.main-content {
    padding: 50px 40px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 35px;
    color: var(--text-primary);
}

.section-header i {
    font-size: 2em;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.section-header h2 {
    font-size: 2em;
    font-weight: 700;
    color: var(--text-primary);
}

.form-intro {
    margin-top: 8px;
    color: var(--text-secondary);
    max-width: 700px;
}

/* Form Section */
.form-section {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-section-divider {
    margin: 35px 0 25px 0;
    text-align: center;
    position: relative;
}

.form-section-divider::before,
.form-section-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: calc(50% - 80px);
    height: 2px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
}

.form-section-divider::before {
    left: 0;
}

.form-section-divider::after {
    right: 0;
}

.form-section-divider span {
    background: white;
    padding: 0 20px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 25px;
    margin-bottom: 25px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
    margin-bottom: 25px;
}

.span-2 {
    grid-column: span 2;
}

.form-group {
    position: relative;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95em;
}

.form-group label i {
    color: #667eea;
    font-size: 1.1em;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1em;
    transition: all 0.3s ease;
    background: white;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

.form-group input:hover,
.form-group select:hover {
    border-color: #a5b4fc;
}

.form-group input::placeholder {
    color: #9ca3af;
}

.form-help {
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 0.86em;
    line-height: 1.5;
}

.form-onboarding-card {
    margin-bottom: 28px;
    padding: 22px 24px;
    border-radius: 18px;
    background: linear-gradient(135deg, #eef4ff 0%, #f8fafc 100%);
    border: 1px solid #dbeafe;
    box-shadow: var(--shadow-sm);
}

.form-onboarding-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.form-progress-label {
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    margin-bottom: 6px;
}

.form-progress-pill {
    min-width: 68px;
    text-align: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(79, 70, 229, 0.12);
    color: #4338ca;
    font-weight: 700;
}

.form-progress-track {
    height: 10px;
    border-radius: 999px;
    background: #dbeafe;
    overflow: hidden;
    margin-bottom: 16px;
}

.form-progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #3b82f6 0%, #14b8a6 100%);
    transition: width 0.25s ease;
}

.form-quick-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-secondary-action {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid #c7d2fe;
    background: white;
    color: #3730a3;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-secondary-action:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    border-color: #818cf8;
}

.form-submit-note {
    margin-top: 14px;
    color: var(--text-secondary);
    font-size: 0.92em;
    text-align: center;
}

/* Buttons */
.btn-submit,
.btn-reset,
.btn-share,
.btn-ask-ai,
.btn-cta-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px 32px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 30px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.btn-submit::before,
.btn-reset::before,
.btn-share::before,
.btn-ask-ai::before,
.btn-cta-primary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-submit:hover::before,
.btn-reset:hover::before,
.btn-share:hover::before,
.btn-ask-ai:hover::before,
.btn-cta-primary:hover::before {
    width: 300px;
    height: 300px;
}

.btn-submit:hover,
.btn-reset:hover,
.btn-share:hover,
.btn-ask-ai:hover,
.btn-cta-primary:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.btn-submit:active,
.btn-reset:active,
.btn-share:active,
.btn-ask-ai:active,
.btn-cta-primary:active {
    transform: translateY(-1px);
}

.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 30px;
}

.btn-share {
    background: var(--secondary-gradient);
}

.btn-ask-ai {
    background: linear-gradient(135deg, #2dd4bf 0%, #3b82f6 100%);
    margin-top: 20px;
}

.btn-cta-primary {
    background: linear-gradient(135deg, #f97316 0%, #ef4444 100%);
    margin-top: 18px;
}

/* Results Section */
.results-section {
    animation: fadeIn 0.6s ease-out;
}

.results-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 25px;
    margin-bottom: 35px;
}

/* Score Card */
.score-card {
    background: var(--primary-gradient);
    color: white;
    padding: 45px;
    border-radius: 20px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.score-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.overall-score {
    position: relative;
    z-index: 1;
}

.score-icon {
    font-size: 3em;
    margin-bottom: 15px;
    animation: pulse 2s ease-in-out infinite;
}

.overall-score h3 {
    font-size: 1.3em;
    margin-bottom: 20px;
    opacity: 0.95;
    font-weight: 500;
}

.score-display {
    font-size: 5.5em;
    font-weight: 800;
    margin: 25px 0;
    line-height: 1;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.2);
    animation: countUp 1s ease-out;
}

@keyframes countUp {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

.score-status {
    font-size: 1.8em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 20px;
}

.score-progress {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 25px;
}

.score-progress-bar {
    height: 100%;
    background: white;
    border-radius: 10px;
    transition: width 1.5s ease-out;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

/* BMI Card */
.bmi-card {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 35px;
    border-radius: 20px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.bmi-card h3 {
    font-size: 1.2em;
    margin-bottom: 20px;
    opacity: 0.95;
    font-weight: 500;
}

.bmi-value {
    font-size: 3.5em;
    font-weight: 800;
    margin: 15px 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.bmi-category {
    font-size: 1.1em;
    font-weight: 600;
    opacity: 0.9;
}

/* Detailed Scores */
.detailed-scores {
    background: white;
    padding: 35px;
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.detailed-scores h3 {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    margin-bottom: 25px;
    font-size: 1.4em;
}

.detailed-scores h3 i {
    color: #667eea;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--bg-light);
    margin-bottom: 12px;
    border-radius: 12px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.score-item:hover {
    background: white;
    border-color: #667eea;
    transform: translateX(5px);
    box-shadow: var(--shadow-sm);
}

.score-item-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.05em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.score-item-name::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
}

.score-item-value {
    font-size: 1.6em;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.score-bar-container {
    flex: 1;
    height: 12px;
    background: #e5e7eb;
    border-radius: 10px;
    margin: 0 20px;
    overflow: hidden;
    position: relative;
}

.score-bar {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 10px;
    transition: width 1s ease-out;
    position: relative;
    overflow: hidden;
}

.score-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Recommendations */
.recommendations {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    padding: 35px;
    border-radius: 20px;
    margin-bottom: 20px;
    border-left: 5px solid #f59e0b;
    box-shadow: var(--shadow-md);
}

.recommendations h3 {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #92400e;
    margin-bottom: 20px;
    font-size: 1.4em;
}

.recommendations h3 i {
    color: #f59e0b;
}

.post-assessment-cta {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 20px;
    border-left: 5px solid #f97316;
    box-shadow: var(--shadow-md);
}

.post-assessment-cta h3 {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #9a3412;
    margin-bottom: 14px;
    font-size: 1.35em;
}

.post-assessment-cta h3 i {
    color: #f97316;
}

.post-assessment-cta p {
    color: #7c2d12;
    font-size: 1.05em;
    line-height: 1.7;
}

/* History Section */
.history-section {
    margin-top: 40px;
    animation: fadeIn 0.5s ease-out;
}

.history-chart-card,
.history-list-card,
.history-goal-card,
.history-sync-card {
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    padding: 30px;
    margin-bottom: 20px;
}

.history-chart-card h3,
.history-list-card h3,
.history-goal-card h3,
.history-sync-card h3 {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 1.25em;
}

.history-chart-card h3 i,
.history-list-card h3 i,
.history-goal-card h3 i,
.history-sync-card h3 i {
    color: #667eea;
}

.goal-controls {
    display: grid;
    grid-template-columns: 130px 1fr auto;
    gap: 12px;
    align-items: center;
}

.goal-controls label {
    color: var(--text-secondary);
    font-weight: 600;
}

#scoreGoalInput {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.95em;
}

#scoreGoalInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

#saveGoalBtn {
    width: auto;
    margin: 0;
    padding: 11px 16px;
    font-size: 0.95em;
}

.goal-progress-wrap {
    margin-top: 16px;
}

.goal-progress {
    height: 12px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.goal-progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #22c55e 0%, #3b82f6 100%);
    transition: width 0.4s ease;
}

#goalProgressText {
    margin-top: 10px;
    color: var(--text-secondary);
    font-weight: 500;
}

.sync-help {
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.sync-controls {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 12px;
}

#syncProfileId {
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.95em;
}

#syncProfileId:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

#syncSaveBtn,
#syncLoadBtn {
    margin: 0;
    padding: 12px 16px;
    font-size: 0.95em;
}

.history-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.history-controls label {
    font-weight: 600;
    color: var(--text-secondary);
}

#historyMetricSelect {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95em;
    color: var(--text-primary);
    background: white;
}

#historyMetricSelect:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

#historyTrendChart {
    width: 100%;
    min-height: 280px;
}

#historyList {
    display: grid;
    gap: 12px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-light);
}

.history-item-main {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.history-item-main strong {
    font-size: 1.2em;
}

.history-item-main span {
    color: var(--text-secondary);
    font-weight: 600;
}

.history-item-meta {
    display: flex;
    gap: 14px;
    color: var(--text-secondary);
    font-size: 0.9em;
}

#recommendationsList {
    list-style: none;
}

#recommendationsList li {
    padding: 15px 0;
    color: #78350f;
    font-size: 1.05em;
    line-height: 1.7;
    border-bottom: 1px solid rgba(245, 158, 11, 0.2);
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

#recommendationsList li:last-child {
    border-bottom: none;
}

#recommendationsList li::before {
    content: "✓";
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    background: #10b981;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9em;
    margin-top: 2px;
}

/* AI Chat Panel */
.ai-chat-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    border: none;
    font-size: 1.8em;
    cursor: pointer;
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    transition: all 0.3s ease;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.ai-chat-toggle:hover {
    transform: scale(1.1) translateY(0);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.4);
    animation: none;
}

.ai-chat-panel {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 400px;
    height: 600px;
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    z-index: 999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideInUp 0.3s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chat-panel.active {
    display: flex;
}

.chat-header {
    background: var(--primary-gradient);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-header-content i {
    font-size: 1.8em;
}

.chat-header h3 {
    margin: 0;
    font-size: 1.2em;
}

.status-indicator {
    font-size: 0.75em;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-indicator::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.close-chat-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2em;
    transition: all 0.3s ease;
}

.close-chat-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-light);
}

.message {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-out;
}

.message-content {
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    max-width: 85%;
}

.bot-message .message-content {
    background: var(--primary-gradient);
    color: white;
    border-bottom-left-radius: 4px;
}

.user-message {
    display: flex;
    justify-content: flex-end;
}

.user-message .message-content {
    background: #e5e7eb;
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}

.message-content p {
    margin: 0 0 8px 0;
    line-height: 1.5;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-time {
    font-size: 0.75em;
    opacity: 0.7;
    margin-top: 8px;
    display: block;
}

.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 15px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    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); }
    30% { transform: translateY(-10px); }
}

.chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

#chatInput {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid var(--border-color);
    border-radius: 25px;
    font-size: 0.95em;
    transition: all 0.3s ease;
    font-family: inherit;
}

#chatInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

#sendChatBtn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

#sendChatBtn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

#sendChatBtn:active {
    transform: scale(0.95);
}

/* Footer */
footer {
    background: var(--bg-light);
    padding: 30px 40px;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.footer-content {
    max-width: 800px;
    margin: 0 auto;
}

.footer-content p {
    color: var(--text-secondary);
    font-size: 0.95em;
    line-height: 1.7;
    margin-bottom: 12px;
}

.footer-content p:last-child {
    margin-bottom: 0;
}

.footer-content strong {
    color: var(--text-primary);
}

.footer-content i {
    color: #667eea;
    margin-right: 8px;
}

.footer-info {
    font-size: 0.85em !important;
    opacity: 0.8;
}

.footer-link {
    color: #4f46e5;
    text-decoration: none;
    font-weight: 600;
}

.footer-link:hover {
    text-decoration: underline;
}

.analytics-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.18), transparent 30%),
        linear-gradient(135deg, #1d4ed8 0%, #312e81 48%, #0f172a 100%);
    color: white;
}

.analytics-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px 56px;
}

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 28px;
}

.analytics-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.analytics-kicker {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.75rem;
    opacity: 0.8;
    margin-bottom: 8px;
}

.analytics-header h1 {
    font-size: 2.6rem;
    line-height: 1.05;
    margin-bottom: 12px;
}

.analytics-subtitle {
    max-width: 640px;
    color: rgba(255, 255, 255, 0.82);
}

.analytics-home-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: white;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.analytics-export-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 999px;
    background: white;
    color: #1d4ed8;
    text-decoration: none;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.analytics-restore-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: white;
    text-decoration: none;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.25);
    cursor: pointer;
}

.analytics-restore-status {
    min-height: 24px;
    margin: -8px 0 20px;
    color: rgba(255, 255, 255, 0.9);
}

.analytics-restore-status.is-error {
    color: #fecaca;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.analytics-card,
.analytics-panel {
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-primary);
    border-radius: 22px;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.analytics-card {
    padding: 24px;
}

.analytics-label {
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.78rem;
    margin-bottom: 10px;
}

.analytics-card h2 {
    font-size: 2.5rem;
    line-height: 1;
    margin-bottom: 12px;
}

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

.analytics-panels {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}

.analytics-panels:last-child {
    grid-template-columns: 1fr;
}

.analytics-panel {
    padding: 24px;
}

.analytics-panel-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.analytics-panel-head h3 {
    font-size: 1.3rem;
}

.analytics-panel-head p {
    color: var(--text-secondary);
}

#analyticsTrendChart {
    width: 100%;
    min-height: 280px;
}

.analytics-event-list,
.analytics-signal-list {
    display: grid;
    gap: 12px;
}

.analytics-funnel {
    display: grid;
    gap: 16px;
}

.analytics-event-item,
.analytics-signal-item {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
}

.analytics-signal-item {
    justify-content: flex-start;
}

.analytics-funnel-step {
    display: grid;
    gap: 8px;
}

.analytics-funnel-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.analytics-funnel-top span {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.analytics-funnel-track {
    height: 14px;
    border-radius: 999px;
    background: rgba(102, 126, 234, 0.12);
    overflow: hidden;
}

.analytics-funnel-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #667eea 0%, #10b981 100%);
}

.analytics-funnel-helper {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.analytics-empty-state {
    color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 992px) {
    .results-grid {
        grid-template-columns: 1fr;
    }

    .form-grid-2 {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        border-radius: 16px;
    }

    header {
        padding: 40px 25px;
    }

    header h1 {
        font-size: 2em;
    }

    .header-icon {
        font-size: 2.5em;
    }

    .main-content {
        padding: 30px 25px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        grid-template-columns: 1fr;
    }

    .score-display {
        font-size: 4em;
    }

    .ai-chat-panel {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 10px;
        right: 10px;
    }

    .ai-chat-toggle {
        bottom: 20px;
        right: 20px;
        width: 55px;
        height: 55px;
        font-size: 1.5em;
    }

    .history-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .history-item-meta {
        flex-wrap: wrap;
        gap: 8px 12px;
    }

    .history-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    #historyMetricSelect {
        width: 100%;
    }

    .goal-controls {
        grid-template-columns: 1fr;
    }

    #saveGoalBtn {
        width: 100%;
    }

    .sync-controls {
        grid-template-columns: 1fr;
    }

    .form-onboarding-header,
    .form-quick-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .analytics-header,
    .analytics-panel-head {
        flex-direction: column;
    }

    .analytics-grid,
    .analytics-panels {
        grid-template-columns: 1fr;
    }
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}
