/* ============================================
   VARIABLES & BASE STYLES
   ============================================ */

:root {
    /* Colors */
    --primary-color: #1e40af;
    --primary-dark: #1e3a8a;
    --primary-light: #3b82f6;
    --secondary-color: #7c3aed;
    --accent-color: #f59e0b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    
    /* Backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-dark: #1f2937;
    
    /* Text Colors */
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --text-light: #ffffff;
    
    /* Borders */
    --border-color: #e5e7eb;
    --border-light: #f3f4f6;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    --spacing-3xl: 4rem;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* ============================================
   HEADER
   ============================================ */

.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--text-light);
    padding: var(--spacing-3xl) var(--spacing-lg);
    text-align: center;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.header::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 1200 120"><path d="M0,50 Q300,0 600,50 T1200,50 L1200,120 L0,120 Z" fill="rgba(255,255,255,0.1)"/></svg>');
    background-size: cover;
    opacity: 0.5;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.header-title {
    font-family: 'Merriweather', serif;
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    margin-bottom: var(--spacing-md);
    letter-spacing: -0.5px;
    animation: slideDown 0.6s ease-out;
}

.header-subtitle {
    font-size: clamp(1rem, 2vw, 1.25rem);
    font-weight: 300;
    opacity: 0.95;
    animation: slideUp 0.6s ease-out 0.1s both;
}

.home-link {
    position: absolute;
    top: var(--spacing-lg);
    left: var(--spacing-lg);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    text-decoration: none;
}

.home-link:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.home-link svg {
    width: 24px;
    height: 24px;
    color: var(--text-light);
    transition: transform var(--transition-base);
}

.home-link:hover svg {
    transform: translateX(-2px);
}

@keyframes slideDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================
   CONTAINER & LAYOUT
   ============================================ */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-xl) var(--spacing-lg);
}

/* ============================================
   SEARCH & FILTER SECTION
   ============================================ */

.search-section {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-2xl);
    box-shadow: var(--shadow-md);
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.search-wrapper { display: flex; margin-bottom: var(--spacing-lg); }
.search-input-group { position: relative; display: flex; align-items: center; width: 100%; }

.search-input {
    width: 100%;
    height: 44px;
    padding-left: 3rem;
    padding-right: 3rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: all var(--transition-base);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-color-translucent, rgba(30, 64, 175, 0.1));
}

.search-input::placeholder { color: var(--text-tertiary); }

.search-icon, .clear-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-tertiary);
}
.search-icon { left: var(--spacing-md); pointer-events: none; }
.clear-icon { right: var(--spacing-md); cursor: pointer; visibility: hidden; opacity: 0; transition: opacity var(--transition-fast), visibility var(--transition-fast); }
.search-input-group.has-text .clear-icon { visibility: visible; opacity: 1; }

.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
}

.stats-bar { display: flex; gap: var(--spacing-xl); }
.stat-item { display: flex; align-items: center; gap: var(--spacing-sm); }
.stat-label { color: var(--text-secondary); font-size: 0.875rem; font-weight: 500; }
.stat-value { color: var(--primary-color); font-size: 1.5rem; font-weight: 700; }

/* SHTESA: Stil për grupin e ri të kontrolleve */
.main-controls-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.filter-group { 
    display: inline-flex; 
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}
.filter-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    border-left: 1px solid var(--border-color);
}
.filter-group .filter-btn:first-child { border-left: none; }
.filter-btn:hover { color: var(--primary-color); }
.filter-btn.active {
    background-color: var(--primary-color);
    color: var(--text-light);
}
.filter-btn svg { width: 18px; height: 18px; }

/* SHTESA: Stil për butonin e ri Share */
.action-btn-main {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.action-btn-main:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: scale(1.1);
}
.action-btn-main svg {
    width: 18px;
    height: 18px;
}


/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content { animation: fadeIn 0.6s ease-out 0.3s both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.hadith-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: var(--spacing-xl); }

/* ============================================
   HADITH CARD
   ============================================ */

.hadith-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    animation: cardFadeIn 0.5s ease-out;
}
@keyframes cardFadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.hadith-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition-base);
}
.hadith-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary-light); }
.hadith-card:hover::before { transform: scaleX(1); }

.hadith-content { flex-grow: 1; margin-bottom: var(--spacing-lg); }
.hadith-text { font-family: 'Merriweather', serif; font-size: 1.1rem; line-height: 1.8; color: var(--text-primary); font-style: italic; position: relative; padding-left: var(--spacing-lg); margin-bottom: var(--spacing-lg); }
.hadith-text::before { content: '"'; position: absolute; left: 0; top: -0.5rem; font-size: 3rem; color: var(--primary-light); opacity: 0.2; font-family: 'Merriweather', serif; }
.hadith-text .highlight, .hadith-meta .highlight { 
    background-color: rgba(245, 158, 11, 0.3); 
    padding: 0 2px; 
    border-radius: 3px;
    font-style: normal;
    color: var(--text-primary);
}

