/* --- Variables CSS --- */
:root {
    --primary-color: #2980b9; /* Azul */
    --secondary-color: #27ae60; /* Verde */
    --accent-color: #e74c3c; /* Rojo (para Qibla) */
    --background-color: #f4f7f6; /* Gris muy claro */
    --card-background-color: #ffffff;
    --text-color: #34495e; /* Gris oscuro azulado */
    --text-light-color: #7f8c8d; /* Gris claro */
    --border-color: #e0e5ec;
    --shadow-color: rgba(0, 0, 0, 0.08);
    --font-family: 'Poppins', sans-serif;
    --base-font-size: 16px;
    --border-radius: 8px;
    --card-padding: 20px;
    --section-spacing: 25px;
}

/* --- Reset Básico y Estilos Globales --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: var(--base-font-size);
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    padding: 20px;
    min-height: 100vh;
}

.app-container {
    max-width: 800px;
    width: 100%;
    background-color: var(--card-background-color);
    border-radius: var(--border-radius);
    box-shadow: 0 5px 20px var(--shadow-color);
    overflow: hidden; /* Contiene bordes redondeados */
}

/* --- Header --- */
.app-header {
    background-color: var(--primary-color);
    color: white;
    padding: var(--card-padding);
    text-align: center;
}

.app-header h1 {
    font-weight: 600;
    font-size: 1.8rem;
    margin-bottom: 5px;
}

.date-display {
    font-size: 0.95rem;
    opacity: 0.9;
}

/* --- Main Content Area --- */
.app-main {
    padding: var(--card-padding);
}

/* --- Secciones Generales --- */
section {
    margin-bottom: var(--section-spacing);
    padding: var(--card-padding);
    background-color: var(--card-background-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 5px var(--shadow-color);
}

section h2 {
    font-size: 1.4rem;
    color: var(--primary-color);
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px; /* Espacio entre icono y texto */
}

section h2 .fas, section h2 .far {
    color: var(--secondary-color); /* Iconos en color secundario */
}

/* --- Location Status & Errors --- */
.location-status {
    background-color: #e9f5ff; /* Fondo azul claro */
    border-color: #bde0fe;
    text-align: center;
    font-weight: 600;
    padding: 15px;
}
.error-message {
    color: var(--accent-color);
    font-weight: bold;
    margin-top: 10px;
}
#general-error:empty { /* Oculta si no hay error */
    display: none;
}


/* --- Manual Location Input --- */
.manual-location {
    background-color: #f8f9fa; /* Fondo ligeramente gris */
}

.manual-location h2 {
    color: var(--text-color);
    border-bottom-color: #dee2e6;
}
.manual-location h2 .fas {
     color: var(--primary-color);
}

.manual-inputs {
    display: flex;
    gap: 15px;
    align-items: flex-end; /* Alinea botón con la parte inferior del input */
    flex-wrap: wrap; /* Permite que el botón baje si no cabe */
}

.manual-inputs div {
    flex-grow: 1; /* Permite que el contenedor del input crezca */
}

.manual-inputs label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.9rem;
}

.manual-inputs input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    font-family: var(--font-family);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.manual-inputs input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.2);
}

.manual-inputs button {
    padding: 10px 15px;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-family: var(--font-family);
    font-weight: 600;
    transition: background-color 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap; /* Evita que el texto del botón se rompa */
}

.manual-inputs button:hover:not(:disabled) {
    background-color: #229954; /* Verde más oscuro */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.manual-inputs button:disabled {
    background-color: var(--text-light-color);
    cursor: not-allowed;
}

/* Spinner para botón de carga */
.spinner {
    display: inline-block;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    width: 1em; /* Tamaño relativo al texto del botón */
    height: 1em;
    animation: spin 1s linear infinite;
    margin-left: 5px; /* Espacio entre texto/icono y spinner */
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.api-credit {
    font-size: 0.8em;
    color: var(--text-light-color);
    margin-top: 15px;
    text-align: center;
}
.api-credit a {
    color: var(--primary-color);
    text-decoration: none;
}
.api-credit a:hover {
    text-decoration: underline;
}

/* --- Prayer Times Grid --- */
.prayer-times-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 15px;
}

