/* css/main.css */

:root {
    /* Light Mode Variables */
    --body-bg: #f0f2f5; /* Overall background */
    --display-section-bg: #ffffff; /* Background for the top display section */
    --table-section-bg: #ffffff; /* Background for the bottom table section */
    --text-color: #212529;
    --heading-color: #0d6efd; /* Bootstrap primary blue */
    --muted-text-color: #6c757d;
    --border-color: #dee2e6;
    --table-header-bg: #0d6efd;
    --table-header-color: white;
    --table-stripe-bg: #f8f9fa; /* bg-light-subtle for table stripes */
    --table-even-row-bg: #ffffff; /* Explicitly define even row bg for light mode */
    --table-hover-bg: #e2f0ff;
    --prayer-status-box-bg: #e9ecef; /* light gray for next prayer box */
    --next-prayer-countdown-color: #198754; /* Bootstrap success green */
    --offcanvas-bg: #ffffff; /* Offcanvas background */
    --offcanvas-heading-color: #212529; /* Dark text for light mode offcanvas headings */
    --list-group-item-bg: #f8f9fa; /* For list group items in light mode */
    --list-group-item-border: rgba(0, 0, 0, 0.125); /* Default list-group-item border */

    /* Dark Mode Variables (prefixed with --dark-) */
    --dark-body-bg: #212529; /* Dark gray */
    --dark-display-section-bg: #2b3035; /* Slightly lighter dark gray */
    --dark-table-section-bg: #2b3035;
    --dark-text-color: #f8f9fa; /* Light white */
    --dark-heading-color: #ffffff; /* A softer blue for dark mode */
    --dark-muted-text-color: #adb5bd; /* Lighter gray */
    --dark-border-color: #495057;
    --dark-table-header-bg: #0d6efd; /* Keep primary blue or adjust if needed */
    --dark-table-header-color: white;
    --dark-table-stripe-bg: #343a40; /* Darker gray for stripes */
    --dark-table-even-row-bg: #2b3035; /* Explicitly define even row bg for dark mode */
    --dark-table-hover-bg: #495057;
    --dark-prayer-status-box-bg: #495057; /* Darker gray for next prayer box */
    --dark-next-prayer-countdown-color: #28a745; /* Green for success */
    --dark-offcanvas-bg: #2b3035; /* Offcanvas background */
    --dark-offcanvas-heading-color: #f8f9fa; /* Light text for dark mode offcanvas headings */
    --dark-list-group-item-bg: #343a40; /* For list group items in dark mode */
    --dark-list-group-item-border: rgba(255, 255, 255, 0.125); /* Lighter border for dark mode */
}

/* Poppins - Thin */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-Thin.ttf') format('truetype');
    font-weight: 100; /* Thin */
    font-style: normal;
}

/* Poppins - Thin Italic */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-ThinItalic.ttf') format('truetype');
    font-weight: 100; /* Thin */
    font-style: italic;
}

/* Poppins - ExtraLight */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-ExtraLight.ttf') format('truetype');
    font-weight: 200; /* ExtraLight */
    font-style: normal;
}

/* Poppins - ExtraLight Italic */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-ExtraLightItalic.ttf') format('truetype');
    font-weight: 200; /* ExtraLight */
    font-style: italic;
}

/* Poppins - Light */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-Light.ttf') format('truetype');
    font-weight: 300; /* Light */
    font-style: normal;
}

/* Poppins - Light Italic */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-LightItalic.ttf') format('truetype');
    font-weight: 300; /* Light */
    font-style: italic;
}

/* Poppins - Regular */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-Regular.ttf') format('truetype');
    font-weight: 400; /* Regular / Normal */
    font-style: normal;
}

/* Poppins - Italic */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-Italic.ttf') format('truetype');
    font-weight: 400; /* Regular / Normal */
    font-style: italic;
}

/* Poppins - Medium */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-Medium.ttf') format('truetype');
    font-weight: 500; /* Medium */
    font-style: normal;
}

/* Poppins - Medium Italic */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-MediumItalic.ttf') format('truetype');
    font-weight: 500; /* Medium */
    font-style: italic;
}

/* Poppins - SemiBold */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-SemiBold.ttf') format('truetype');
    font-weight: 600; /* SemiBold */
    font-style: normal;
}

/* Poppins - SemiBold Italic */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-SemiBoldItalic.ttf') format('truetype');
    font-weight: 600; /* SemiBold */
    font-style: italic;
}

