/* Define Color Variables */
:root {
    /* Background Colors */
    --primary-bg: #b0bec5;
    --secondary-bg: #545c5a;
    --highlight2-bg: #48b5be;
    --highlight-bg: #008c99;
    --white-bg: #ffffff;

    /* Text Colors */
    --primary-text: #2d3b45;
    --secondary-text: #ffffff; 
    --nextprayer-text:  #2d3b45;
    --messages-text: #2d3b45;
    --highlight-text: #2C3E50;
    --highlight2-text: #368adf;
    --error-text: #D32F2F;
    --clock-text: #ffb35c;
    --prayerTime-text: #58d8ff;
    --highlight-time: #ffd96f;
    --highlight2-time: #f88436;
    --secondary-span-text: #777;
    --responsive-text: #333;

    /* Shadow Colors */
    --shadow-color: #156b9c80;
}

:root[data-theme="Theme1"] {
    /* Background Colors */
    --primary-bg: #1b5e20;    
    --secondary-bg: #488d4a;  
    --highlight2-bg: #4caf50;
    --highlight-bg: #3cbb42;  
    --white-bg: #ffffff;      

    /* Text Colors */
    --primary-text: #ffffff;   
    --secondary-text: #f1f1f1; 
    --nextprayer-text: #1e5588; 
    --messages-text: #ffffff;  
    --highlight-text: #ff9800; 
    --highlight2-text: #3b573c; 
    --error-text: #D32F2F;     
    --clock-text: #ffeb3b;    
    --prayerTime-text: #8af08f ; 
    --highlight-time: #ffd54f; 
    --highlight2-time: #ff7043;
    --secondary-span-text: #b0bec5; 
    --responsive-text: #333;    

    /* Shadow Color */
    --shadow-color: #004d2d80; 
}

:root[data-theme="Theme2"] {
    /* Background Colors */
    --primary-bg: #a1887f;    
    --secondary-bg: #6d4c41;  
    --highlight2-bg: #8d6e63; 
    --highlight-bg: #3e2723;  
    --white-bg: #ffffff;      

    /* Text Colors */
    --primary-text: #ffffff;  
    --secondary-text: #f1f1f1;
    --nextprayer-text: #666029; 
    --messages-text: #ffffff;  
    --highlight-text: #ff9800;
    --highlight2-text: #39738b; 
    --error-text: #D32F2F;     
    --clock-text: #ffeb3b;     
    --prayerTime-text: #e2db96; 
    --highlight-time: #ffd54f;  
    --highlight2-time: #ff7043;
    --secondary-span-text: #b0bec5; 
    --responsive-text: #333;    

    /* Shadow Color */
    --shadow-color: #32323240; /* Light shadow with brownish tint */
}

:root[data-theme="Theme3"] {
    /* Background Colors */
    --primary-bg: #8baaad;   
    --secondary-bg: #0097a7; 
    --highlight2-bg: #4db6ac; 
    --highlight-bg: #00777c; 
    --white-bg: #ffffff;     

    /* Text Colors */
    --primary-text: #ffffff;  
    --secondary-text: #f1f1f1; 
    --nextprayer-text: #00777c;
    --messages-text: #ffffff;  
    --highlight-text: #ff9800; 
    --highlight2-text: #0097a7; 
    --error-text: #D32F2F;     
    --clock-text: #ffeb3b;     
    --prayerTime-text: #a2d8e9; 
    --highlight-time: #ffd54f;  
    --highlight2-time: #ff7043; 
    --secondary-span-text: #b0bec5; 
    --responsive-text: #333;    

    /* Shadow Color */
    --shadow-color: rgba(0, 64, 64, 0.4); /* Deep shadow with teal tint */
}

/* Global Styles */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--primary-bg);
    display: flex;
    flex-direction: column;
    height: 100dvh;
    text-align: center;
    overflow: hidden;
}

/* Header Section */
#header {
    margin-top: 20px;
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    color: var(--secondary-text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 10;
    box-sizing: border-box;
}

