/**
 * RareHope - Global Styles
 * Light/Dark Mode with CSS Variables
 */

/* ============================================
   CSS Custom Properties (Light Mode Default)
   ============================================ */
:root {
    /* Primary Colors - Healing Theme */
    --primary: #5B8C5A;
    --primary-light: #7DA87C;
    --primary-dark: #3D6B3C;
    --primary-rgb: 91, 140, 90;
    
    /* Secondary Colors */
    --secondary: #6C8EBF;
    --secondary-light: #8FADD4;
    --secondary-dark: #4A6A94;
    
    /* Accent Colors */
    --accent: #E8B86D;
    --accent-light: #F2D4A3;
    --accent-dark: #C49642;
    
    /* Status Colors */
    --success: #4CAF50;
    --warning: #FFC107;
    --danger: #E57373;
    --info: #64B5F6;
    
    /* Background Colors */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F8F9FA;
    --bg-tertiary: #E9ECEF;
    --bg-card: #FFFFFF;
    
    /* Text Colors */
    --text-primary: #2C3E50;
    --text-secondary: #5D6D7E;
    --text-muted: #95A5A6;
    --text-light: #BDC3C7;
    --text-on-primary: #FFFFFF;
    
    /* Border Colors */
    --border-color: #DEE2E6;
    --border-light: #F1F3F5;
    
    /* Shadow */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.15);
    
    /* Transitions */
    --transition: all 0.3s ease;
    --transition-fast: all 0.15s ease;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    
    /* Font */
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Header Height */
    --header-height: 70px;
}

/* ============================================
   Dark Mode Variables
   ============================================ */
[data-theme="dark"] {
    --primary: #7DA87C;
    --primary-light: #9FC59E;
    --primary-dark: #5B8C5A;
    
    --bg-primary: #1A1D21;
    --bg-secondary: #22262B;
    --bg-tertiary: #2D3238;
    --bg-card: #22262B;
    
    --text-primary: #E4E6EB;
    --text-secondary: #B0B3B8;
    --text-muted: #8A8D91;
    --text-light: #606770;
    
    --border-color: #3E4247;
    --border-light: #2D3238;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ============================================
   Base Styles
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    transition: var(--transition);
    padding-top: var(--header-height);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition-fast);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }

p {
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
}

/* ============================================
   Header / Navigation
   ============================================ */
.navbar {
    background: var(--bg-primary) !important;
    box-shadow: var(--shadow-sm);
    padding: var(--spacing-sm) 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    height: var(--header-height);
    transition: var(--transition);
}

.navbar-brand {
    font-weight: 700;
    font-size: var(--font-size-xl);
    color: var(--primary) !important;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.navbar-brand img {
    height: 40px;
}

.nav-link {
    color: var(--text-primary) !important;
    font-weight: 500;
    padding: var(--spacing-sm) var(--spacing-md) !important;
    border-radius: var(--radius);
    transition: var(--transition-fast);
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary) !important;
    background-color: rgba(var(--primary-rgb), 0.1);
}

.navbar-search {
    max-width: 300px;
}

.navbar-search .form-control {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 0.5rem 1rem;
}

.navbar-search .form-control:focus {
    background-color: var(--bg-primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

/* Theme Toggle Button */
.theme-toggle {
    background: transparent;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    transition: var(--transition-fast);
}

.theme-toggle:hover {
    background-color: var(--bg-secondary);
}

.theme-toggle .fa-sun { display: none; }
.theme-toggle .fa-moon { display: block; }

[data-theme="dark"] .theme-toggle .fa-sun { display: block; }
[data-theme="dark"] .theme-toggle .fa-moon { display: none; }

/* ============================================
   Hero Section
   ============================================ */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: var(--spacing-2xl) 0;
    margin-top: calc(-1 * var(--header-height));
    padding-top: calc(var(--header-height) + var(--spacing-2xl));
    min-height: 500px;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" fill="rgba(255,255,255,0.05)"/></svg>');
    background-size: 200px;
    opacity: 0.5;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: var(--spacing-lg);
    color: white;
}

.hero p {
    font-size: var(--font-size-xl);
    opacity: 0.9;
    margin-bottom: var(--spacing-xl);
    color: white;
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-4px);
}

.card-img-top {
    height: 200px;
    object-fit: cover;
}

.card-body {
    padding: var(--spacing-lg);
}