/* Poppins - Bold */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-Bold.ttf') format('truetype');
    font-weight: 700; /* Bold */
    font-style: normal;
}

/* Poppins - Bold Italic */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-BoldItalic.ttf') format('truetype');
    font-weight: 700; /* Bold */
    font-style: italic;
}

/* Poppins - ExtraBold */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-ExtraBold.ttf') format('truetype');
    font-weight: 800; /* ExtraBold */
    font-style: normal;
}

/* Poppins - ExtraBold Italic */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-ExtraBoldItalic.ttf') format('truetype');
    font-weight: 800; /* ExtraBold */
    font-style: italic;
}

/* Poppins - Black */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-Black.ttf') format('truetype');
    font-weight: 900; /* Black */
    font-style: normal;
}

/* Poppins - Black Italic */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-BlackItalic.ttf') format('truetype');
    font-weight: 900; /* Black */
    font-style: italic;
}

/* Base styles using light mode variables */
body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--body-bg);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh; /* Ensure body takes full viewport height */
}

p {
    color: var(--text-color);
    transition: color 0.3s ease;
}

.text-muted {
    color: var(--muted-text-color) !important;
    transition: color 0.3s ease;
}

.display-section,
.prayer-table-section .table-container {
    background-color: var(--display-section-bg);
    border-radius: 0.75rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    margin-bottom: 1rem;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* Global padding for sections on desktop */
.display-section {
    padding: 0;
    height: 70vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.prayer-table-section {
    padding: 0; /* New: Removed padding */
    height: 25vh;
    overflow: hidden;
}
.prayer-table-section .table-container {
    padding: 1rem;
}


/* Dark mode styles */
body.dark-mode {
    background-color: var(--dark-body-bg);
    color: var(--dark-text-color);
}

body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode h5,
body.dark-mode h6 {
    color: var(--dark-heading-color);
}

body.dark-mode p {
    color: var(--dark-text-color);
}

body.dark-mode .text-muted {
    color: var(--dark-muted-text-color) !important;
}

body.dark-mode .display-section,
body.dark-mode .prayer-table-section .table-container {
    background-color: var(--dark-display-section-bg);
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.2);
}

/* Specific component overrides for dark mode */
body.dark-mode .prayer-status-box {
    background-color: var(--dark-prayer-status-box-bg);
    border-color: var(--dark-border-color);
}

body.dark-mode .next-prayer-countdown-color {
    color: var(--dark-next-prayer-countdown-color);
}

/* Table styling for light and dark mode */
.table {
    --bs-table-bg: var(--table-section-bg); /* Use section background as default */
    --bs-table-striped-bg: var(--table-stripe-bg);
    --bs-table-hover-bg: var(--table-hover-bg);
    color: var(--text-color); /* Default text color for table */
    transition: background-color 0.3s ease, color 0.3s ease;
}

.table thead th {
    background-color: var(--table-header-bg);
    color: var(--table-header-color);
    border-color: var(--border-color); /* Ensure header borders match theme */
    font-size: 1.5rem; /* Increased header font size */
}

.table tbody tr:nth-of-type(odd) {
    background-color: var(--table-even-row-bg); /* Explicitly for odd rows to be 'even' themed */
}

.table tbody td,
.table tfoot td {
    font-size: 1.5rem; /* Increased font size for table content */
    vertical-align: middle; /* Align content vertically in middle */
}

/* Dark mode specific table overrides */
body.dark-mode .table {
    --bs-table-bg: var(--dark-table-section-bg);
    --bs-table-striped-bg: var(--dark-table-stripe-bg);
    --bs-table-hover-bg: var(--dark-table-hover-bg);
    color: var(--dark-text-color);
}

body.dark-mode .table thead th {
    border-color: var(--dark-border-color);
}

body.dark-mode .table tbody tr:nth-of-type(odd) {
    background-color: var(--dark-table-even-row-bg);
}


/* Settings Button */
.settings-button {
    position: fixed;
    top: 1rem; /* 16px from top */
    left: 1rem; /* 16px from left */
    z-index: 1050; /* Above offcanvas, below modal */
    border-radius: 50%; /* Make it round */
    width: 3rem; /* Fixed width */
    height: 3rem; /* Fixed height */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0; /* Remove padding for perfect circle */
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease-in-out;
}

.settings-button:hover {
    transform: scale(1.05);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.3);
}