#messages-container {
    flex-grow: 1;
    min-height: 80px;
    color: var(--messages-text);
    font-size: 2.5em;
    display: flex;
    align-items: center;
    margin: 0 20px;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.message-wrapper {
    position: absolute;
    white-space: nowrap;
    top: 50%;
    transform: translateY(-50%);
    visibility: visible;
    opacity: 1;
}

.message-wrapper span {
    white-space: nowrap;
    display: inline-block;
    padding: 0 20px;
    font-family: inherit;
}

.message-wrapper span.arabic {
    direction: rtl;
    font-family: Arial, sans-serif;
    font-size: clamp(28px, 3.5em, 56px); 
}

.button1, .fullscreen-button {
    background-color: var(--primary-bg);
    color: var(--primary-text);
    border: none;
    padding: 10px;
    cursor: pointer;
    font-size: 1em;
}

.fullscreen-button {
    margin-right: 10px;
}

.message-wrapper span.arabic {
    direction: rtl;
    font-family: Arial, sans-serif;
}

@keyframes marqueeLeft {
    0% { transform: translateX(2000px) translateY(-50%); }
    100% { transform: translateX(-2000px) translateY(-50%); }
}

@keyframes marqueeRight {
    0% { transform: translateX(-2000px) translateY(-50%); }
    100% { transform: translateX(2000px) translateY(-50%); }
}

#next-prayer {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    flex-direction: row;
    width: 100%;
    height: clamp(300px, 60dvh, 600px); 
    background-color: var(--primary-bg);
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
    border-radius: 12px;
    position: relative;
}

#prayer-details {
    width: 46%;
    display: flex;
    flex-direction: row;
    gap: 10px;
    background-color: var(--white-bg);
    box-shadow: 0 4px 6px var(--shadow-color);
    border-radius: 12px;
    overflow: hidden;
    position: absolute;
    left: 20px;
    top: 20px;
    bottom: 20px;
    right: auto;
    z-index: 2;
    padding: 0;
    box-sizing: border-box;
}

#time-notification {
    width: 46%;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    justify-items: center;
    background-color: var(--highlight-bg);
    box-shadow: 0 4px 6px var(--shadow-color);
    border-radius: 12px;
    overflow: auto; 
    position: absolute;
    left: 20px;
    top: 20px;
    bottom: 20px;
    right: auto;
    z-index: 3;
    display: none;
    padding: 10px;
}

#notification-content {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    text-align: center;
    padding: 10px;
    color: var(--secondary-text);
    margin-top: 5dvh;
    overflow-y: hidden;
    overflow-wrap: break-word; 
}

#notification-content .arabic {
    font-size: clamp(20px, 6vw, 120px); 
    font-weight: bold;
    color: var(--secondary-text);
    direction: rtl;
    font-family: Arial, sans-serif;
    width: 100%;
}

#notification-content .french {
    font-size: clamp(16px, 6vw, 80px);
    font-weight: bold;
    color: var(--secondary-text);
    direction: ltr;
    font-family: Arial, sans-serif;
}

#notification-content .time {
    font-size: clamp(18px, 6vw, 150px);
    color: var(--highlight-time);
    font-weight: bold;
}

/* Animations */
@keyframes highlightChange {
    0% {background-color: var(--highlight-bg);}
    50% {background-color: var(--highlight2-bg);}
    100% {background-color: var(--highlight-bg);}
}

@keyframes textColorChange {
    0% {color: var(--highlight-time);}
    50% {color: var(--highlight-time);}
    100% {color: var(--highlight-time);}
}

@keyframes flipShow {
    0% { transform: perspective(1000px) translateX(50vw); opacity: 0; }
    100% { transform: perspective(1000px) translateX(0vw); opacity: 1; }
    
}

@keyframes flipHide {
    0% { transform: perspective(1000px) translateX(0vw); opacity: 1; }
    100% { transform: perspective(1000px) translateX(50vw); opacity: 0; }
}

.flip-show {
    animation: flipShow 1s ease forwards;
}

.flip-hide {
    animation: flipHide 1s ease forwards;
}

.flip-hide-reverse {
    animation: flipHide 1s ease reverse forwards;
}

/* Current Prayer Section (2/3 width, left) */
#current-prayer {
    width: 66.66%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 8px;
    color: var(--nextprayer-text);
    font-size: clamp(24px, 4vmin, 36px);
    overflow-wrap: break-word;
    flex: 1 1 auto;
    min-height: 120px;
    overflow: hidden;
}

