/**
 * Global Prayer Times - Main Stylesheet
 * RTL/LTR compatible using CSS Logical Properties
 */

/* ========================================
   CSS Variables
   ======================================== */
:root {
    /* Colors */
    --color-primary: #1a5f2a;
    --color-primary-dark: #145022;
    --color-primary-light: #2d8f42;
    --color-accent: #c9a227;
    --color-text: #1a1a1a;
    --color-text-muted: #666;
    --color-bg: #f5f7f5;
    --color-bg-card: #fff;
    --color-border: #e0e0e0;

    /* Typography */
    --font-system: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    --font-arabic: 'Noto Sans Arabic', 'Segoe UI', Tahoma, sans-serif;

    /* Spacing */
    --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-full: 9999px;

    /* 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: 250ms ease;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root {
        --color-text: #f0f0f0;
        --color-text-muted: #aaa;
        --color-bg: #121212;
        --color-bg-card: #1e1e1e;
        --color-border: #333;
    }
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-system);
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* RTL Font */
[dir="rtl"] body {
    font-family: var(--font-arabic);
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

/* ========================================
   Layout
   ======================================== */
.container {
    max-width: 1200px;
    margin-inline: auto;
    padding-inline: var(--space-md);
}

main {
    flex: 1;
    padding-block: var(--space-xl);
}

/* ========================================
   Header
   ======================================== */
.header {
    background: var(--color-primary);
    color: #fff;
    padding-block: var(--space-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: #fff;
    font-weight: 700;
    font-size: 1.25rem;
}

.logo:hover {
    color: #fff;
    opacity: 0.9;
}

.logo-icon {
    width: 32px;
    height: 32px;
}

.hijri-date {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* Language Switcher */
.lang-switcher {
    position: relative;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.875rem;
    transition: background var(--transition-fast);
}

.lang-btn:hover {
    background: rgba(255,255,255,0.2);
}

.lang-dropdown {
    position: absolute;
    top: 100%;
    inset-inline-end: 0;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 150px;
    margin-top: var(--space-xs);
    display: none;
    z-index: 200;
}

.lang-switcher:hover .lang-dropdown,
.lang-switcher:focus-within .lang-dropdown {
    display: block;
}

.lang-option {
    display: block;
    padding: var(--space-sm) var(--space-md);
    color: var(--color-text);
    transition: background var(--transition-fast);
}

.lang-option:hover {
    background: var(--color-bg);
}

.lang-option.active {
    background: var(--color-primary);
    color: #fff;
}

/* Breadcrumb */
.breadcrumb {
    background: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border);
    padding-block: var(--space-sm);
}

.breadcrumb-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    list-style: none;
    font-size: 0.875rem;
}

.breadcrumb-item:not(:last-child)::after {
    content: '/';
    margin-inline-start: var(--space-sm);
    color: var(--color-text-muted);
}

[dir="rtl"] .breadcrumb-item:not(:last-child)::after {
    content: '\\';
}

/* ========================================
   Hero Section
   ======================================== */
.hero {
    text-align: center;
    padding-block: var(--space-2xl);
}

.hero h1 {
    font-size: 2rem;
    margin-block-end: var(--space-sm);
    color: var(--color-primary);
}

.hero-subtitle {
    color: var(--color-text-muted);
    font-size: 1.125rem;
    margin-block-end: var(--space-xl);
}

/* Search Box */
.search-box {
    position: relative;
    max-width: 500px;
    margin-inline: auto;
}

.search-input {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    font-size: 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-bg-card);
    color: var(--color-text);
    transition: border-color var(--transition-fast);
}

.search-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.search-results {
    position: absolute;
    top: 100%;
    inset-inline: 0;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    margin-top: var(--space-sm);
    max-height: 300px;
    overflow-y: auto;
    display: none;
    z-index: 100;
}

.search-results.active {
    display: block;
}

.search-result-item {
    display: block;
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-border);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--color-bg);
}

/* ========================================
   Prayer Card
   ======================================== */
.prayer-card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--space-lg);
    margin-block-end: var(--space-xl);
}

/* Next Prayer */
.next-prayer {
    text-align: center;
    padding-block-end: var(--space-lg);
    margin-block-end: var(--space-lg);
    border-block-end: 1px solid var(--color-border);
}

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

.next-prayer-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-block: var(--space-xs);
}

.next-prayer-time {
    font-size: 2.5rem;
    font-weight: 700;
    font-feature-settings: 'tnum';
}

.countdown {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-xs);
    margin-block-start: var(--space-md);
    font-size: 1.5rem;
    font-weight: 600;
    font-feature-settings: 'tnum';
    color: var(--color-accent);
}

/* Prayer Times List */
.prayer-times {
    display: grid;
    gap: var(--space-sm);
}

.prayer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    background: var(--color-bg);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.prayer-row.is-next {
    background: var(--color-primary);
    color: #fff;
}

.prayer-name {
    font-weight: 500;
}

.prayer-time {
    font-size: 1.25rem;
    font-weight: 700;
    font-feature-settings: 'tnum';
}

.prayer-method {
    text-align: center;
    margin-block-start: var(--space-lg);
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* ========================================
   Countries Grid
   ======================================== */
.countries-section h2 {
    margin-block-end: var(--space-lg);
    font-size: 1.5rem;
}

.countries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-lg);
}

.country-group {
    background: var(--color-bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}

.country-letter {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-block-end: var(--space-sm);
    padding-block-end: var(--space-sm);
    border-block-end: 2px solid var(--color-primary);
}

.country-list {
    list-style: none;
}

.country-list li {
    padding-block: var(--space-xs);
}

.country-list a {
    color: var(--color-text);
}

.country-list a:hover {
    color: var(--color-primary);
}

/* ========================================
   Weekly Table
   ======================================== */
.weekly-section {
    margin-block-start: var(--space-xl);
}

.weekly-section h2 {
    margin-block-end: var(--space-md);
}

.weekly-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.weekly-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.weekly-table th,
.weekly-table td {
    padding: var(--space-sm) var(--space-md);
    text-align: center;
    border-bottom: 1px solid var(--color-border);
}

.weekly-table th {
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.875rem;
}

.weekly-table tr.is-today {
    background: rgba(26, 95, 42, 0.1);
}

.weekly-table td:first-child {
    text-align: start;
    font-weight: 500;
}

/* ========================================
   Location List
   ======================================== */
.location-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-sm);
    list-style: none;
}

.location-list a {
    display: block;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg-card);
    border-radius: var(--radius-md);
    color: var(--color-text);
    transition: background var(--transition-fast);
}

.location-list a:hover {
    background: var(--color-bg);
    color: var(--color-primary);
}

/* ========================================
   Footer
   ======================================== */
.footer {
    background: var(--color-bg-card);
    border-top: 1px solid var(--color-border);
    padding-block: var(--space-lg);
    margin-top: auto;
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
}

.copyright {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.footer-nav {
    display: flex;
    gap: var(--space-lg);
}

.footer-nav a {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.footer-nav a:hover {
    color: var(--color-primary);
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        text-align: center;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .next-prayer-time {
        font-size: 2rem;
    }

    .countdown {
        font-size: 1.25rem;
    }

    .countries-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .footer-inner {
        flex-direction: column;
        text-align: center;
    }
}

/* ========================================
   Utilities
   ======================================== */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.text-center { text-align: center; }
.text-start { text-align: start; }
.text-end { text-align: end; }
