/* Font Faces */
@font-face {
    font-family: Stam_Normal;
    src: url('TaameyAshkenaz-Bold.ttf');
    font-display: swap;
}

@font-face {
    font-family: Stam_Keren;
    src: url('Guttman_Keren.ttf');
    font-display: swap;
}

/* CSS Variables for Themes */
:root {
    --primary-color: #00b9f1;
    --primary-hover: #0099cc;
    --accent-color: #3300CC;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    
    /* Light Theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f0f8ff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #868e96;
    --border-color: #dee2e6;
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: rgba(0, 0, 0, 0.15);
    --shadow-heavy: rgba(0, 0, 0, 0.25);
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-medium: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Border Radius */
    --radius-small: 6px;
    --radius-medium: 10px;
    --radius-large: 15px;
    
    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 3rem;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #404040;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-muted: #888888;
    --border-color: #404040;
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-medium: rgba(0, 0, 0, 0.4);
    --shadow-heavy: rgba(0, 0, 0, 0.6);
    --primary-color: #4db8e8;
    --primary-hover: #3da8d8;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color var(--transition-medium), color var(--transition-medium);
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    transition: all var(--transition-medium);
    box-shadow: 0 4px 12px var(--shadow-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.theme-toggle:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* Header Styles */
.header {
    background: var(--bg-primary);
    box-shadow: 0 2px 20px var(--shadow-light);
    margin-bottom: var(--space-lg);
}

.banner {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.banner::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"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="1"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.3;
}

.logo {
    height: 80px;
    width: auto;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    position: relative;
    z-index: 2;
    transition: transform var(--transition-medium);
}

.logo:hover {
    transform: scale(1.05);
}

.header-content {
    padding: var(--space-lg);
    text-align: center;
}

.main-title {
    font-family: Stam_Keren, sans-serif;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    font-weight: 700;
}

.subtitle {
    font-family: Stam_Keren, sans-serif;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
    font-weight: 500;
}

.zohar-quote {
    background: var(--bg-tertiary);
    padding: var(--space-md);
    border-radius: var(--radius-medium);
    border-right: 4px solid var(--primary-color);
    margin: var(--space-md) 0;
    transition: all var(--transition-medium);
}

.zohar-quote:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--shadow-light);
}

.quote-text {
    font-family: Stam_Normal, cursive, sans-serif;
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    color: var(--accent-color);
    line-height: 1.8;
    margin-bottom: var(--space-sm);
    text-align: justify;
}

.quote-source {
    font-family: Stam_Keren, sans-serif;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
}

.quote-source:hover {
    color: var(--primary-color);
}

/* Controls Section */
.controls-section {
    max-width: 1200px;
    margin: 0 auto var(--space-lg);
    padding: 0 var(--space-md);
}

.search-container {
    position: relative;
    max-width: 400px;
    margin: 0 auto var(--space-md);
}

.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    z-index: 2;
}

.search-input {
    width: 100%;
    padding: 12px 50px 12px 40px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-medium);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all var(--transition-medium);
    font-family: inherit;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 185, 241, 0.1);
    transform: translateY(-1px);
}

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

.clear-search {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    display: none;
    transition: all var(--transition-fast);
}

.clear-search:hover {
    background: var(--bg-secondary);
    color: var(--danger-color);
}

.stats {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.stat-separator {
    color: var(--text-muted);
}

/* Main Content */
.parashot-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-md) var(--space-xl);
}

.parashot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-md);
    animation: fadeIn 0.6s ease-out;
}

.parasha-card {
    background: var(--bg-primary);
    border-radius: var(--radius-medium);
    border: 1px solid var(--border-color);
    transition: all var(--transition-medium);
    overflow: hidden;
    position: relative;
    opacity: 0;
    transform: translateY(20px);
}

.parasha-card.loaded {
    opacity: 1;
    transform: translateY(0);
}

.parasha-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px var(--shadow-medium);
}

.parasha-card.available:hover {
    border-color: var(--primary-color);
}

.parasha-card.unavailable {
    opacity: 0.7;
    cursor: not-allowed;
}

.parasha-link {
    display: block;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

.parasha-content {
    padding: var(--space-md);
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 140px;
}

.parasha-name {
    font-family: Stam_Keren, sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
    color: var(--text-primary);
    text-align: center;
    line-height: 1.4;
}

.parasha-count {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--space-sm);
}

.parasha-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius-small);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.available-status {
    background: rgba(40, 167, 69, 0.1);
    color: var(--success-color);
}

.unavailable-status {
    background: rgba(255, 193, 7, 0.1);
    color: var(--warning-color);
}

/* No Results */
.no-results {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-secondary);
    animation: fadeIn 0.3s ease-out;
}

.no-results i {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    color: var(--text-muted);
}

.no-results h3 {
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

.hidden {
    display: none !important;
}

/* Footer */
.footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    margin-top: var(--space-xl);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md);
    text-align: center;
}

.copyright h4 {
    font-family: Stam_Keren, sans-serif;
    margin-bottom: var(--space-md);
    color: var(--text-primary);
    font-size: 1.1rem;
}

.copyright p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.8;
    margin-bottom: var(--space-sm);
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Error Message */
.error-message {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger-color);
    padding: var(--space-md);
    border-radius: var(--radius-medium);
    text-align: center;
    margin: var(--space-lg);
    border: 1px solid rgba(220, 53, 69, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .theme-toggle {
        top: 15px;
        left: 15px;
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
    
    .banner {
        height: 100px;
    }
    
    .logo {
        height: 70px;
    }
    
    .header-content {
        padding: var(--space-md);
    }
    
    .parashot-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: var(--space-sm);
    }
    
    .controls-section {
        padding: 0 var(--space-sm);
    }
    
    .search-container {
        max-width: none;
    }
    
    .stats {
        flex-direction: column;
        gap: var(--space-xs);
    }
    
    .footer-content {
        padding: var(--space-md);
    }
}

@media (max-width: 480px) {
    .parashot-grid {
        grid-template-columns: 1fr;
    }
    
    .parasha-content {
        padding: var(--space-sm);
        min-height: 120px;
    }
    
    .parasha-name {
        font-size: 1.1rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --shadow-light: rgba(0, 0, 0, 0.5);
        --shadow-medium: rgba(0, 0, 0, 0.7);
    }
    
    [data-theme="dark"] {
        --border-color: #ffffff;
        --text-secondary: #ffffff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .theme-toggle:hover,
    .parasha-card:hover {
        transform: none;
    }
}