#current-prayer .prayer-names {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}

#current-prayer .arabic {
    font-size: clamp(32px, 10vmin, 100px);
    color: var(--nextprayer-text);
    direction: rtl;
    font-family: Arial, sans-serif;
    line-height: 1.2;
    margin: 3px 0;
}

#current-prayer .french {
    font-size: clamp(24px, 8vmin, 70px);
    color: var(--nextprayer-text);
    direction: ltr;
    font-family: Arial, sans-serif;
    line-height: 1.2;
    margin: 3px 0;
}

#current-prayer .time {
    font-size: clamp(18px, 6vw, 140px);
    color: var(--highlight2-text);
    font-weight: bold;
    line-height: 1.2;
    margin: 3px 0;
}

#current-prayer .athan-label .french {
    font-size: clamp(20px, 3vmin, 60px);
    color: var(--nextprayer-text);
    line-height: 1.2;
    margin: 3px 0;
}

#current-prayer .iqama-label .french {
    font-size: clamp(20px, 3vmin, 60px);
    color: var(--nextprayer-text);
    line-height: 1.2;
    margin: 3px 0;
}

#current-prayer .athan-label .arabic{
    font-size: clamp(15px, 4vmin, 80px);
    color: var(--nextprayer-text);
    line-height: 1.2;
    margin: 3px 0;
}

#current-prayer .iqama-label .arabic{
    font-size: clamp(15px, 4vmin, 80px);
    color: var(--nextprayer-text);
    line-height: 1.2;
    margin: 3px 0;
}

#current-prayer .iqama-time {
    font-size: clamp(18px, 6vw, 140px);
    color: var(--highlight2-text);
    font-weight: bold;
    line-height: 1.2;
    margin: 3px 0;
}

/* Prayer Info Section (1/3 width, right) */
#prayer-info {
    width: 33.33%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1 1 auto;
    min-height: 120px;
}

/* Prayer Link Section (top half of prayer-info) */
#prayer-link {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    background-color: var(--white-bg);
    overflow: hidden; /* Ensure QR code stays contained */
}

#prayer-link img.qr-code {
    max-width: 100%;
    max-height: 90%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
}

/* Next Prayer Details Section (bottom half of prayer-info) */
#next-prayer-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 8px;
    background-color: var(--white-bg);
    font-size: clamp(22px, 3.5vmin, 34px); /* Increased for consistency */
    border-radius: 12px;
    overflow-wrap: break-word;
    overflow: auto;
    min-height: 100px;
}

#next-prayer-details .arabic-prayer-name {
    font-size: clamp(26px, 4vmin, 38px);
    color: var(--nextprayer-text);
    font-weight: bold;
    font-family: Arial, sans-serif;
    line-height: 1.2;
    margin: 3px 0;
}

#next-prayer-details .french-prayer-name {
    font-size: clamp(22px, 3vmin, 30px);
    color: var(--nextprayer-text);
    font-weight: normal;
    line-height: 1.2;
    margin: 3px 0;
}

#next-prayer-details .remaining-time {
    font-size: clamp(18px, 6dvh, 120px);
    color: var(--highlight2-time);
    font-weight: bold;
    line-height: 1.2;
    margin: 3px 0;
}

#next-prayer-details.highlight-next-prayer {
    animation: highlightChange 2s ease-in-out infinite;
}

#next-prayer-details.highlight-next-prayer .arabic-prayer-name,
#next-prayer-details.highlight-next-prayer .french-prayer-name,
#next-prayer-details.highlight-next-prayer .remaining-time {
    animation: textColorChange 2s ease-in-out infinite;
}

#next-prayer-details.highlight-next-prayer .remaining-time {
    color: var(--highlight-time);
    font-size: clamp(26px, 7vmin, 60px);
}

/* Date & Time Section on the Right */
#date-time {
    width: 46%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    background-color: var(--highlight-bg);
    box-shadow: 0 4px 6px var(--shadow-color);
    border-radius: 12px;
    position: absolute;
    right: 20px;
    top: 20px;
    bottom: 20px;
    left: auto;
    z-index: 1;
    overflow: hidden; 
}

