/**
 * BENIN OPPORTUNITY TRACKER - Styles
 * 
 * CHOICE: CSS Variables for theming and consistency
 * WHY: Easy customization, accessible color schemes
 * 
 * ACCESSIBILITY: All colors meet WCAG AA contrast requirements
 */

:root {
    /* Benin flag colors + professional palette */
    --benin-green: #008751;
    --benin-yellow: #FCD116;
    --benin-red: #E8112D;
    
    /* Base colors */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    /* Semantic colors */
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --accent: #008751; /* Benin green */
    
    /* Risk level colors */
    --risk-low: #22c55e;
    --risk-medium: #f59e0b;
    --risk-high: #ef4444;
    
    /* Spacing scale */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
}

/* High contrast theme */
.high-contrast {
    --bg-primary: #000000;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #a0a0a0;
    --accent: #00ff00;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: var(--space-md);
}

/* Accessibility: Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.header-content h1 {
    font-size: 2rem;
    margin-bottom: var(--space-xs);
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

.header-actions {
    display: flex;
    gap: var(--space-sm);
}

/* Buttons */
.btn {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
}

.btn:focus {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

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

.btn-primary:hover {
    opacity: 0.9;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--text-muted);
}

.btn-secondary:hover {
    border-color: var(--text-primary);
}

/* Stats Overview */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--bg-secondary);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.stat-icon {
    font-size: 2.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
}

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

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

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.filter-select,
.filter-input {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
    border: 1px solid var(--text-muted);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 44px;
}

.filter-select:focus,
.filter-input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.filter-search {
    flex: 1;
    min-width: 250px;
}

/* Sections */
section {
    margin-bottom: var(--space-2xl);
}

section h2 {
    font-size: 1.5rem;
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
}

/* Top Opportunities List */
.opportunity-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.opportunity-card {
    background: var(--bg-secondary);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border-left: 4px solid var(--accent);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.opportunity-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.opportunity-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-md);
}

.opportunity-title {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.opportunity-sector {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.opportunity-rank {
    background: var(--accent);
    color: white;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-md);
    font-weight: bold;
    font-size: 0.875rem;
}

.opportunity-description {
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

.opportunity-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.opportunity-actions {
    display: flex;
    gap: var(--space-sm);
}

.opportunity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: var(--space-md);
}

/* Risk Badge */
.risk-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.risk-badge.low {
    background: rgba(34, 197, 94, 0.1);
    color: var(--risk-low);
}

.risk-badge.medium {
    background: rgba(245, 158, 11, 0.1);
    color: var(--risk-medium);
}

.risk-badge.high {
    background: rgba(239, 68, 68, 0.1);
    color: var(--risk-high);
}

/* Score Display */
.score-display {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.score-bar {
    width: 100px;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.score-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width var(--transition-normal);
}

.score-fill.low {
    background: var(--risk-low);
}

.score-fill.medium {
    background: var(--risk-medium);
}

.score-fill.high {
    background: var(--risk-high);
}

.score-value {
    font-weight: bold;
    min-width: 3ch;
}

/* Chart Section */
.chart-section {
    background: var(--bg-secondary);
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.chart-container {
    position: relative;
    height: 400px;
    max-width: 100%;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-secondary);
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-large {
    max-width: 800px;
}

.modal-close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: var(--space-xs);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-content h2 {
    margin-bottom: var(--space-lg);
}

/* Risk Breakdown in Modal */
.risk-breakdown {
    margin-top: var(--space-lg);
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--bg-tertiary);
}

.breakdown-label {
    color: var(--text-secondary);
}

.breakdown-score {
    font-weight: bold;
}

/* Settings */
.settings-section {
    margin-bottom: var(--space-xl);
}

.settings-section h3 {
    margin-bottom: var(--space-sm);
}

.settings-note {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: var(--space-md);
}

.weight-slider {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
}

.weight-slider label {
    min-width: 150px;
}

.weight-slider input[type="range"] {
    flex: 1;
}

.weight-value {
    min-width: 4ch;
    text-align: right;
    font-weight: bold;
}

/* Footer */
.footer {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer a {
    color: var(--accent);
    text-decoration: none;
}

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

.footer-note {
    margin-top: var(--space-sm);
    color: var(--text-muted);
}

/* Loading State */
.loading {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-secondary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: var(--space-md);
        text-align: center;
    }
    
    .header-content h1 {
        font-size: 1.5rem;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .filter-search {
        width: 100%;
    }
    
    .opportunity-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-overview {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chart-container {
        height: 300px;
    }
}

@media (max-width: 480px) {
    .stats-overview {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: var(--space-md);
    }
    
    body {
        padding: var(--space-sm);
    }
}

/* Print Styles */
@media print {
    .header-actions,
    .filters,
    .opportunity-actions,
    .modal,
    .btn {
        display: none !important;
    }
    
    .opportunity-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