.prayer-card {
    background-color: var(--card-background-color);
    padding: 15px;
    border-radius: var(--border-radius);
    text-align: center;
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}

.prayer-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 10px var(--shadow-color);
}

.prayer-card h3 {
    color: var(--primary-color);
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.prayer-card p {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-color);
}

/* --- Next Prayer Info --- */
.next-prayer-info {
    text-align: center;
    background: linear-gradient(135deg, var(--secondary-color), #2ecc71); /* Degradado verde */
    color: white;
    border: none;
}

.next-prayer-info h2 {
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.3);
    justify-content: center; /* Centra título e icono */
}
.next-prayer-info h2 .far {
    color: white; /* Icono blanco */
}

#next-prayer-name {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 5px;
}

#time-remaining {
    font-size: 2rem;
    font-weight: 300; /* Fuente más ligera para el contador */
    font-family: 'Courier New', Courier, monospace;
    letter-spacing: 2px;
}

/* --- Qibla Direction --- */
.qibla-info {
    text-align: center;
}
.qibla-info h2 .fas {
    color: var(--accent-color); /* Icono Kaaba en rojo */
}

.compass {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: var(--background-color); /* Fondo claro */
    position: relative;
    margin: 20px auto;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.05);
    display: flex; /* Para centrar la flecha fácilmente */
    justify-content: center;
    align-items: center;
}
.compass-dial { /* Opcional: Añadir marcas N,E,S,W o un fondo */
    width: 100%;
    height: 100%;
    border-radius: 50%;
    /* background-image: url('compass-background.svg'); */ /* Ejemplo */
    position: absolute;
    top: 0;
    left: 0;
}

.arrow {
    width: 4px; /* Ancho de la flecha */
    height: 50%; /* Largo desde el centro hasta casi el borde */
    background-color: var(--accent-color);
    position: absolute;
    top: 0; /* Se alinea desde el centro hacia arriba */
    left: calc(50% - 2px); /* Centrado horizontalmente */
    transform-origin: bottom center; /* El punto de rotación es el centro inferior */
    transform: rotate(0deg); /* JS ajustará esto */
    border-radius: 3px 3px 0 0; /* Punta redondeada */
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.5);
    transition: transform 0.5s ease-in-out; /* Animación suave */
}
.arrow::after { /* La punta de la flecha */
    content: '';
    position: absolute;
    top: -10px; /* Posiciona la punta arriba del cuerpo */
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 12px solid var(--accent-color);
}

#qibla-degrees {
    font-size: 1.2rem;
    font-weight: 600;
}

/* --- Footer --- */
.app-footer {
    text-align: center;
    padding: 15px;
    background-color: #e9ecef; /* Gris claro */
    color: var(--text-light-color);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
}

/* --- Helper Classes --- */
.visually-hidden { /* Para accesibilidad */
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}


/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    html {
        font-size: 15px; /* Ligeramente más pequeño en tablet */
    }
    .prayer-times-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 columnas en tablet */
    }
    .compass {
        width: 130px;
        height: 130px;
    }
    .app-main {
         padding: 15px;
    }
     section {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px; /* Más pequeño en móvil */
    }
    body {
        padding: 10px; /* Menos padding en body */
    }
    .app-header h1 {
        font-size: 1.6rem;
    }
    section h2 {
         font-size: 1.2rem;
    }
    .prayer-times-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 columnas en móvil */
        gap: 10px;
    }
    .prayer-card {
        padding: 12px;
    }
     .prayer-card p {
        font-size: 1.1rem;
    }
    .manual-inputs {
        flex-direction: column;
        align-items: stretch; /* Input y botón ocupan todo el ancho */
    }
     .manual-inputs button {
        margin-top: 10px; /* Espacio cuando el botón está abajo */
    }
    #next-prayer-name {
        font-size: 1.4rem;
    }
    #time-remaining {
        font-size: 1.7rem;
    }
    .compass {
        width: 110px;
        height: 110px;
    }
    .arrow::after { /* Punta más pequeña */
         border-left-width: 6px;
         border-right-width: 6px;
         border-bottom-width: 9px;
         top: -8px;
    }
    #qibla-degrees {
        font-size: 1.1rem;
    }
    .app-main {
        padding: 10px;
    }
    section {
        padding: 10px;
        margin-bottom: 20px;
    }
}