/* ===================================
   Analyze Page Styles
   Clean, professional design
   =================================== */

.analyze-page {
    background: var(--color-bg);
    min-height: 100vh;
}

/* Ensure header stays white on analyze page */
.analyze-page .header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
}

.analyze-main {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 70px);
    margin-top: 70px;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
    padding: var(--space-xl);
}

/* Upload Section */
.upload-section {
    margin-bottom: var(--space-xl);
}

.upload-zone {
    position: relative;
    padding: var(--space-3xl);
    background: var(--color-bg-elevated);
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--color-primary);
    background: var(--color-primary-muted);
}

.upload-zone.has-file {
    border-style: solid;
    border-color: var(--color-success);
    background: rgba(16, 185, 129, 0.05);
    cursor: default;
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
}

.upload-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-muted);
    border-radius: var(--radius-lg);
    color: var(--color-primary);
    margin-bottom: var(--space-md);
}

.upload-icon svg {
    width: 32px;
    height: 32px;
}

.upload-text {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--color-text);
}

.upload-hint {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
}

.upload-loading,
.upload-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.upload-loading {
    color: var(--color-primary);
}

.upload-success svg {
    color: var(--color-success);
    width: 48px;
    height: 48px;
}

.success-message {
    color: var(--color-text);
    font-size: 1rem;
    font-weight: 500;
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Analysis Panel */
.analysis-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--color-border);
}

.panel-title-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.panel-title {
    font-size: 1.5rem;
}

.panel-subtitle {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
}

/* Analysis Content */
.analysis-content {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.analysis-placeholder {
    padding: var(--space-2xl);
    text-align: center;
    color: var(--color-text-muted);
}

.analysis-placeholder ul {
    list-style: none;
    margin-top: var(--space-lg);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-md);
}

.analysis-placeholder li {
    background: var(--color-bg-muted);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
}

.analysis-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    padding: var(--space-4xl);
    color: var(--color-text-muted);
}

.loading-hint {
    font-size: 0.875rem;
    color: var(--color-text-faint);
}

/* Pound Breakdown Section */
.pound-breakdown-section {
    padding: var(--space-xl);
    border-bottom: 1px solid var(--color-border);
    background: linear-gradient(135deg, var(--color-primary-muted) 0%, var(--color-bg-muted) 100%);
}

.pound-breakdown-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.pound-breakdown-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--space-xs);
}

.pound-breakdown-subtitle {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
}

.pound-coins {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.pound-coin {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    min-width: 120px;
}

.coin-visual {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-body);
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    box-shadow: var(--shadow-md);
    position: relative;
}

