/* ===== Prayer Page Styles ===== */
.prayer-page { max-width: 1000px; margin: 0 auto; padding: 16px; }

/* Tabs */
.prayer-tabs {
    display: flex; gap: 4px; margin-bottom: 20px;
    background: var(--surface); border-radius: 12px; padding: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.prayer-tab {
    flex: 1; padding: 12px 16px; border: none; background: none;
    border-radius: 8px; cursor: pointer; font-size: 1rem; font-weight: 500;
    color: var(--text-muted); transition: all .2s;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.prayer-tab.active { background: var(--primary); color: #fff; }
.prayer-tab:hover:not(.active) { background: var(--surface-hover); }

/* Tab content */
.prayer-tab-content { display: none; animation: fadeIn .3s; }
.prayer-tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Geo status */
.geo-status { margin-bottom: 12px; }
.geo-status-inner {
    display: flex; align-items: center; gap: 12px;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border-radius: 10px; padding: 12px 16px; color: #1565c0;
    font-weight: 500;
}
.geo-status-inner i { font-size: 1.3rem; }
.geo-status.error .geo-status-inner {
    background: linear-gradient(135deg, #ffebee, #ffcdd2); color: #c62828;
}
.geo-status.success .geo-status-inner {
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9); color: #2e7d32;
}

/* City search bar */
.city-search-bar { margin-bottom: 16px; }
.city-search-inner {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface); border-radius: 10px; padding: 8px 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06); flex-wrap: wrap; position: relative;
}
.city-search-inner > i { color: var(--text-muted); font-size: 1.1rem; }
.city-search-inner input {
    flex: 1; min-width: 200px; border: 1px solid #dee2e6; border-radius: 6px;
    padding: 8px 12px; font-size: 1rem; background: #fff;
}
.city-search-inner input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,110,253,.1); }

