/**
 * Deen Calendar - Premium Styles (Phase 2)
 * Features: Sticky Header, Scroll Animations, Action Buttons, Install Banner
 */

:root {
    --primary: #005b36;
    --primary-light: #0d8b52;
    --primary-dark: #003d24;
    --accent: #d4af37;
    --accent-light: #e8c547;
    --bg: #f8faf9;
    --card-bg: #ffffff;
    --text: #1a1a1a;
    --text-muted: #666666;
    --border: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    
    /* Fard colors - WCAG AA compliant */
    --fard-bg: #fef2f2;
    --fard-border: #dc2626;
    --fard-text: #7f1d1d;
    --fard-label: #991b1b;
    
    /* Sunnah colors - WCAG AA compliant */
    --sunnah-bg: #f0fdf4;
    --sunnah-border: #16a34a;
    --sunnah-text: #14532d;
    --sunnah-label: #166534;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(180deg, var(--bg) 0%, #ffffff 100%);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ============================================
   STICKY HEADER
   ============================================ */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 1.25rem 1rem;
    text-align: center;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.logo-icon {
    font-size: 1.75rem;
}

header h1 {
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

header .subtitle {
    color: rgba(255,255,255,0.85);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* ============================================
   INSTALL BANNER
   ============================================ */
.install-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: white;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 200;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.install-banner.show {
    transform: translateY(0);
}

.install-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.install-icon {
    font-size: 1.25rem;
}

.install-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.install-btn {
    background: var(--accent);
    color: var(--primary-dark);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.install-btn:hover {
    background: var(--accent-light);
    transform: scale(1.02);
}

.install-dismiss {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: background 0.2s ease;
}

.install-dismiss:hover {
    background: rgba(255,255,255,0.3);
}

/* Push content down when banner is visible */
body:has(.install-banner.show) header {
    margin-top: 52px;
}

/* ============================================
   MAIN CONTAINER
   ============================================ */
main {
    max-width: 680px;
    margin: 0 auto;
    padding: 1rem;
}

/* ============================================
   YEAR INDICATOR
   ============================================ */
.year-indicator {
    text-align: center;
    padding: 1.25rem 1rem;
    margin-bottom: 1.25rem;
    background: linear-gradient(90deg, transparent, var(--accent) 50%, transparent);
    background-size: 100% 2px;
    background-position: center bottom;
    background-repeat: no-repeat;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.year-badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* ============================================
   EVENT CARDS WITH SCROLL ANIMATION
   ============================================ */
.event-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.5s ease;
    border: 1px solid var(--border);
    opacity: 0;
    transform: translateY(20px);
}

.event-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.event-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.event-date {
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.multi-date {
    font-size: 0.8rem;
    opacity: 0.9;
    font-weight: 400;
}

.event-title {
    padding: 1rem 1rem 0.5rem;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-dark);
}

.event-description {
    padding: 0 1rem 0.75rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.recommendation-badge {
    background: linear-gradient(90deg, #fbbf24 0%, #f59e0b 100%);
    color: #78350f;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sunset-banner {
    background: linear-gradient(90deg, #1e3a5f 0%, #2563eb 100%);
    color: white;
    padding: 0.625rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
}

.sunset-notice {
    background: linear-gradient(90deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-bottom: 1px solid #fcd34d;
}

.special-note {
    margin: 0.75rem 1rem;
    padding: 0.75rem;
    background: #eff6ff;
    border-left: 3px solid #3b82f6;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: #1e40af;
    font-style: italic;
}

.other-nights {
    margin: 0.75rem 1rem;
    padding: 0.75rem;
    background: #f3f4f6;
    border-left: 3px solid #6b7280;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: #374151;
}

/* ============================================
   GLOSSARY TOOLTIPS
   ============================================ */
.glossary-term {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.glossary-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: var(--primary-dark);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 400;
    width: 280px;
    max-width: 90vw;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    line-height: 1.4;
}

.glossary-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--primary-dark);
}

.glossary-term:hover .glossary-tooltip {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   RECOMMENDED CARD HIGHLIGHT
   ============================================ */
.event-card.recommended {
    border: 2px solid #fbbf24;
    box-shadow: 0 4px 20px rgba(251, 191, 36, 0.3);
}

.event-card.recommended .event-title {
    color: #b45309;
}

/* ============================================
   FEEDBACK BUTTON
   ============================================ */
.feedback-btn {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s ease;
}

.feedback-btn:hover {
    background: var(--primary-dark);
}

.version-info {
    text-align: center;
    margin-top: 0.5rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.6;
}

.event-section {
    margin: 0.625rem 1rem;
    padding: 0.875rem;
    border-radius: var(--radius-sm);
    border-left: 4px solid;
}

.event-section:last-of-type {
    margin-bottom: 0.75rem;
}

.section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.375rem;
}

.section-content {
    font-size: 0.95rem;
    line-height: 1.5;
}

.fard {
    background: var(--fard-bg);
    border-left-color: var(--fard-border);
}

.fard .section-label {
    color: var(--fard-label);
}

.fard .section-content {
    color: var(--fard-text);
}

.sunnah {
    background: var(--sunnah-bg);
    border-left-color: var(--sunnah-border);
}

.sunnah .section-label {
    color: var(--sunnah-label);
}

.sunnah .section-content {
    color: var(--sunnah-text);
}

/* Card Actions */
.card-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: #fafafa;
}

.action-btn {
    flex: 1;
    background: white;
    border: 1px solid var(--border);
    padding: 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}

.action-btn:hover {
    background: var(--bg);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.ics-btn:hover {
    background: var(--fard-bg);
    border-color: var(--fard-border);
}

.share-btn:hover {
    background: var(--sunnah-bg);
    border-color: var(--sunnah-border);
}

/* ============================================
   LOADER
   ============================================ */
.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 1rem;
    text-align: center;
}

.loader-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.loader-text {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ============================================
   ERROR STATE
   ============================================ */
.error-container {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    margin: 1rem 0;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.error-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #991b1b;
    margin-bottom: 0.5rem;
}

.error-message {
    color: #7f1d1d;
    margin-bottom: 1rem;
    font-family: monospace;
    font-size: 0.875rem;
    word-break: break-word;
}

.retry-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.retry-btn:hover {
    background: var(--primary-dark);
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.empty-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.empty-text {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ============================================
   TOAST NOTIFICATION
   ============================================ */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--primary-dark);
    color: white;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 300;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   FOOTER
   ============================================ */
footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.footer-separator {
    color: var(--border);
}

footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

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

.disclaimer-link {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    font-size: 0.8rem;
}

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

.disclaimer-text {
    max-width: 600px;
    margin: 0 auto;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--text-muted);
    opacity: 0.8;
}

/* ============================================
   DISCLAIMER MODAL
   ============================================ */
.disclaimer-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.disclaimer-modal.show {
    opacity: 1;
    pointer-events: auto;
}

.disclaimer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
}

.disclaimer-content {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 420px;
    margin: 1rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.disclaimer-modal.show .disclaimer-content {
    transform: translateY(0);
}

.disclaimer-content h3 {
    color: var(--primary);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.disclaimer-content p {
    margin-bottom: 0.75rem;
    line-height: 1.6;
    color: var(--text);
}

.disclaimer-close {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: background 0.2s ease;
}

.disclaimer-close:hover {
    background: var(--primary-dark);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.25rem;
    }
    
    .event-title {
        font-size: 1.1rem;
    }
    
    .event-section {
        margin: 0.625rem;
        padding: 0.75rem;
    }
    
    .card-actions {
        padding: 0.625rem;
    }
    
    .action-btn {
        font-size: 0.8rem;
        padding: 0.5rem;
    }
    
    .install-content {
        font-size: 0.8rem;
    }
    
    .install-btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* ============================================
   DARK MODE - HIGH CONTRAST
   ============================================ */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0a0f0c;
        --card-bg: #111a15;
        --text: #e8f5ee;
        --text-muted: #8fa896;
        --border: #1e3a2b;
        --shadow: 0 2px 8px rgba(0,0,0,0.3);
        --shadow-hover: 0 4px 16px rgba(0,0,0,0.4);
        
        /* Fard - improved contrast for dark mode */
        --fard-bg: #3d1515;
        --fard-border: #f87171;
        --fard-text: #fecaca;
        --fard-label: #fca5a5;
        
        /* Sunnah - improved contrast for dark mode */
        --sunnah-bg: #0f2918;
        --sunnah-border: #4ade80;
        --sunnah-text: #bbf7d0;
        --sunnah-label: #86efac;
    }
    
    body {
        background: linear-gradient(180deg, var(--bg) 0%, #050805 100%);
    }
    
    .card-actions {
        background: #0d1511;
    }
    
    .action-btn {
        background: var(--card-bg);
        color: var(--text);
        border-color: var(--border);
    }
    
    .action-btn:hover {
        background: #1a2b22;
    }
    
    .error-container {
        background: #3d1515;
        border-color: #7f1d1d;
    }
    
    .error-title {
        color: #fca5a5;
    }
    
    .error-message {
        color: #fecaca;
    }

    .sunset-notice {
        background: linear-gradient(90deg, #451a03 0%, #78350f 100%);
        color: #fcd34d;
        border-bottom-color: #92400e;
    }

    .special-note {
        background: #172554;
        border-left-color: #60a5fa;
        color: #bfdbfe;
    }

    .sunset-banner {
        background: linear-gradient(90deg, #1e3a8a 0%, #3b82f6 100%);
    }

    .other-nights {
        background: #1f2937;
        border-left-color: #9ca3af;
        color: #d1d5db;
    }

    .event-description {
        color: #9ca3af;
    }

    .glossary-tooltip {
        background: #0f172a;
        color: #e2e8f0;
    }

    .glossary-tooltip::after {
        border-top-color: #0f172a;
    }

    .event-card.recommended {
        border-color: #fbbf24;
        box-shadow: 0 4px 20px rgba(251, 191, 36, 0.2);
    }

    .event-card.recommended .event-title {
        color: #fbbf24;
    }
}