.card-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.card-title a {
    color: inherit;
}

.card-title a:hover {
    color: var(--primary);
}

.card-text {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-md);
}

.card-meta {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.card-meta i {
    margin-right: var(--spacing-xs);
}

/* Disease Card Specific */
.disease-card .card-header {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: white;
    padding: var(--spacing-md);
    border: none;
}

.disease-card .prevalence-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    font-weight: 500;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    transition: var(--transition-fast);
    border: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-outline-primary {
    border: 2px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: white;
}

.btn-donate {
    background: #F1F8E9;
    color: var(--primary);
    font-weight: 700;
    padding: 0.6rem 1.8rem;
    border-radius: var(--radius-full);
    border: 2px solid var(--primary);
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.1);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-donate:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.2);
    background: var(--primary);
    color: white;
}

/* ============================================
   Stats Section
   ============================================ */
.stats-section {
    background: var(--bg-primary);
    padding: var(--spacing-2xl) 0;
}

.stat-item {
    text-align: center;
    padding: var(--spacing-lg);
}

.stat-number {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    margin-bottom: var(--spacing-sm);
}

.stat-label {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ============================================
   Section Styles
   ============================================ */
.section {
    padding: var(--spacing-2xl) 0;
}

.section-title {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.section-title h2 {
    font-size: var(--font-size-2xl);
    margin-bottom: var(--spacing-sm);
}

.section-title p {
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

/* ============================================
   Forms
   ============================================ */
.form-control,
.form-select {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    transition: var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bg-primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
    color: var(--text-primary);
}

.form-label {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.form-text {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

/* Donation Amount Selector */
.amount-selector {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.amount-btn {
    flex: 1;
    min-width: 80px;
    padding: var(--spacing-md);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.amount-btn:hover,
.amount-btn.active {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

/* ============================================
   Footer
   ============================================ */
.footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: var(--spacing-2xl) 0 var(--spacing-lg);
    margin-top: var(--spacing-2xl);
}

.footer-brand {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--primary);
    margin-bottom: var(--spacing-md);
    display: block;
}

.footer-desc {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-lg);
}

.footer-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-links li {
    margin-bottom: var(--spacing-sm);
}

.footer-links a {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-social {
    display: flex;
    gap: var(--spacing-md);
}

.footer-social a {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.footer-social a:hover {
    background: var(--primary);
    color: white;
}

.footer-bottom {
    border-top: 1px solid var(--border-color);
    padding-top: var(--spacing-lg);
    margin-top: var(--spacing-lg);
    text-align: center;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    border: 1px solid var(--border-color);
}

.sidebar-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    padding-bottom: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    border-bottom: 2px solid var(--primary);
    color: var(--text-primary);
}

/* ============================================
   Comments
   ============================================ */
.comment-item {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-md) 0;
    border-bottom: 1px solid var(--border-light);
}

.comment-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    object-fit: cover;
}

.comment-content {
    flex: 1;
}

.comment-author {
    font-weight: 600;
    color: var(--text-primary);
}

.comment-date {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-left: var(--spacing-sm);
}

.comment-text {
    margin-top: var(--spacing-sm);
    color: var(--text-secondary);
}

/* ============================================
   Breadcrumb
   ============================================ */
.breadcrumb-wrapper {
    background: var(--bg-primary);
    padding: var(--spacing-md) 0;
    border-bottom: 1px solid var(--border-color);
}

.breadcrumb {
    margin: 0;
    background: transparent;
}

.breadcrumb-item a {
    color: var(--text-secondary);
}

.breadcrumb-item.active {
    color: var(--text-primary);
}

/* ============================================
   Utilities
   ============================================ */
.text-primary { color: var(--primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted { color: var(--text-muted) !important; }
.bg-primary { background-color: var(--primary) !important; }
.bg-secondary { background-color: var(--bg-secondary) !important; }

.badge-category {
    background: var(--primary);
    color: white;
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1;
    position: relative;
}

.badge-type {
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.badge-type.policy { background: #E3F2FD; color: #1976D2; }
.badge-type.activity { background: #E8F5E9; color: #388E3C; }
.badge-type.research { background: #FFF3E0; color: #F57C00; }
.badge-type.announcement { background: #FCE4EC; color: #C2185B; }

[data-theme="dark"] .badge-type.policy { background: rgba(25, 118, 210, 0.2); }
[data-theme="dark"] .badge-type.activity { background: rgba(56, 142, 60, 0.2); }
[data-theme="dark"] .badge-type.research { background: rgba(245, 124, 0, 0.2); }
[data-theme="dark"] .badge-type.announcement { background: rgba(194, 24, 91, 0.2); }

/* Loading Spinner */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--spacing-xl);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 991.98px) {
    .hero h1 {
        font-size: 2rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .navbar-search {
        width: 100%;
        max-width: none;
        margin: var(--spacing-md) 0;
    }
}

@media (max-width: 767.98px) {
    :root {
        --header-height: 60px;
    }
    
    .hero {
        min-height: 400px;
        text-align: center;
    }
    
    .hero h1 {
        font-size: 1.75rem;
    }
    
    .hero p {
        font-size: var(--font-size-base);
    }
    
    .section {
        padding: var(--spacing-xl) 0;
    }
    
    .card-img-top {
        height: 160px;
    }
    
    .footer-col {
        margin-bottom: var(--spacing-lg);
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .navbar,
    .footer,
    .btn,
    .theme-toggle {
        display: none !important;
    }
    
    body {
        padding-top: 0;
        background: white;
        color: black;
    }
    
    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ============================================
   Hover Effects for External Links
   ============================================ */
.hover-shadow {
    transition: all 0.3s ease;
}

.hover-shadow:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover) !important;
}

.hover-shadow .card-body {
    transition: all 0.3s ease;
}

.hover-shadow:hover .card-body {
    background-color: rgba(var(--primary-rgb), 0.02);
}

.hover-shadow:hover .text-primary {
    color: var(--primary-dark) !important;
}

/* ==============================================
   Simple Category Tabs for External Links
   ============================================ */
.btn-category-tab {
    border-radius: 50px;
    padding: 0.6rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
    border-width: 2px;
}

.btn-category-tab:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-category-tab.active,
.btn-category-tab:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-category-tab .badge {
    font-size: 0.75rem;
    padding: 0.25em 0.5em;
    font-weight: 600;
}

.btn-category-tab.btn-primary .badge {
    background-color: rgba(255, 255, 255, 0.9) !important;
    color: var(--primary) !important;
}

@media (max-width: 768px) {
    .btn-category-tab {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
}

/* Call to Action Section */
.cta-section {
    padding: var(--spacing-2xl) 0;
    margin-top: var(--spacing-xl);
    margin-bottom: var(--spacing-2xl);
}

.cta-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: var(--radius-xl);
    padding: var(--spacing-2xl);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.cta-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    transform: rotate(30deg);
    z-index: 0;
}

.cta-content {
    position: relative;
    z-index: 1;
}

.cta-content h2 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    margin-bottom: var(--spacing-md);
    color: white;
    position: relative;
    display: inline-block;
}

.cta-content h2::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 60px;
    height: 4px;
    background: var(--accent);
    border-radius: 2px;
}

@media (min-width: 768px) {
    .cta-content h2 {
        font-size: 2.5rem;
    }
}

.cta-content p {
    font-size: var(--font-size-lg);
    opacity: 0.95;
    margin-bottom: var(--spacing-lg);
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.8;
    text-align: justify;
}

.cta-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
    z-index: 1;
}

@media (min-width: 768px) {
    .cta-buttons {
        flex-direction: column;
        gap: 1rem;
    }
}

.cta-buttons .btn {
    flex: 1;
    margin-bottom: 0;
    white-space: nowrap;
    padding: 0.875rem 1.5rem;
    font-weight: 600;
    border-radius: var(--radius-lg);
    transition: all 0.3s ease;
    border-width: 2px;
}

.cta-buttons .btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.cta-buttons .btn-outline-light {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
    color: white;
}

.cta-buttons .btn-outline-light:hover {
    background-color: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.7);
    color: white;
}

.cta-buttons .btn i {
    margin-right: 0.5rem;
}

/* Pagination styling */
.pagination .page-link {
    color: var(--primary);
    border-color: var(--border-color);
    background-color: var(--bg-card);
}

.pagination .page-link:hover {
    background-color: var(--primary-light);
    color: white;
    border-color: var(--primary-light);
}

.pagination .page-item.active .page-link {
    background-color: var(--primary);
    border-color: var(--primary);
}

.pagination .page-item.disabled .page-link {
    color: var(--text-muted);
    background-color: var(--bg-secondary);
}
