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

:root {
    /* Colors */
    --primary-blue: #1a237e;
    --primary-purple: #512da8;
    --accent-gold: #ffc107;
    --white: #ffffff;
    --light-gray: #f5f5ff;
    --dark-gray: #333333;
    --text-secondary: #666666;
    --border-color: rgba(255, 255, 255, 0.1);
    
    /* Typography */
    --font-primary: 'Inter', 'Segoe UI', sans-serif;
    --font-mono: 'Roboto Mono', monospace;
    
    /* Spacing */
    --container-padding: 1rem;
    --section-padding: 2rem 0;
    
    /* Transitions */
    --transition: all 0.3s ease-in-out;
    
    /* Shadows */
    --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 20px rgba(0, 0, 0, 0.15);
    --shadow-heavy: 0 8px 30px rgba(0, 0, 0, 0.2);
}

body {
    font-family: var(--font-primary);
    line-height: 1.6;
    color: var(--white);
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-purple) 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

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

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-purple) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease-in-out;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
}

.loading-icon {
    font-size: 3rem;
    color: var(--accent-gold);
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

.loading-text {
    font-size: 1.2rem;
    color: var(--white);
    opacity: 0.8;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    gap: 1rem;
}

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

.logo i {
    font-size: 2rem;
    color: var(--accent-gold);
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--white);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.current-date {
    text-align: right;
}

.date-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.date-info span {
    font-size: 0.9rem;
    opacity: 0.8;
    white-space: nowrap;
}

/* Stile per il pulsante Home */
.back-to-main-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    color: var(--white);
    padding: 0.6rem 1rem;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    border: 1px solid var(--border-color);
    white-space: nowrap;
}

.back-to-main-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}


.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

/* Navigation */
.navigation {
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid var(--border-color);
}

.nav-content {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    justify-content: center;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    color: var(--white);
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
    transition: var(--transition);
    opacity: 0.7;
}

.nav-btn:hover,
.nav-btn.active {
    background: rgba(255, 255, 255, 0.1);
    opacity: 1;
    transform: translateY(-2px);
}

.nav-btn i {
    font-size: 1.1rem;
}

/* Main Content */
.main-content {
    padding: var(--section-padding);
    min-height: calc(100vh - 200px);
}

.view {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}

.view.active {
    display: block;
}

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


/* --- Styles for Initial Location Prompt --- */
.location-prompt-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2.5rem;
    margin: 2rem auto;
    max-width: 600px;
    text-align: center;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-medium);
}

.location-prompt-card i.fa-location-arrow {
    font-size: 3rem;
    color: var(--accent-gold);
    margin-bottom: 1rem;
}

.location-prompt-card h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.location-prompt-card p {
    font-size: 1.1rem;
    opacity: 0.8;
    margin-bottom: 2rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.location-btn {
    background: linear-gradient(135deg, var(--accent-gold) 0%, #ffb300 100%);
    color: var(--dark-gray);
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-medium);
}

.location-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-heavy);
}

.location-btn i {
    font-size: 1.2rem;
}

.location-status {
    min-height: 2rem;
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-weight: 500;
    animation: fadeIn 0.3s ease-in-out;
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

.status-message.success {
    background-color: rgba(76, 175, 80, 0.2);
    color: #81C784;
}
.status-message.error {
    background-color: rgba(244, 67, 54, 0.2);
    color: #E57373;
}
.status-message.loading .fa-spinner {
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Current Prayer Card */
.current-prayer-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    margin: 2rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-medium);
    border: 1px solid var(--border-color);
}

.current-prayer-info h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-gold);
    margin-bottom: 0.5rem;
}

.current-prayer-time {
    font-family: var(--font-mono);
    font-size: 3rem;
    font-weight: 500;
    color: var(--white);
    margin-bottom: 1rem;
}

.next-prayer-info {
    font-size: 1rem;
    opacity: 0.8;
}

.next-prayer-info span:nth-child(2) {
    color: var(--accent-gold);
    font-weight: 600;
}

/* Prayer Times Grid */
.prayer-times-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.prayer-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.prayer-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-heavy);
    background: rgba(255, 255, 255, 0.15);
}

.prayer-card.active {
    background: rgba(255, 193, 7, 0.2);
    border-color: var(--accent-gold);
}

.prayer-icon {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--accent-gold);
}

.prayer-info h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.prayer-time {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--accent-gold);
}

/* Progress Circle */
.progress-circle {
    position: relative;
    width: 120px;
    height: 120px;
}
.progress-ring {
    transform: rotate(-90deg);
}
.progress-ring-circle {
    stroke-dasharray: 339.292; /* 2 * PI * 54 */
    stroke-dashoffset: 339.292;
    transition: stroke-dashoffset 1s linear;
}
.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}
.progress-text span {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 500;
    display: block;
}
.progress-text small {
    font-size: 0.8rem;
    opacity: 0.7;
}


/* Calendar */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding: 1rem 0;
}

.month-nav-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--white);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.month-nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.calendar-header h2 {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
}

.calendar-grid-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 0.5rem;
    padding: 0 0.5rem;
}
.calendar-day-header {
    text-align: center;
    font-weight: 600;
    opacity: 0.7;
    font-size: 0.9rem;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.calendar-day {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.calendar-day:hover {
    background: rgba(255, 255, 255, 0.1);
}
.calendar-day.today {
    background: var(--accent-gold);
    color: var(--dark-gray);
    font-weight: 700;
}
.calendar-day.selected {
    background: rgba(255, 193, 7, 0.3);
    border: 2px solid var(--accent-gold);
}
.calendar-day-number {
    font-size: 1.1rem;
    font-weight: 600;
}
.calendar-day-hijri {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 0.25rem;
}

/* Selected Day Info */
.selected-day-info {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 2rem;
    border: 1px solid var(--border-color);
}
.selected-day-info h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--accent-gold);
}
.day-prayer-times {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}
.day-prayer-item {
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}
.day-prayer-item h4 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}
.day-prayer-item .time {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--accent-gold);
}


