/* ===============================
   PRAYER TIMES – MATCH DESIGN
   =============================== */

:root {
    --primary-color: #0f766e;
    --primary-light: rgba(16, 163, 127, 0.12);
    --primary-dark: #0d6c65;
    --secondary-color: #10a37f;
    --accent-yellow: #facc15;
    --accent-yellow-light: #fde047;
    --text-dark: #0f172a;
    --text-medium: #1e293b;
    --text-light: #475569;
    --bg-light: #f8fafc;
    --bg-white: #fff;
    --border-color: #e2e8f0;
    --hover-color: #e2e8f0;
    --shadow-light: 0 8px 32px rgba(16, 163, 127, 0.08);
    --shadow-medium: 0 12px 30px rgba(16, 163, 127, 0.35);
    --shadow-heavy: 0 12px 40px rgba(16, 163, 127, 0.5);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 999px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.prayer-times-section {
    padding: 2rem 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    color: var(--text-medium);
}

/* ===== UTIL CLASSES ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== COMMON CONTAINER ===== */
.prayer-times,
.monthly-prayer-times {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: clamp(1.5rem, 5vw, 2rem);
    margin: 1.5rem 0;
    box-shadow: var(--shadow-light);
    transition: var(--transition);
}

.prayer-times:hover,
.monthly-prayer-times:hover {
    box-shadow: 0 12px 40px rgba(16, 163, 127, 0.12);
}

/* ===== HEADER COMMON ===== */
.prayer-header,
.monthly-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--primary-light);
    flex-wrap: wrap;
}

.prayer-header h2,
.monthly-header h2 {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    font-size: clamp(1.2rem, 2vw, 1.4rem);
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    line-height: 1.3;
}

.prayer-header h2 i,
.monthly-header h2 i {
    font-size: 1.2em;
    color: var(--secondary-color);
}

/* ===== CURRENT DATE DISPLAY ===== */
.current-date {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.gregorian-date {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-dark);
    white-space: nowrap;
}

.hijri-date {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-color);
    background: var(--primary-light);
    padding: 0.375rem 1rem;
    border-radius: var(--radius-full);
    line-height: 1;
    transition: var(--transition);
    gap: 0.5rem;
}

.hijri-date:hover {
    background: rgba(16, 163, 127, 0.2);
    transform: translateY(-1px);
}

/* ===== PRAYER GRID (DAILY) ===== */
.prayer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
    gap: 1.25rem;
    margin: 0;
}

/* PRAYER CARD */
.prayer-card {
    position: relative;
    aspect-ratio: 1;
    background: var(--bg-light);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
    transition: var(--transition);
    overflow: hidden;
    padding: 1rem;
    cursor: pointer;
    user-select: none;
}

.prayer-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: transparent;
    transition: var(--transition);
}

.prayer-card:hover:not(.active) {
    border-color: var(--primary-light);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(16, 163, 127, 0.15);
}

.prayer-card:hover:not(.active)::before {
    background: var(--primary-color);
}

/* ICON */
.prayer-card .icon-wrapper {
    position: relative;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    transition: var(--transition);
}

.prayer-card i {
    font-size: 1.75rem;
    color: var(--primary-color);
    transition: var(--transition);
}

/* NAME */
.prayer-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-dark);
    transition: var(--transition);
}

/* TIME */
.prayer-time {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
    letter-spacing: -0.5px;
    transition: var(--transition);
}

/* ===== ACTIVE CARD ===== */
.prayer-card.active {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    border: none;
    box-shadow: var(--shadow-medium);
    animation: card-pulse 3s ease-in-out infinite;
    transform: scale(1.02);
}

.prayer-card.active::before {
    background: var(--accent-yellow);
    height: 6px;
}