.hadith-meta { padding-top: var(--spacing-lg); border-top: 1px solid var(--border-light); }
.hadith-transmitter { font-weight: 600; color: var(--primary-color); font-size: 0.95rem; margin-bottom: var(--spacing-sm); display: block; }
.hadith-number { font-size: 0.85rem; color: var(--text-tertiary); font-style: italic; }

.card-actions { 
    display: flex; 
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--spacing-sm); 
    margin-top: var(--spacing-lg); 
    align-items: center; 
}
.main-actions { 
    display: flex; 
    gap: var(--spacing-sm); 
}

.share-actions-fallback { 
    flex-basis: 100%;
    display: flex; 
    gap: var(--spacing-sm); 
    border-top: 1px solid var(--border-light); 
    padding-top: var(--spacing-sm); 
    max-height: 0; 
    overflow: hidden; 
    opacity: 0; 
    transition: max-height var(--transition-base), opacity var(--transition-base), padding-top var(--transition-base); 
}
.card-actions.show-share .share-actions-fallback {
    max-height: 100px;
    opacity: 1;
}

.action-btn, .favorite-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.action-btn:hover, .favorite-btn:hover { 
    border-color: var(--primary-color); 
    color: var(--primary-color); 
    background: var(--bg-primary); 
    transform: scale(1.1); 
}
.action-btn.copy-btn.copied { 
    background: var(--success-color); 
    border-color: var(--success-color); 
    color: white; 
}
.action-btn svg, .favorite-btn svg { 
    width: 18px; 
    height: 18px; 
}
.favorite-btn:hover { 
    border-color: var(--danger-color); 
    color: var(--danger-color); 
}
.favorite-btn.favorited { 
    color: white; 
    background-color: var(--danger-color); 
    border-color: var(--danger-color); 
}
.favorite-btn.favorited svg { fill: white; }

#toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-dark);
    color: var(--text-light);
    padding: 14px 28px;
    border-radius: 50px;
    z-index: 2000;
    transition: bottom 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    font-weight: 500;
    font-size: 0.95rem;
}
#toast.show {
    bottom: 30px;
}


/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
    text-align: center;
    padding: var(--spacing-3xl) var(--spacing-xl);
    animation: fadeInUp 0.6s ease-out;
}

.empty-icon {
    width: 80px;
    height: 80px;
    color: var(--text-tertiary);
    margin: 0 auto var(--spacing-lg);
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
}

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

/* ============================================
   FOOTER
   ============================================ */

.footer {
    background: var(--bg-dark);
    color: var(--text-light);
    padding: var(--spacing-2xl) var(--spacing-lg);
    text-align: center;
    margin-top: var(--spacing-3xl);
    border-top: 1px solid var(--border-color);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color var(--transition-base);
}

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

/* ============================================
   LOADING INDICATOR
   ============================================ */

.loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition-slow);
    z-index: 1000;
}

.loading-indicator.active {
    transform: scaleX(1);
}

/* ============================================
   SCROLL TO TOP BUTTON
   ============================================ */

.scroll-to-top {
    position: fixed;
    bottom: var(--spacing-lg);
    right: var(--spacing-lg);
    width: 50px;
    height: 50px;
    background-color: var(--primary-color);
    color: var(--text-light);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 999;
    
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity var(--transition-base), visibility var(--transition-base), transform var(--transition-base);
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
}

.scroll-to-top svg {
    width: 24px;
    height: 24px;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    .container {
        padding: var(--spacing-lg) var(--spacing-md);
    }
    .hadith-grid {
        grid-template-columns: 1fr;
    }
    .controls-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .header-title {
        font-size: 2rem;
    }
    .header-subtitle {
        font-size: 1rem;
    }
    .search-section {
        padding: var(--spacing-lg);
    }
    .hadith-card {
        padding: var(--spacing-lg);
    }
}

@media (max-width: 480px) {
    .container {
        padding: var(--spacing-md);
    }
    .header {
        padding: var(--spacing-2xl) var(--spacing-md);
    }
    .search-section {
        padding: var(--spacing-md);
    }
    .search-input {
        font-size: 16px;
    }
    .hadith-grid {
        gap: var(--spacing-lg);
    }
    .hadith-card {
        padding: var(--spacing-md);
    }
    .hadith-text {
        font-size: 1rem;
    }
    .home-link {
        top: var(--spacing-md);
        left: var(--spacing-md);
    }
}

/* ============================================
   ACCESSIBILITY & PRINT
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

@media print {
    .header, .search-section, .footer, .card-actions, .scroll-to-top, .filter-group, .home-link {
        display: none;
    }
    .hadith-card {
        box-shadow: none;
        border: 1px solid #000;
        page-break-inside: avoid;
    }
    html, body {
        background-color: #fff !important;
        color: #000 !important;
    }
    :root {
        --primary-color: #000;
        --text-primary: #000;
        --text-secondary: #333;
        --bg-primary: #fff;
        --border-color: #ccc;
    }
}