/* Dropdown risultati ricerca città */
.city-results-dropdown {
    display: none; position: absolute; top: 100%; left: 40px; right: 60px;
    background: #fff; border: 1px solid #dee2e6; border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15); max-height: 300px; overflow-y: auto;
    z-index: 1000; margin-top: 4px;
}
.city-results-dropdown.show { display: block; }
.city-result-item {
    padding: 10px 14px; cursor: pointer; border-bottom: 1px solid #f0f0f0;
    font-size: .9rem; display: flex; align-items: center; gap: 8px;
}
.city-result-item:hover { background: #f0f7ff; }
.city-result-item i { color: var(--primary); }
.city-result-item .result-name { font-weight: 500; }
.city-result-item .result-detail { color: var(--text-muted); font-size: .8rem; }

/* City bar */
.prayer-city-bar {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
    background: var(--surface); border-radius: 12px; padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.prayer-city-info { display: flex; align-items: center; gap: 8px; font-size: 1.1rem; font-weight: 600; }
.prayer-city-info i { color: var(--primary); }
.prayer-date-info { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

/* Current prayer box */
.current-prayer-box {
    background: linear-gradient(135deg, var(--primary), #0b5ed7);
    color: #fff; border-radius: 16px; padding: 24px; margin-bottom: 24px;
    text-align: center; box-shadow: 0 8px 24px rgba(13,110,253,.3);
}
.current-prayer-label { font-size: .9rem; opacity: .85; text-transform: uppercase; letter-spacing: 1px; }
.current-prayer-name { font-size: 2.5rem; font-weight: 700; margin: 8px 0; }
.current-prayer-time { font-size: 1.5rem; opacity: .9; }
.current-prayer-next {
    margin-top: 16px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.2);
    display: flex; justify-content: center; align-items: center; gap: 12px; font-size: 1rem;
}
.countdown { font-weight: 700; font-size: 1.2rem; background: rgba(255,255,255,.15); padding: 4px 12px; border-radius: 20px; }

/* Prayers grid */
.prayers-grid {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px;
}
.prayer-card {
    background: var(--surface); border-radius: 12px; padding: 20px 12px;
    text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,.06);
    transition: all .3s; border: 2px solid transparent;
}
.prayer-card.active {
    border-color: var(--primary); background: linear-gradient(135deg, #e3f2fd, #fff);
    transform: translateY(-4px); box-shadow: 0 8px 24px rgba(13,110,253,.2);
}
.prayer-card.active .prayer-icon { color: var(--primary); }
.prayer-card.passed { opacity: .55; }
.prayer-icon { font-size: 2rem; color: var(--text-muted); margin-bottom: 8px; }
.prayer-name { font-weight: 600; margin-bottom: 4px; font-size: .95rem; }
.prayer-time { font-size: 1.3rem; font-weight: 700; color: var(--primary); }

/* ===== Qibla ===== */
.qibla-container { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; justify-content: center; }
.qibla-info { flex: 1; min-width: 280px; }
.qibla-info h2 { margin-bottom: 8px; }
.qibla-info p { color: var(--text-muted); margin-bottom: 20px; }
.qibla-angle-box {
    background: var(--surface); border-radius: 12px; padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06); text-align: center;
}
.qibla-angle-label, .qibla-distance-label { font-size: .85rem; color: var(--text-muted); text-transform: uppercase; }
.qibla-angle-value { font-size: 2.5rem; font-weight: 700; color: var(--primary); margin: 4px 0 12px; }
.qibla-distance-value { font-size: 1.5rem; font-weight: 600; color: var(--secondary); }

/* Compass */
.qibla-compass-wrapper { display: flex; justify-content: center; }
.qibla-compass {
    position: relative; width: 320px; height: 320px;
    border-radius: 50%; background: radial-gradient(circle, #fff 60%, #f0f0f0);
    box-shadow: 0 8px 32px rgba(0,0,0,.15), inset 0 0 20px rgba(0,0,0,.05);
    border: 4px solid #e0e0e0;
}
.compass-ring {
    position: absolute; inset: 0; border-radius: 50%;
    transition: transform .1s linear;
}
.compass-mark {
    position: absolute; font-size: 1.4rem; font-weight: 700; color: #333;
    transform: translate(-50%, -50%);
}
.compass-n { top: 8%; left: 50%; color: #d32f2f; }
.compass-e { top: 50%; right: 8%; transform: translate(50%, -50%); }
.compass-s { bottom: 8%; left: 50%; transform: translate(-50%, 50%); }
.compass-w { top: 50%; left: 8%; transform: translate(-50%, -50%); }
.compass-ticks { position: absolute; inset: 0; border-radius: 50%; }
.compass-ticks::before, .compass-ticks::after {
    content: ''; position: absolute; inset: 0; border-radius: 50%;
    background:
        conic-gradient(from 0deg, transparent 0deg 4deg, #ccc 4deg 5deg, transparent 5deg 10deg,
        transparent 10deg 14deg, #999 14deg 15deg, transparent 15deg 20deg,
        transparent 20deg 24deg, #ccc 24deg 25deg, transparent 25deg 30deg,
        transparent 30deg 34deg, #ccc 34deg 35deg, transparent 35deg 40deg,
        transparent 40deg 44deg, #999 44deg 45deg, transparent 45deg 50deg,
        transparent 50deg 54deg, #ccc 54deg 55deg, transparent 55deg 60deg,
        transparent 60deg 64deg, #ccc 64deg 65deg, transparent 65deg 70deg,
        transparent 70deg 74deg, #999 74deg 75deg, transparent 75deg 80deg,
        transparent 80deg 84deg, #ccc 84deg 85deg, transparent 85deg 90deg);
    -webkit-mask: radial-gradient(circle, transparent 78%, #000 78%, #000 88%, transparent 88%);
    mask: radial-gradient(circle, transparent 78%, #000 78%, #000 88%, transparent 88%);
}

/* Qibla needle */
.qibla-needle {
    position: absolute; top: 50%; left: 50%; width: 8px; height: 70%;
    transform: translate(-50%, -50%) rotate(0deg);
    transform-origin: center center; transition: transform .3s ease;
    z-index: 5; pointer-events: none;
}
.qibla-needle-top {
    position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 0; height: 0; border-left: 12px solid transparent; border-right: 12px solid transparent;
    border-bottom: 50px solid #1b5e20; filter: drop-shadow(0 2px 4px rgba(0,0,0,.3));
}
.qibla-needle-bottom {
    position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
    width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent;
    border-top: 30px solid #c62828; opacity: .4;
}

.compass-center {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 16px; height: 16px; border-radius: 50%; background: #333;
    box-shadow: 0 2px 8px rgba(0,0,0,.3); z-index: 6;
}
.compass-kaaba {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    font-size: 2rem; z-index: 7; pointer-events: none; opacity: 0; transition: opacity .3s;
}
.qibla-compass.ready .compass-kaaba { opacity: 1; }

.qibla-instructions { margin-top: 20px; text-align: center; color: var(--text-muted); }
.qibla-instructions p { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); padding: 12px 20px; border-radius: 10px; }

/* ===== Month table ===== */
.month-controls {
    display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
    flex-wrap: wrap; justify-content: center;
}
.month-title { font-size: 1.3rem; font-weight: 700; min-width: 200px; text-align: center; }

.month-table-wrapper { overflow-x: auto; }
.month-table {
    width: 100%; border-collapse: collapse; font-size: .9rem;
    background: var(--surface); border-radius: 12px; overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.month-table th {
    background: var(--primary); color: #fff; padding: 10px 8px; text-align: center;
    font-weight: 600; white-space: nowrap;
}
.month-table td { padding: 8px; text-align: center; border-bottom: 1px solid #eee; }
.month-table tr:hover td { background: #f8f9fa; }
.month-table tr.holiday td { color: #c62828; font-weight: 700; background: #fff5f5; }
.month-table tr.holiday .day-name { color: #c62828; }
.month-table tr.friday td { background: #f0f7ff; }
.month-table tr.friday .day-name { color: var(--primary); font-weight: 600; }
.month-table tr.today td { background: #e8f5e9; font-weight: 600; }
.month-table .day-name { font-weight: 600; }
.month-table .holiday-note { color: #c62828; font-weight: 700; font-size: .8rem; }

/* Print A4 - una sola pagina */
@media print {
    @page { size: A4 landscape; margin: 5mm; }
    html, body { height: auto !important; overflow: visible !important; margin: 0; padding: 0; }
    body * { visibility: hidden; }
    .prayer-page, .prayer-page * { visibility: visible; }
    .prayer-tabs, .geo-status, .month-controls, .no-print, .city-search-bar,
    #tab-today, #tab-qibla, #tab-moon, .qibla-container, .moon-phase-section { display: none !important; }
    .prayer-tab-content { display: none !important; }
    #tab-month { display: block !important; }
    .prayer-page { padding: 0; max-width: 100%; margin: 0; }
    .print-header { display: block !important; text-align: center; margin-bottom: 4px; }
    .print-header h1 { font-size: 1.1rem; margin: 0; font-weight: 700; }
    .month-table-wrapper { overflow: visible; }
    .month-table {
        font-size: .5rem; box-shadow: none; border-collapse: collapse;
        width: 100%; table-layout: fixed;
    }
    .month-table th { padding: 2px 1px; font-size: .5rem; line-height: 1; }
    .month-table td { padding: 1px 1px; line-height: 1; white-space: nowrap; overflow: hidden; }
    .month-table tr { page-break-inside: avoid; }
    .month-table tr.holiday td { background: #fff5f5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .month-table tr.friday td { background: #f0f7ff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* RTL */
html[dir="rtl"] .prayer-tab i, html[dir="rtl"] .qibla-info i { margin-left: 4px; }
html[dir="rtl"] .prayer-city-info { flex-direction: row-reverse; }
html[dir="rtl"] .prayer-date-info { align-items: flex-start; }

/* Mobile */
/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    .prayers-grid { grid-template-columns: repeat(2, 1fr); }
    .prayer-tab { font-size: .75rem; padding: 10px 4px; }
    .prayer-tab i { display: none; }
    .qibla-compass { width: 240px; height: 240px; }
    .qibla-container { flex-direction: column; }
    .current-prayer-name { font-size: 1.5rem; }
    .month-table { font-size: .65rem; }
    .month-table th, .month-table td { padding: 3px 2px; }
    .city-search-inner { flex-wrap: wrap; gap: 6px; }
    .city-search-inner input { min-width: 140px; flex: 1; }
    .city-search-inner .btn { flex: 0 0 auto; }
    .moon-phase-container { flex-direction: column; }
    #moonCanvas { width: 140px; height: 140px; }
    .moon-phase-name { font-size: 1.4rem; }
}

@media (max-width: 480px) {
    .prayer-page { padding: 8px; }
    .prayer-tabs { flex-wrap: wrap; gap: 2px; }
    .prayer-tab { font-size: .7rem; padding: 8px 4px; flex: 1 0 45%; }
    .prayers-grid { grid-template-columns: 1fr; }
    .prayer-card { padding: 12px; }
    .prayer-time { font-size: 1.8rem; }
    .current-prayer-card { padding: 16px; }
    .current-prayer-name { font-size: 1.3rem; }
    .next-prayer-info { font-size: .9rem; }
    .qibla-compass { width: 200px; height: 200px; }
    .compass-mark { font-size: .8rem; }
    .qibla-angle-value { font-size: 1.5rem; }
    .month-table { font-size: .55rem; }
    .month-table th, .month-table td { padding: 2px 1px; }
    .city-search-inner input { min-width: 120px; font-size: .85rem; }
    .moon-phase-section { padding: 16px; }
    #moonCanvas { width: 120px; height: 120px; }
    .moon-info { min-width: 100%; }
    .moon-detail-row { padding: 6px 8px; font-size: .85rem; }
}

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin 1s linear infinite; }

/* ===== Moon Phase ===== */
.moon-phase-section {
    margin-top: 32px; padding: 24px;
    background: linear-gradient(135deg, #0d1117, #161b22);
    border-radius: 16px; color: #e6edf3;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.moon-phase-title { margin: 0 0 16px; font-size: 1.3rem; color: #e6edf3; }
.moon-phase-title i { color: #f0c040; }
.moon-phase-container { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; justify-content: center; }
.moon-visual { flex-shrink: 0; }
#moonCanvas { display: block; border-radius: 50%; box-shadow: 0 0 40px rgba(240,192,64,.2); }
.moon-info { flex: 1; min-width: 250px; }
.moon-phase-name { font-size: 1.8rem; font-weight: 700; color: #f0c040; margin-bottom: 4px; }
.moon-phase-emoji { font-size: 2rem; margin-bottom: 12px; }
.moon-details { display: grid; gap: 8px; }
.moon-detail-row { display: flex; justify-content: space-between; padding: 8px 12px; background: rgba(255,255,255,.05); border-radius: 8px; }
.moon-detail-label { color: #8b949e; font-size: .9rem; }
.moon-detail-value { font-weight: 600; color: #e6edf3; }
.moon-location { margin-top: 12px; color: #8b949e; font-size: .85rem; display: flex; align-items: center; gap: 4px; }

html[dir="rtl"] .moon-detail-row { flex-direction: row-reverse; }