.prayer-card.active .icon-wrapper {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.prayer-card.active i,
.prayer-card.active .prayer-name,
.prayer-card.active .prayer-time {
    color: white;
}

@keyframes card-pulse {
    0%, 100% {
        box-shadow: var(--shadow-medium);
        transform: scale(1.02);
    }
    50% {
        box-shadow: var(--shadow-heavy), 0 0 30px rgba(16, 163, 127, 0.4);
        transform: scale(1.03);
    }
}

/* ===== COUNTDOWN BADGE ===== */
.prayer-countdown {
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(135deg, var(--accent-yellow), #eab308);
    color: var(--text-dark);
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-full);
    min-width: 72px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(250, 204, 21, 0.3);
    z-index: 10;
    animation: countdown-float 2s ease-in-out infinite;
    border: 2px solid rgba(255, 255, 255, 0.9);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

@keyframes countdown-float {
    0%, 100% {
        transform: translateY(0) scale(1);
        box-shadow: 0 4px 12px rgba(250, 204, 21, 0.3);
    }
    50% {
        transform: translateY(-2px) scale(1.05);
        box-shadow: 0 6px 20px rgba(250, 204, 21, 0.4);
    }
}

/* ===== FOOTER ===== */
.prayer-footer {
    margin-top: 2rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, rgba(16, 163, 127, 0.1), rgba(15, 118, 110, 0.05));
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    color: var(--primary-color);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    text-align: center;
    border: 1px solid var(--primary-light);
}

.prayer-footer i {
    font-size: 1.1rem;
}

/* ===== LOADING STATES ===== */
.prayer-loading,
.monthly-loading {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    gap: 1.5rem;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(16, 163, 127, 0.1);
    border-top: 3px solid var(--secondary-color);
    border-right: 3px solid var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
}

.loading-spinner + p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-light);
    font-weight: 500;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* ===== MONTHLY TABLE SPECIFIC ===== */
.monthly-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

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

.month-navigation button {
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-medium);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-width: 120px;
}

.month-navigation button:hover:not(:disabled) {
    background: var(--hover-color);
    border-color: var(--primary-light);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.month-navigation button:active:not(:disabled) {
    transform: translateY(0);
}

.month-navigation button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.current-month {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    min-width: 200px;
    text-align: center;
    padding: 0.5rem 1rem;
    background: var(--primary-light);
    border-radius: var(--radius-full);
    order: 1;
    flex: 1;
}

.today-btn {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color)) !important;
    color: white !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(16, 163, 127, 0.3);
}

.today-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark)) !important;
    box-shadow: 0 6px 20px rgba(16, 163, 127, 0.4);
}

/* TABLE CONTAINER */
.monthly-table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

.monthly-table-container::-webkit-scrollbar {
    height: 8px;
}

.monthly-table-container::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 4px;
}

.monthly-table-container::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.monthly-table-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* TABLE STYLES */
.monthly-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 800px;
    font-size: 0.9rem;
}

.monthly-table thead {
    position: sticky;
    top: 0;
    z-index: 100;
}

.monthly-table thead tr {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
}

.monthly-table th {
    padding: 1rem;
    text-align: center;
    font-weight: 700;
    color: white;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    position: relative;
    white-space: nowrap;
}

.monthly-table th:last-child {
    border-right: none;
}

.monthly-table th .hijri-day {
    display: block;
    font-size: 0.75rem;
    opacity: 0.9;
    margin-top: 4px;
    font-weight: 500;
    text-transform: none;
}

/* TABLE BODY */
.monthly-table tbody tr {
    transition: var(--transition);
    background: white;
}

.monthly-table tbody tr:nth-child(even) {
    background: var(--bg-light);
}

.monthly-table tbody tr:hover {
    background: rgba(16, 163, 127, 0.05);
}

.monthly-table td {
    padding: 1rem;
    text-align: center;
    color: var(--text-medium);
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    transition: var(--transition);
}

.monthly-table td:last-child {
    border-right: none;
}

.monthly-table tbody tr:last-child td {
    border-bottom: none;
}

/* DAY CELL */
.day-cell {
    font-weight: 700;
    color: var(--text-dark);
    position: relative;
    min-width: 80px;
}

.day-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-light);
    color: var(--text-dark);
    font-weight: 700;
    margin-bottom: 0.5rem;
    transition: var(--transition);
}

/* TODAY HIGHLIGHT */
.monthly-table .today {
    background: linear-gradient(135deg, rgba(16, 163, 127, 0.1), rgba(15, 118, 110, 0.05));
    position: relative;
}

.monthly-table .today::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary-color);
    border-radius: 2px;
}

.monthly-table .today .day-number {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.monthly-table .today td:not(.day-cell) {
    color: var(--primary-dark);
    font-weight: 600;
}

/* PRAYER TIME CELLS */
.prayer-time-cell {
    font-weight: 600;
    min-width: 70px;
    position: relative;
}

.next-prayer-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent-yellow);
    border-radius: 50%;
    margin-left: 6px;
    vertical-align: middle;
    animation: indicator-pulse 2s ease-in-out infinite;
    box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.3);
}

@keyframes indicator-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.3);
    }
    50% {
        transform: scale(1.3);
        box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.5);
    }
}

/* HIJRI DATE IN TABLE */
.hijri-date-small {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
    margin-top: 0.25rem;
}