#date-time #date {
    font-size: clamp(24px, 5vw, 70px);
    color: var(--secondary-text);
}

#date-time #clock {
    font-weight: bold;
    font-size: clamp(24px, 40dvh, 140px); 
    color: var(--clock-text);
}

/* slideshow Section*/
#slideshow {
    display: none;
    width: 100%;
    height: 90%;
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
    border-radius: 12px;
    margin-top: 20px;
    top: 10%;
    position: fixed;
    justify-content: center;
    align-items: center;
}

#slideshow img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    margin: auto;
    height: auto;
    object-fit: fill;
    display: none;
    border-radius: 12px;
}

#slideshow img.active {
    display: block;
}

#slideshow .error {
    color: var(--error-text);
    font-size: 1.5em;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

/* All Prayers Section */
#all-prayers {
    display: flex;
    white-space: nowrap;
    flex-direction: row;
    justify-items: center;
    justify-content: stretch;
    gap: 10px; 
    width: 100%; 
    /*max-width: 100%; */
    /*margin: 0.5%; */
    padding: 0; 
    background-color: var(--primary-bg);
    margin-top: 20px; 
    margin-right: 1%;
    margin-left: 1%;
    /*margin-bottom: 20px;*/
    height: auto;
    box-sizing: border-box;
    overflow-y: auto; 
}

.athan-iqama-labels {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    justify-content: center;
    flex: 1;
    max-width: fit-content;
    background-color: var(--secondary-bg);
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 6px var(--shadow-color);
    box-sizing: border-box;
}

.athan-iqama-labels .label {
    font-size: clamp(18px, 2.5dvh, 28px);
    white-space: nowrap;
    font-weight: bold;
    color: var(--secondary-text);
    text-align: center;
}

.prayer-time-container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    /*justify-content: stretch;*/
    gap: 10px; 
    width: 89vw;
    box-sizing: border-box;
    min-height: fit-content;
    height: auto;
    flex-wrap: wrap; /* Allow wrapping if needed */
}

.prayer-time {
    font-size: 18px; 
    font-weight: bold; 
    color: var(--secondary-text); 
    background-color: var(--secondary-bg); 
    padding: 10px; 
    border-radius: 8px; 
    box-shadow: 0 2px 6px var(--shadow-color); 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    min-height: 100px; 
    flex: 1; 
    min-width: 0; 
    box-sizing: border-box;
    /*flex-wrap: nowrap;*/
}

.prayer-time .upper-part {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 5px;
}

.prayer-time .lower-part {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 5px;
}

.prayer-time .prayer-names {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap !important;
    width: 100%;
}

/* Force wrapping for prayers without Iqama time or for Jumu'ah prayers */
.prayer-time[data-prayer="Sunrise"] .prayer-names,
.prayer-time[data-prayer="Jumu3a 1"] .prayer-names,
.prayer-time[data-prayer="Jumu3a 2"] .prayer-names,
.prayer-time .lower-part:empty ~ .upper-part .prayer-names,
.prayer-time .lower-part:not(:has(.iqama-time)) ~ .upper-part .prayer-names {
    flex-wrap: wrap; 
    text-align: center;
    text-wrap: wrap;
    display: flex;
    flex-direction: column;
}

.prayer-time .prayer-names .arabic {
    font-size: clamp(16px, 2vw, 34px);
    color: var(--secondary-text);
    direction: rtl;
    text-align: center; 
    flex: 1; 
    min-width: 0; 
}

.prayer-time .prayer-names .french {
    font-family: Arial, sans-serif;
    font-size: clamp(14px, 1.6vw, 32px);
    color: var(--secondary-text);
    direction: ltr;
    text-align: center; 
    flex: 1; 
    min-width: 0; 
}

.prayer-time .time {
    font-size: clamp(18px, 7dvh, 120px);
    color: var(--prayerTime-text);
    margin-top: 5px;
}

.prayer-time .iqama-time {
    font-size: clamp(18px, 7dvh, 120px);
    color: var(--prayerTime-text);
    margin-top: 5px;
}