/* Footer */
.footer {
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: 3rem;
}
.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: center;
}
.footer-content p {
    opacity: 0.8;
}

/* Positions View Styles */
.positions-header {
    text-align: center;
    margin-bottom: 2rem;
}
.positions-header h2 {
    color: var(--accent-gold);
    margin-bottom: 0.5rem;
}
.positions-header p {
    opacity: 0.8;
}
.city-selector {
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
}
.city-dropdown {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    font-size: 1rem;
    min-width: 250px;
    cursor: pointer;
}
.city-dropdown:focus {
    outline: none;
    border-color: var(--accent-gold);
}
.city-dropdown option {
    background: var(--primary-blue);
}
.position-prayer-times {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}
.no-city-selected {
    text-align: center;
    padding: 3rem 1rem;
    opacity: 0.7;
}
.no-city-selected i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--accent-gold);
}
.position-times-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.position-time-card {
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 10px;
    text-align: center;
}
.position-time-card h4 {
    margin-bottom: 0.5rem;
    opacity: 0.9;
}
.position-time-card .time {
    font-size: 1.2rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--accent-gold);
}
.city-info {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(255, 193, 7, 0.1);
    border-radius: 10px;
}
.city-info h3 {
    color: var(--accent-gold);
}
.loading-position {
    text-align: center;
    padding: 2rem;
}
.loading-position i {
    font-size: 2rem;
    animation: spin 1s linear infinite;
    color: var(--accent-gold);
}

/* --- Qibla Compass Styles --- */
.qibla-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    text-align: center;
}
.location-details {
    margin-bottom: 1rem;
}
.location-name {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.location-name i {
    color: var(--accent-gold);
}
.location-name h3 {
    font-size: 1.2rem;
    font-weight: 500;
}

.qibla-header h3 {
    font-size: 1.5rem;
    color: var(--accent-gold);
    margin-bottom: 0.25rem;
}
.qibla-header p {
    font-family: var(--font-mono);
    opacity: 0.8;
}

.compass {
    position: relative;
    width: 250px;
    height: 250px;
    margin: 1.5rem auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.compass-indicator {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%) rotate(180deg);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 20px solid var(--accent-gold);
    z-index: 100;
}
.compass-circle {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 70%);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    position: relative;
}
.marker {
    position: absolute;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
    font-size: 1.2rem;
}
.marker.north { top: 10px; left: 50%; transform: translateX(-50%); }
.marker.south { bottom: 10px; left: 50%; transform: translateX(-50%); }
.marker.east { top: 50%; right: 10px; transform: translateY(-50%); }
.marker.west { top: 50%; left: 10px; transform: translateY(-50%); } /* Ovest */

.qibla-indicator {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    color: #4CAF50;
    font-size: 2.5rem;
    transition: transform 0.2s linear, color 0.3s ease, text-shadow 0.3s ease;
    transform-origin: center center;
}
.qibla-arrow-indicator {
    position: absolute; left: 50%; top: 0;
    transform: translateX(-50%);
    width: 0; height: 0;
    border-left: 8px solid transparent; border-right: 8px solid transparent;
    border-bottom: 16px solid #4CAF50;
    transition: border-color 0.3s ease;
}
.qibla-indicator.aligned {
    color: #81C784;
    text-shadow: 0 0 15px rgba(76, 175, 80, 0.8);
}
.qibla-indicator.aligned .qibla-arrow-indicator {
    border-bottom-color: #81C784;
}
.orientation-prompt {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 15px;
}
.orientation-prompt p {
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.retry-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
}
.retry-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.api-status .status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255,255,255, 0.1);
    border-radius: 20px;
    font-size: 0.85rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .date-info span#current-hijri { display: none; }
    .back-to-main-btn .btn-text {
        display: none; /* Nascondi solo il testo su schermi medi, lasciando l'icona */
    }
    .back-to-main-btn {
        padding: 0.6rem 0.8rem;
    }
}

@media (max-width: 768px) {
    :root { --container-padding: 1rem; }
    .logo h1 { font-size: 1.3rem; }
    .current-date, .back-to-main-btn { display: none; }
    .mobile-menu-btn { display: block; }
    .navigation {
        position: fixed; top: 0; left: -100%;
        width: 80%; height: 100vh;
        background: rgba(26, 35, 126, 0.95);
        backdrop-filter: blur(10px);
        transition: left 0.3s ease-in-out;
        z-index: 200;
        padding-top: 5rem;
    }
    .navigation.open { left: 0; }
    .nav-content { flex-direction: column; padding: 2rem; justify-content: flex-start; }
    .nav-btn { justify-content: flex-start; padding: 1rem 1.5rem; border-radius: 10px; width: 100%; }
    .current-prayer-card { flex-direction: column; text-align: center; gap: 2rem; }
    .current-prayer-time { font-size: 2.5rem; }
    .prayer-times-grid { grid-template-columns: 1fr; }
    .day-prayer-times { grid-template-columns: repeat(2, 1fr); }
    .footer-content { flex-direction: column; gap: 1rem; }
    .compass { width: 220px; height: 220px; }
}

@media (max-width: 480px) {
    .logo h1 { font-size: 1.1rem; }
    .logo i { font-size: 1.5rem; }
    .current-prayer-card { padding: 1.5rem; }
    .current-prayer-time { font-size: 2rem; }
    .calendar-day { min-height: 50px; padding: 0.25rem; }
    .calendar-day-number { font-size: 1rem; }
    .calendar-day-hijri { font-size: 0.7rem; }
}