/* ERROR STATES */
.monthly-error {
    text-align: center;
    padding: 3rem 1rem;
    grid-column: 1 / -1;
}

.error-icon {
    font-size: 3rem;
    color: #ef4444;
    margin-bottom: 1rem;
    opacity: 0.8;
}

.monthly-error p {
    color: var(--text-medium);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.retry-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3);
}

/* ===== RESPONSIVE DESIGN ===== */

/* Tablet */
@media (max-width: 768px) {
    .prayer-header,
    .monthly-header {
        flex-direction: column;
        text-align: center;
        gap: 1.25rem;
    }
    
    .current-date {
        align-items: center;
    }
    
    .monthly-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .current-month {
        order: -1;
        width: 100%;
    }
    
    .month-navigation {
        width: 100%;
        justify-content: center;
    }
    
    .month-navigation button {
        flex: 1;
        min-width: 0;
    }
    
    .monthly-table th,
    .monthly-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }
    
    .prayer-time-cell {
        min-width: 60px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .prayer-grid {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: 0.75rem;
        padding: 0.5rem 0 1rem;
        margin: 0 -1rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .prayer-grid::after {
        content: '';
        flex: 0 0 1rem;
    }
    
    .prayer-card {
        flex: 0 0 auto;
        width: 120px;
        height: 120px;
        scroll-snap-align: start;
        border-radius: var(--radius-sm);
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .prayer-card .icon-wrapper {
        width: 48px;
        height: 48px;
    }
    
    .prayer-card i {
        font-size: 1.5rem;
    }
    
    .prayer-name {
        font-size: 0.85rem;
    }
    
    .prayer-time {
        font-size: 1.2rem;
    }
    
    .prayer-countdown {
        top: 8px;
        right: 8px;
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
        min-width: 60px;
    }
    
    .prayer-times,
    .monthly-prayer-times {
        padding: 1.25rem;
        margin: 1rem 0;
    }
    
    .monthly-table {
        min-width: 600px;
    }
    
    .monthly-table th,
    .monthly-table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.8rem;
    }
    
    .day-number {
        width: 28px;
        height: 28px;
    }
    
    .hijri-date-small {
        font-size: 0.7rem;
    }
}

/* Small Mobile */
@media (max-width: 360px) {
    .prayer-card {
        width: 110px;
        height: 110px;
    }
    
    .monthly-table {
        min-width: 500px;
    }
    
    .month-navigation button {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
}

/* Print Styles */
@media print {
    .prayer-times,
    .monthly-prayer-times {
        box-shadow: none;
        border: 1px solid #ddd;
        margin: 0;
        page-break-inside: avoid;
    }
    
    .monthly-table-container {
        overflow: visible;
        border: none;
    }
    
    .prayer-countdown,
    .monthly-controls button,
    .retry-btn {
        display: none;
    }
    
    .prayer-card.active {
        border: 2px solid var(--primary-color) !important;
        background: white !important;
        color: var(--text-dark) !important;
    }
    
    .prayer-card.active i,
    .prayer-card.active .prayer-name,
    .prayer-card.active .prayer-time {
        color: var(--text-dark) !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #00665e;
        --secondary-color: #00856e;
        --accent-yellow: #b89500;
    }
    
    .prayer-card.active {
        outline: 3px solid var(--accent-yellow);
    }
    
    .monthly-table .today {
        outline: 2px solid var(--primary-color);
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .prayer-card.active,
    .prayer-countdown,
    .next-prayer-indicator {
        animation: none;
    }
    
    .prayer-card:hover:not(.active),
    .month-navigation button:hover:not(:disabled) {
        transform: none;
    }
}

/* Prayer Card Colors */
.prayer-card[data-prayer="fajr"] {
    --prayer-color: #4f46e5;
}

.prayer-card[data-prayer="dhuhr"] {
    --prayer-color: #0ea5e9;
}

.prayer-card[data-prayer="asr"] {
    --prayer-color: #f59e0b;
}

.prayer-card[data-prayer="maghrib"] {
    --prayer-color: #ef4444;
}

.prayer-card[data-prayer="isha"] {
    --prayer-color: #8b5cf6;
}

/* Icon Wrapper */
.icon-wrapper {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    margin-bottom: 0.5rem;
    transition: all 0.3s;
}

.prayer-card.active .icon-wrapper {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.prayer-card i {
    font-size: 1.5rem;
    color: var(--primary-color);
    transition: all 0.3s;
}

.prayer-card.active i {
    color: white;
}