:root {
    --bg-color: var(--tg-theme-bg-color, #ffffff);
    --text-color: var(--tg-theme-text-color, #000000);
    --hint-color: var(--tg-theme-hint-color, #999999);
    --link-color: var(--tg-theme-link-color, #2481cc);
    --button-color: var(--tg-theme-button-color, #2481cc);
    --button-text-color: var(--tg-theme-button-text-color, #ffffff);
    --secondary-bg-color: var(--tg-theme-secondary-bg-color, #f0f0f0);
    --card-bg: var(--tg-theme-bg-color, #ffffff);
    --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --border-radius: 16px;
    --border-color: rgba(128, 128, 128, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--secondary-bg-color);
    color: var(--text-color);
    padding: 16px;
    line-height: 1.5;
}

.hidden {
    display: none !important;
}

/* Loader */
.loader-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-color);
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--button-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* Layout */
.card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
}

.header {
    margin-bottom: 24px;
    padding-top: 10px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.header h1 {
    font-size: 24px;
    font-weight: 700;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    color: var(--text-color);
}

#region-display {
    color: var(--hint-color);
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

h2 {
    font-size: 18px;
    margin-bottom: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Countdown */
.countdown-section {
    text-align: center;
    background: linear-gradient(135deg, var(--button-color), #4dabf7);
    color: #ffffff;
    border: none;
}

.countdown-section h2 {
    color: rgba(255, 255, 255, 0.9);
    justify-content: center;
    font-size: 16px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.countdown-display {
    font-size: 42px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    margin: 8px 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.next-prayer-name {
    font-size: 18px;
    font-weight: 600;
}

/* Lists */
.prayer-list {
    list-style: none;
}

.prayer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.prayer-item:last-child {
    border-bottom: none;
}

.prayer-name {
    font-weight: 500;
    font-size: 16px;
}

.prayer-time {
    font-weight: 600;
    font-size: 16px;
    background-color: var(--secondary-bg-color);
    padding: 4px 12px;
    border-radius: 8px;
}

.ramadan-grid {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.ramadan-box {
    flex: 1;
    background-color: var(--secondary-bg-color);
    border: 1px solid var(--button-color);
    color: var(--text-color);
    border-radius: var(--border-radius);
    padding: 16px 12px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ramadan-icon {
    font-size: 28px;
    margin-bottom: 4px;
}

.ramadan-label {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: 4px;
}

.ramadan-val {
    font-size: 22px;
    font-weight: 700;
    color: var(--button-color);
}

/* Qazo */
.qazo-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.qazo-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-radius: 12px;
    background-color: var(--secondary-bg-color);
}

.qazo-info {
    display: flex;
    flex-direction: column;
}

.qazo-name {
    font-weight: 600;
    font-size: 16px;
}

.qazo-count-text {
    font-size: 14px;
    color: var(--hint-color);
}

.qazo-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--card-bg);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.qazo-btn {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    color: var(--button-color);
    cursor: pointer;
    transition: background-color 0.2s;
}

.qazo-btn:active {
    background-color: var(--secondary-bg-color);
}

.qazo-count {
    font-weight: 700;
    font-size: 16px;
    min-width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 6px;
    cursor: pointer;
    background-color: var(--secondary-bg-color);
    transition: background-color 0.2s;
}

.qazo-count:active {
    background-color: var(--border-color);
}

.badge {
    background-color: var(--button-color);
    color: var(--button-text-color);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

/* Stats */
.stat-row {
    margin-bottom: 16px;
}

.stat-row:last-child {
    margin-bottom: 0;
}

.stat-labels {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    margin-bottom: 6px;
    font-weight: 500;
}

.progress-bg {
    background-color: var(--secondary-bg-color);
    border-radius: 8px;
    height: 8px;
    overflow: hidden;
    width: 100%;
}

.progress-fill {
    background-color: var(--button-color);
    height: 100%;
    width: 0%;
    border-radius: 8px;
    transition: width 0.5s ease;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background-color: var(--card-bg);
    width: 90%;
    max-width: 400px;
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.form-select {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background-color: var(--secondary-bg-color);
    color: var(--text-color);
    font-size: 15px;
    font-family: inherit;
    margin-top: 8px;
    margin-bottom: 20px;
    outline: none;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    line-height: normal;
    min-height: 48px;
}

select.form-select {
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23999999%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 12px auto;
    padding-right: 40px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn {
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary {
    background-color: var(--button-color);
    color: var(--button-text-color);
}

.btn-secondary {
    background-color: var(--secondary-bg-color);
    color: var(--text-color);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--button-color);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--button-color);
}

input:checked+.slider:before {
    -webkit-transform: translateX(20px);
    -ms-transform: translateX(20px);
    transform: translateX(20px);
}

/* Rounded sliders */
.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 100;
}

.nav-item {
    background: none;
    border: none;
    color: var(--hint-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.2s;
}

.nav-item.active {
    color: var(--button-color);
}

.nav-icon {
    font-size: 24px;
}

.nav-label {
    font-size: 12px;
    font-weight: 500;
}

/* Zikr View */
.zikr-circle {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--button-color), #4dabf7);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 40px auto;
    box-shadow: 0 10px 20px rgba(36, 129, 204, 0.3);
    cursor: pointer;
    user-select: none;
    transition: transform 0.1s;
    position: relative;
    overflow: hidden;
}

.zikr-circle:active {
    transform: scale(0.95);
}

/* Ripple effect container */
.zikr-circle::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
}

.zikr-circle.ripple::after {
    animation: ripple-animation 0.4s ease-out;
}

@keyframes ripple-animation {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
    }

    100% {
        width: 400px;
        height: 400px;
        opacity: 0;
    }
}

#zikr-word {
    text-align: center;
    line-height: 1.2;
}

.zikr-action-btn {
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Prayer Checkbox Buttons */
.prayer-check-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background-color: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
}

.prayer-check-btn.pending {
    border-color: var(--button-color);
    color: transparent;
    /* Hide text/emoji temporarily */
}

.prayer-check-btn.pending:active {
    background-color: var(--secondary-bg-color);
    transform: scale(0.95);
}

.prayer-check-btn.done {
    background-color: #E8F5E9;
    /* Light green */
    border-color: #4CAF50;
    color: #4CAF50;
    cursor: default;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.2);
}

.prayer-check-btn.locked {
    background-color: var(--secondary-bg-color);
    border-color: var(--border-color);
    color: var(--hint-color);
    cursor: not-allowed;
    opacity: 0.6;
}

/* --- Taqvim Table --- */
.taqvim-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    text-align: center;
}

.taqvim-table th {
    background-color: var(--secondary-bg-color);
    color: var(--hint-color);
    padding: 12px 8px;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.taqvim-table td {
    padding: 12px 8px;
    border-bottom: 1px solid var(--border-color);
}

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

#taqvim-loader {
    animation: spin 1.5s linear infinite;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* --- Dual Calendar Grid --- */
.calendar-grid-header,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    text-align: center;
}

.calendar-grid-header {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-color);
}

.calendar-day {
    padding: 8px 0;
    font-size: 14px;
    font-weight: 500;
    border-radius: 4px;
    color: var(--hint-color);
    display: flex;
    justify-content: center;
    align-items: center;
}

.calendar-day.enabled {
    color: var(--text-color);
    cursor: pointer;
    transition: background-color 0.15s, transform 0.1s;
}

.calendar-day.active {
    color: var(--button-color);
    font-weight: bold;
}

.calendar-day.selected {
    background-color: var(--button-color) !important;
    color: var(--button-text-color) !important;
    font-weight: bold;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    margin: 0 auto;
}

.calendar-day.enabled:active {
    transform: scale(0.9);
}

.cal-nav-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 18px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.cal-nav-btn:active {
    background-color: var(--secondary-bg-color);
}

.conversion-info {
    text-align: center;
    padding: 10px 16px;
    font-size: 15px;
    font-weight: 600;
    color: var(--button-color);
    background: var(--secondary-bg-color);
    border-radius: 10px;
    margin: 16px 0;
    transition: opacity 0.2s;
}

/* Qibla Compass Styles */
.compass-ring {
    position: relative;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    border: 4px solid var(--border-color);
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.1s linear;
}

.compass-marker {
    position: absolute;
    font-weight: bold;
    font-size: 18px;
    color: var(--hint-color);
}

.compass-marker.N {
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    color: #ff3b30;
}

.compass-marker.S {
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
}

.compass-marker.E {
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.compass-marker.W {
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.qibla-arrow {
    position: absolute;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    top: -4px;
    left: -4px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    transition: transform 0.15s ease-out;
    z-index: 10;
}

.kaaba-icon {
    font-size: 40px;
    margin-top: 20px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    transition: transform 0.2s;
}

.kaaba-icon.aligned {
    transform: scale(1.3);
    filter: drop-shadow(0 0 12px var(--button-color));
}

/* Quran View Styles */
.surah-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.surah-item:active {
    transform: scale(0.98);
}

.surah-item.playing {
    border-color: var(--button-color);
    background: var(--secondary-bg-color);
}

.surah-number {
    font-size: 14px;
    font-weight: bold;
    color: var(--hint-color);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--secondary-bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

.surah-item.playing .surah-number {
    background: var(--button-color);
    color: white;
}

.surah-details {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.surah-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-color);
}

.surah-meta {
    font-size: 12px;
    color: var(--hint-color);
}

.surah-name-ar {
    font-family: 'Amiri', serif;
    font-size: 20px;
    color: var(--button-color);
    text-align: right;
}