.coin-visual.charitable { background: linear-gradient(135deg, #059669, #10b981); }
.coin-visual.fundraising { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.coin-visual.admin { background: linear-gradient(135deg, #dc2626, #ef4444); }
.coin-visual.other { background: linear-gradient(135deg, #94a3b8, #cbd5e1); }

.coin-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
    text-align: center;
}

.coin-pence {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

/* Charts Section */
.charts-section {
    padding: var(--space-xl);
    border-bottom: 1px solid var(--color-border);
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
}

.chart-card {
    background: var(--color-bg-muted);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
}

.chart-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-md);
}

.chart-container {
    position: relative;
    height: 220px;
}

/* Key Metrics */
.metrics-section {
    padding: var(--space-xl);
    border-bottom: 1px solid var(--color-border);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
}

.metric-card {
    background: var(--color-bg-muted);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    text-align: center;
}

.metric-value {
    font-family: var(--font-body);
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: var(--space-xs);
}

.metric-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.metric-card.good .metric-value { color: #059669; }
.metric-card.good { border-left: 4px solid #10b981; }
.metric-card.warning .metric-value { color: #d97706; }
.metric-card.warning { border-left: 4px solid #f59e0b; }
.metric-card.bad .metric-value { color: #dc2626; }
.metric-card.bad { border-left: 4px solid #ef4444; }
.metric-card.neutral .metric-value { color: var(--color-primary); }
.metric-card.neutral { border-left: 4px solid var(--color-primary); }

/* Summary Section */
.summary-section {
    padding: var(--space-xl);
}

.summary-content {
    line-height: 1.8;
}

.summary-content h2,
.summary-content h3 {
    font-family: var(--font-body);
    font-weight: 600;
    color: var(--color-text);
    margin-top: var(--space-xl);
    margin-bottom: var(--space-md);
}

.summary-content h2 { font-size: 1.375rem; }
.summary-content h3 { font-size: 1.125rem; }

.summary-content p {
    margin-bottom: var(--space-md);
    color: var(--color-text);
}

.summary-content ul,
.summary-content ol {
    margin-bottom: var(--space-md);
    padding-left: var(--space-xl);
}

.summary-content li {
    margin-bottom: var(--space-sm);
    color: var(--color-text);
}

.summary-content strong {
    color: var(--color-primary);
    font-weight: 600;
}

/* Calculations Section */
.calculations-section {
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-muted);
}

.calculations-toggle {
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-primary);
    list-style: none;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.calculations-toggle::-webkit-details-marker {
    display: none;
}

.calculations-toggle::before {
    content: "▶";
    font-size: 0.75rem;
    transition: transform var(--transition-fast);
}

details[open] .calculations-toggle::before {
    transform: rotate(90deg);
}

.calculations-content {
    margin-top: var(--space-lg);
}

.calc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.calc-table th,
.calc-table td {
    padding: var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.calc-table th {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
    background: var(--color-bg-elevated);
}

.calc-table td {
    color: var(--color-text);
}

.calc-table td strong {
    color: var(--color-primary);
}

.calc-table .total-row {
    background: var(--color-bg-elevated);
}

.calc-table .total-row td {
    border-bottom: none;
}

/* Chat Section */
.chat-section {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    max-height: 450px;
}

.chat-header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-muted);
}

.chat-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

.chat-title svg {
    color: var(--color-primary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.chat-welcome {
    color: var(--color-text-muted);
    font-size: 0.9375rem;
    text-align: center;
    padding: var(--space-lg);
}

.suggested-questions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.suggestion {
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.suggestion:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-muted);
}

.chat-message {
    display: flex;
    gap: var(--space-sm);
    max-width: 85%;
}

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

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

.chat-message.user .chat-avatar {
    background: var(--color-primary);
    color: white;
}

.chat-message.assistant .chat-avatar {
    background: var(--color-accent);
    color: white;
}

.chat-bubble {
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    font-size: 0.9375rem;
    line-height: 1.6;
}

.chat-message.user .chat-bubble {
    background: var(--color-primary);
    color: white;
    border-bottom-right-radius: var(--radius-sm);
}

.chat-message.assistant .chat-bubble {
    background: var(--color-bg-muted);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    border-bottom-left-radius: var(--radius-sm);
}

.chat-input-container {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-muted);
}

.chat-input {
    flex: 1;
    padding: var(--space-md);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    color: var(--color-text);
    outline: none;
    transition: border-color var(--transition-fast);
}

.chat-input:focus {
    border-color: var(--color-primary);
}

.chat-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-input::placeholder {
    color: var(--color-text-faint);
}

.chat-send {
    padding: var(--space-md) var(--space-lg);
    background: var(--color-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-send:hover:not(:disabled) {
    background: var(--color-primary-dark);
}

.chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Nav Actions */
.nav-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.powered-by {
    font-size: 0.8125rem;
    color: var(--color-text-faint);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-xl);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    z-index: 1100;
}

.toast {
    padding: var(--space-md) var(--space-lg);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.9375rem;
    animation: slideIn 0.3s ease;
}

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

.toast.error {
    border-left: 3px solid var(--color-error);
}

.toast.success {
    border-left: 3px solid var(--color-success);
}

.toast-icon {
    flex-shrink: 0;
}

.toast.error .toast-icon { color: var(--color-error); }
.toast.success .toast-icon { color: var(--color-success); }

/* Utility */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .analyze-main {
        padding: var(--space-md);
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .panel-header {
        flex-direction: column;
        gap: var(--space-md);
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .suggested-questions {
        flex-direction: column;
    }
}