/* Offcanvas */
.offcanvas {
    background-color: var(--offcanvas-bg);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.offcanvas-header {
    background-color: var(--table-header-bg);
    color: var(--table-header-color);
    border-bottom: 1px solid var(--border-color);
}
body.dark-mode .offcanvas-header {
    background-color: var(--dark-table-header-bg);
    color: var(--dark-table-header-color);
    border-bottom-color: var(--dark-border-color);
}

.offcanvas-title {
    color: var(--offcanvas-heading-color);
}
body.dark-mode .offcanvas-title {
    color: var(--dark-offcanvas-heading-color);
}

.offcanvas-body {
    padding: 1.5rem;
}

.offcanvas-body .form-label,
.offcanvas-body .form-check-label {
    color: var(--text-color);
}
body.dark-mode .offcanvas-body .form-label,
body.dark-mode .offcanvas-body .form-check-label {
    color: var(--dark-text-color);
}

.offcanvas-body hr {
    border-top: 1px solid var(--border-color);
    opacity: 1; /* Ensure visibility */
}

body.dark-mode .offcanvas-body hr {
    border-top: 1px solid var(--dark-border-color);
}

body.dark-mode .offcanvas {
    --offcanvas-bg: var(--dark-display-section-bg); /* Offcanvas background dark */
}

body.dark-mode .header-section {
    background-color: var(--dark-display-section-bg);
}

body.dark-mode .table-container {
    background-color: var(--dark-display-section-bg);
}

.form-control, .form-select {
    background-color: var(--display-section-bg); /* Use display section background for inputs */
    color: var(--text-color);
    border-color: var(--border-color);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body.dark-mode .form-control, body.dark-mode .form-select {
    background-color: var(--dark-display-section-bg);
    color: var(--dark-text-color);
    border-color: var(--dark-border-color);
}
body.dark-mode .form-control::placeholder { /* For placeholder text in dark mode */
    color: var(--dark-muted-text-color);
}

.list-group-item {
    background-color: var(--list-group-item-bg);
    border-color: var(--list-group-item-border);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}
body.dark-mode .list-group-item {
    background-color: var(--dark-list-group-item-bg);
    border-color: var(--dark-list-group-item-border);
    color: var(--dark-text-color); /* Ensure text color is readable */
}

/* Current Time Display */
#currentTime {
    font-feature-settings: "tnum"; /* Tabular numbers for consistent width */
    font-variant-numeric: tabular-nums;
}

/* Next Prayer Box */
.prayer-status-box {
    background-color: var(--prayer-status-box-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 3rem;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Countdown color for main display */
#countdownToNextPrayer {
    color: var(--next-prayer-countdown-color);
    font-feature-settings: "tnum"; /* Tabular numbers */
    font-variant-numeric: tabular-nums;
}

/* Custom colors for Iqama countdown */
.text-success-custom { color: #28a745 !important; } /* Green */
.text-warning-custom { color: #ffc107 !important; } /* Orange */
.text-danger-custom { color: #dc3545 !important; } /* Red */

/* Display Mode Content Switching - Centering elements within */
.display-mode-content {
    position: absolute;
    top: 0;
    left: 0;
    display: none; /* Hidden by default */
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    /* New: Flex properties for centering content */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center; /* Ensure text is centered within flex item */
    height: 100%; /* Ensure flex container takes full height of parent */
    width: 100%;
}

.display-mode-content.active-display {
    display: flex; /* Changed from block to flex */
    opacity: 1;
}

/* Sync History List Button & Collapse */
.list-group-item.d-flex {
    align-items: flex-start; /* Align content to the top of the item */
}

.list-group-item .collapse-toggle-btn {
    margin-top: 0.25rem; /* Align button better with text */
    padding: 0.25rem 0.5rem; /* Smaller padding */
    font-size: 0.8rem; /* Smaller font */
    border-radius: 0.5rem;
}
.list-group-item .collapse-toggle-btn .bi {
    transition: transform 0.2s ease-in-out;
}
.list-group-item .collapse-toggle-btn[aria-expanded="true"] .bi {
    transform: rotate(180deg);
}

.sync-detail-content pre {
    background-color: var(--body-bg); /* Use body bg for pre to contrast */
    color: var(--text-color);
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    white-space: pre-wrap; /* Ensure long lines wrap */
    word-break: break-all; /* Break words for very long strings */
    transition: background-color 0.3s ease, color 0.3s ease;
}
body.dark-mode .sync-detail-content pre {
    background-color: var(--dark-body-bg);
    color: var(--dark-text-color);
}


/* Mobile Responsiveness */
@media (max-width: 767.98px) {
    .settings-button {
        top: 0.5rem; /* Adjust for smaller top margin on mobile */
        left: 0.5rem; /* Adjust for smaller left margin on mobile */
        width: 2.5rem; /* Smaller button on mobile */
        height: 2.5rem;
        font-size: 1.2rem;
    }
    .settings-button .bi {
        font-size: 1.2rem !important; /* Adjust icon size */
    }

    .display-5 {
        font-size: 3rem; /* Adjust current time font size for mobile */
    }

    .display-section,
    .prayer-table-section {
        padding-left: 1rem; /* Adjust section padding for mobile */
        padding-right: 1rem;
    }
    .display-section .h5 {
        font-size: 0.9rem; /* Smaller font for dates on mobile */
    }
    .prayer-status-box {
        padding: 0.75rem; /* Smaller padding for next prayer box */
    }
    .prayer-status-box .h3 {
        font-size: 1.1rem; /* Smaller next prayer name */
    }
    .prayer-status-box .h5 {
        font-size: 1rem; /* Smaller next prayer time */
    }
    .prayer-status-box .h2 {
        font-size: 1.8rem; /* Smaller countdown */
    }

    .table thead th,
    .table tbody td,
    .table tfoot td {
        font-size: 0.9rem; /* Smaller table font size for mobile */
        padding: 0.4rem; /* Smaller padding */
    }
    /* Ensure table is scrollable if content overflows */
    .table-responsive > .table {
        min-width: 600px; /* Adjust as needed to allow horizontal scrolling */
    }

    /* Specific padding for content within display section on mobile */
    .display-section {
        padding-top: 1rem; /* Adjust top padding for mobile */
        padding-bottom: 1rem; /* Adjust bottom padding for mobile */
    }
    .prayer-table-section {
        padding-top: 0.5rem; /* Reduce top padding for prayer table section on mobile */
        padding-bottom: 0.5rem; /* Reduce bottom padding for prayer table section on mobile */
    }
    .table-container {
        padding: 0.5rem; /* Reduce inner padding for table container on mobile */
    }

}


/* Desktop / Larger Screens Font Size for Table */
@media (min-width: 992px) { /* Adjust breakpoint as needed (lg breakpoint in Bootstrap) */
    .table tbody td,
    .table tfoot td {
        font-size: 1.5rem; /* Keep increased font size for desktop */
    }
    .table thead th {
        font-size: 1.5rem; /* Keep increased header font size for desktop */
    }
}


/* Keep these modal stylings, they apply to all modals */
.modal-content {
    background-color: var(--offcanvas-bg); /* Use offcanvas bg for modals */
    color: var(--text-color);
    border-radius: 0.75rem; /* Keep slight rounding for modals */
}
.modal-header {
    background-color: var(--table-header-bg); /* Use table header bg for modal header */
    color: var(--table-header-color);
    border-bottom: 1px solid var(--border-color);
}
body.dark-mode .modal-header {
    background-color: var(--dark-table-header-bg);
    color: var(--dark-table-header-color);
    border-bottom-color: var(--dark-border-color);
}
.modal-body { /* Ensure modal body uses consistent background */
    background-color: var(--offcanvas-bg);
    color: var(--text-color);
}
body.dark-mode .modal-body {
    background-color: var(--dark-offcanvas-bg);
    color: var(--dark-text-color);
}
.modal-footer {
    border-top: 1px solid var(--border-color);
    background-color: var(--offcanvas-bg); /* Ensure modal footer uses consistent background */
}
body.dark-mode .modal-footer {
    border-top-color: var(--dark-border-color);
    background-color: var(--dark-offcanvas-bg);
}


.btn-close {
    filter: invert(1) grayscale(100%) brightness(200%); /* Makes close button white */
}
body.dark-mode .btn-close {
    filter: none; /* Reset filter for dark mode if default is good */
}

/* Adjustments for Announcement/Iqama Displays */
#prayerAnnouncementDisplay .display-3,
#iqamaCountdownDisplay .display-1 {
    font-feature-settings: "tnum"; /* Tabular numbers for consistent width */
    font-variant-numeric: tabular-nums;
}

/* Ensure buttons in Offcanvas have consistent padding and rounded corners */
.offcanvas .btn {
    border-radius: 0.5rem; /* Slightly less rounded than full pills, more subtle */
    padding: 0.75rem 1rem;
}