.prayer-time.next-prayer {
    background-color: var(--highlight-bg);
    color: var(--secondary-text);
}

.prayer-time.next-prayer .time {
    color: var(--highlight-time) !important;
}

.prayer-time.next-prayer .iqama-time {
    color: var(--highlight-time) !important;
}

.latin-date {
    font-size: 0.8em;
    white-space: nowrap;
    display: inline-block;
}

.prayer-time span {
    font-size: 16px;
    color: var(--secondary-text);
}

.arabic, .arabic-text {
    font-size: clamp(16px, 2vw, 24px);
    white-space: nowrap;
    direction: rtl;
    text-align: center;
}

.french-prayer-name, .latin-date {
    direction: ltr;
    text-align: center;
}

/*Responsive edsign*/
@media (max-width: 428px) {
    #time-notification, #messages-container, .athan-iqama-labels {display: none;}
    #time-notification > *  {display: none;}
    .athan-iqama-labels > * {display: none;}
    #date-time{
        width: 80vw;
        height: 25dvh;
    }

    #next-prayer{
        flex-direction: column;
        width: 100dvh;
        flex-wrap: wrap;
    }
    
    #prayer-details {
        position:fixed;
        height: 0px;
        width: 100%;
        display: none;
    }  

    #current-prayer .arabic, #next-prayer-details .arabic-prayer-name {
        font-size: clamp(12px, 3vmin, 34px);
    }

    #current-prayer .french, #next-prayer-details .french-prayer-name {
        font-size: clamp(12px, 2.2vmin, 28px);
    }

    #current-prayer .time, #next-prayer-details .remaining-time {
        font-size: clamp(16px, 2.5vmin, 32px);
    }

    #current-prayer .iqama-label {
        font-size: clamp(16px, 2vmin, 26px);
    }

    #current-prayer .iqama-time {
        font-size: clamp(18px, 2.2vmin, 30px);
    }    

    #all-prayers {
        flex: 1;
        padding: 20px;
        background-color: var(--primary-bg);
        position: fixed;
        margin-top: 45dvh;
        display: block;
        width: 100%;
        height: 50dvh;
        overflow-y: auto;
        overflow-wrap: normal;
        max-width: 100%;
    } 
    .prayer-time-container {
        font-size: clamp(16px, 3vmin, 28px);
        flex-direction: row;
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 10px;
        width: 100%; /* Full width on small screens */
        padding: 10px;
    } 

    .prayer-time {
        min-width: 0; /* Allow shrinking */
        flex: 1 1 45%; /* Allow two columns with wrapping */
        max-width: 48%; /* Prevent taking too much space */
        box-sizing: border-box;
    }

    .prayer-time .prayer-names {
        flex-wrap: wrap; /* Allow wrapping on small screens regardless of Iqama */
        justify-content: center;
        align-items: center;
    }   
    
    .prayer-time .prayer-names .arabic {
        font-size: clamp(14px, 2.5vmin, 28px);
        text-align: center;
    }

    .prayer-time .prayer-names .french {
        font-size: clamp(12px, 2vmin, 26px);
        text-align: center;
    }

    .prayer-time .time {
        font-size: clamp(16px, 2.5vmin, 32px);
    }

    .prayer-time .iqama-time {
        font-size: clamp(16px, 2.5vmin, 32px);
    }    
}

@media (max-height: 720px) {
    .prayer-time .prayer-names .arabic {
        font-size: clamp(14px, 2.5vmin, 27px);
        text-align: center;
    }

    .prayer-time .prayer-names .french {
        font-size: clamp(12px, 2vmin, 25px);
        text-align: center;
    }
}

@media (max-height: 667px) {
    #date-time{
        height: 20dvh;
    }
}

@media (max-height: 720px) {
    
    #date-time #clock {
        font-weight: bold;
        font-size: clamp(26px, 40dvh, 100px); 
        color: var(--clock-text);
    }

    .prayer-time .time {
        font-size: clamp(12px, 7dvh, 80px);
        color: var(--prayerTime-text);
        margin-top: 5px;
    }

    .prayer-time .iqama-time {
        font-size: clamp(12px, 7dvh, 80px);
        color: var(--prayerTime-text);
        margin-top: 5px;
    }
}