:root {
    /* Premium Islamic Color Palette */
    --primary-color: #0d3b2e;
    /* Deep Forest Green */
    --secondary-color: #1a5642;
    /* Emerald Green */
    --accent-color: #d4af37;
    /* Soft Gold */
    --accent-hover: #f1c40f;
    /* Bright Gold */
    --text-light: #f8f9fa;
    /* Off White */
    --text-dark: #2c3e50;
    /* Charcoal */
    --bg-light: #eef2f0;
    /* Very light green hint */
    --glass-bg: rgba(13, 59, 46, 0.7);
    --glass-border: rgba(212, 175, 55, 0.3);

    /* Typography */
    --font-heading: 'Amiri', serif;
    --font-body: 'Tajawal', sans-serif;

    /* System */
    --transition-speed: 0.3s;
    --border-radius: 16px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-light);
    color: var(--text-dark);
    margin-bottom: 80px;
    /* Space for bottom nav on mobile */
    overflow-x: hidden;
}

/* Background Pattern Overlay */
.bg-pattern {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('data:image/svg+xml;utf8,<svg width="40" height="40" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg"><path d="M20 0l20 20-20 20L0 20z" fill="rgba(26,86,66,0.03)"/></svg>');
    z-index: -1;
    pointer-events: none;
}

/* Glassmorphism Utilities */
.glassmorphism {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: var(--shadow);
    border-radius: var(--border-radius);
}

.dark-glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    color: var(--text-light);
}

/* Typography */
h1,
h2,
h3,
.amiri-text {
    font-family: var(--font-heading);
    color: var(--primary-color);
}

.dark-glass h1,
.dark-glass h2,
.dark-glass h3 {
    color: var(--accent-color);
}

/* Navigation - Bottom on Mobile, Top/Side on Desktop */
.navbar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--primary-color);
    color: var(--text-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
}

.nav-brand {
    display: none;
    /* Hidden on mobile */
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
    align-items: center;
    gap: 0.5rem;
}

.nav-links {
    list-style: none;
    display: flex;
    justify-content: space-around;
    width: 100%;
}

.nav-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-family: var(--font-body);
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.nav-btn i {
    font-size: 1.2rem;
    transition: transform var(--transition-speed) ease;
}

.nav-btn.active,
.nav-btn:hover {
    color: var(--accent-color);
}

.nav-btn.active i {
    transform: translateY(-3px) scale(1.1);
}

@media (min-width: 768px) {
    body {
        margin-bottom: 0;
        padding-top: 80px;
        /* Space for top nav */
    }

    .navbar {
        top: 0;
        bottom: auto;
        padding: 1rem 4rem;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    }

    .nav-brand {
        display: flex;
    }

    .nav-links {
        width: auto;
        gap: 2rem;
    }

    .nav-btn {
        flex-direction: row;
        font-size: 1.1rem;
    }
}

/* Main Content & Sections */
.main-content {
    padding: 2rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.section {
    display: none;
    animation: fadeIn 0.5s ease-out forwards;
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-header {
    text-align: center;
    margin-bottom: 2rem;
}

.section-header h2 {
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
    position: relative;
    display: inline-block;
}

.section-header h2::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 3px;
    background: var(--accent-color);
    border-radius: 2px;
}

.section-header p {
    color: #666;
    font-size: 1.1rem;
    margin-top: 1rem;
}

/* Hero Section */
.hero-card {
    text-align: center;
    padding: 4rem 2rem;
    margin: 2rem auto;
    max-width: 800px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(240, 248, 245, 0.9));
}

.hero-icon {
    width: 80px;
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.hero-title {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
}

.hero-text {
    font-size: 1.2rem;
    line-height: 1.8;
    color: var(--secondary-color);
    font-family: var(--font-heading);
}

.divider {
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
    margin: 2rem 0;
}

.dedication h3 {
    margin-bottom: 1rem;
}

.dedication p {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

/* Forms & Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 30px;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--text-light);
    box-shadow: 0 4px 15px rgba(13, 59, 46, 0.3);
}

.btn-primary:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(13, 59, 46, 0.4);
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: var(--text-light);
}

.custom-select,
.custom-input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid rgba(13, 59, 46, 0.2);
    border-radius: 12px;
    font-family: var(--font-body);
    font-size: 1rem;
    background: #fff;
    transition: all 0.3s ease;
}

.custom-select:focus,
.custom-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}

/* Quran Section */
.quran-controls {
    padding: 2rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .quran-controls {
        grid-template-columns: 1fr 1fr auto;
        align-items: end;
    }
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--primary-color);
}

.surah-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.surah-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.surah-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border-color: var(--accent-color);
}

.surah-info h3 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 0.2rem;
}

.surah-info span {
    font-size: 0.85rem;
    color: #7f8c8d;
}

.surah-actions {
    display: flex;
    gap: 0.5rem;
}

.surah-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--bg-light);
    color: var(--primary-color);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.surah-btn.play-btn {
    background: var(--primary-color);
    color: var(--accent-color);
}

.surah-btn:hover {
    background: var(--accent-color);
    color: white;
    transform: scale(1.1);
}

/* Audio Player Fixed Bottom */
.audio-player-container {
    position: fixed;
    bottom: 70px;
    /* Above nav on mobile */
    left: 10px;
    right: 10px;
    background: rgba(13, 59, 46, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--accent-color);
    border-radius: 20px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 999;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

@media (min-width: 768px) {
    .audio-player-container {
        bottom: 20px;
        left: auto;
        right: 20px;
        width: 400px;
    }
}

.audio-player-container.hidden {
    transform: translateY(150%);
}

.playing-info {
    display: flex;
    justify-content: space-between;
    color: var(--text-light);
    font-size: 0.9rem;
    padding: 0 0.5rem;
}

#playing-surah-name {
    color: var(--accent-color);
    font-weight: bold;
    font-family: var(--font-heading);
}

audio {
    width: 100%;
    height: 40px;
}

audio::-webkit-media-controls-panel {
    background-color: #eef2f0;
}

.close-player-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: #e74c3c;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Tree Section */
.tree-container {
    width: 100%;
    height: 600px;
    position: relative;
    overflow: auto;
    background: #fdfdfd;
    padding: 2rem;
}

#tree-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.tree-nodes {
    position: relative;
    min-width: 800px;
    min-height: 500px;
}

.tree-node {
    position: absolute;
    background: white;
    border: 2px solid var(--primary-color);
    border-radius: 30px;
    padding: 0.5rem 1.5rem;
    font-family: var(--font-heading);
    font-weight: bold;
    color: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transform: translate(-50%, -50%);
    /* Center on coordinates */
    transition: all 0.3s ease;
    z-index: 2;
    text-align: center;
    white-space: nowrap;
}

.tree-node:hover {
    background: var(--primary-color);
    color: var(--accent-color);
    transform: translate(-50%, -50%) scale(1.1);
}

/* Memorize Section */
.memorize-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 768px) {
    .memorize-grid {
        grid-template-columns: 3fr 2fr;
    }
}

.tracker-card,
.guidance-card {
    padding: 2rem;
}

.tracker-card h3,
.guidance-card h3 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    border-bottom: 2px solid rgba(212, 175, 55, 0.3);
    padding-bottom: 0.5rem;
}

.tracker-form {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.tracker-form input {
    flex: 1;
    min-width: 150px;
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: white;
    border-radius: 12px;
    margin-bottom: 0.8rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.history-item .date {
    font-size: 0.8rem;
    color: #95a5a6;
}

.tips-list {
    list-style: none;
}

.tips-list li {
    margin-bottom: 1rem;
    line-height: 1.6;
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
}

.tips-list i {
    color: var(--accent-color);
    margin-top: 5px;
}

/* Tasbeeh Section */
.tasbeeh-container {
    text-align: center;
    padding: 3rem 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.tasbeeh-display {
    font-size: 3rem;
    font-family: var(--font-heading);
    color: var(--primary-color);
    margin-bottom: 1rem;
    min-height: 80px;
}

.counter-display {
    font-size: 5rem;
    font-weight: bold;
    color: var(--accent-color);
    margin-bottom: 2rem;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.tasbeeh-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.btn-tasbeeh {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: none;
    background: var(--primary-color);
    color: white;
    font-size: 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(13, 59, 46, 0.4);
    transition: transform 0.1s ease;
}

.btn-tasbeeh:active {
    transform: scale(0.95);
    background: var(--secondary-color);
}

.btn-tasbeeh i {
    font-size: 2rem;
    color: var(--accent-color);
}

.btn-reset {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: #e74c3c;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(231, 76, 60, 0.3);
    align-self: flex-end;
}

.tasbeeh-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.t-opt {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--primary-color);
    background: white;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.t-opt.active,
.t-opt:hover {
    background: var(--primary-color);
    color: white;
}

/* Azkar Cards */
.azkar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    max-width: 600px;
    margin: 2rem auto 0;
}

.azkar-card {
    padding: 2rem;
    text-align: center;
    text-decoration: none;
    color: var(--primary-color);
    transition: all 0.3s ease;
}

.azkar-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-color);
}

.azkar-icon {
    font-size: 3rem;
    color: var(--accent-color);
    margin-bottom: 1rem;
}

/* Loader */
.loader-container {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
}

.loader {
    border: 4px solid rgba(13, 59, 46, 0.1);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 0;
    width: 90%;
    max-width: 600px;
    border-radius: 20px;
    position: relative;
    animation: slideDown 0.3s ease-out;
    overflow: hidden;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close-modal {
    color: rgba(255, 255, 255, 0.8);
    position: absolute;
    top: 15px;
    left: 20px;
    /* RTL - left instead of right */
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
}

.close-modal:hover {
    color: white;
}

.modal-header {
    background: var(--primary-color);
    color: var(--accent-color);
    padding: 1.5rem 2rem;
    font-family: var(--font-heading);
}

.modal-header h2 {
    color: var(--accent-color);
}

.modal-body {
    padding: 2rem;
    line-height: 1.8;
    font-size: 1.1rem;
}

/* Prophet Modals Specific Styles */
.prophet-details p {
    margin-bottom: 1rem;
}

.prophet-details strong {
    color: var(--primary-color);
}

.prophet-details ul {
    list-style: none;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px dashed rgba(13, 59, 46, 0.2);
}

.prophet-details ul li {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: #444;
}

.prophet-details ul li i {
    color: var(--accent-color);
    font-size: 1.2rem;
}

.badge {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    background: var(--bg-light);
    color: var(--primary-color);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 1rem;
    border: 1px solid var(--primary-color);
}

/* --- Quran Reader Modal --- */
.quran-modal .modal-content {
    width: 95%;
    max-width: 900px;
    height: 90vh;
    margin: 5vh auto;
    display: flex;
    flex-direction: column;
}

.reader-header {
    background: var(--primary-color);
    color: var(--accent-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-heading);
}

.reader-header h2 {
    color: var(--accent-color);
    margin: 0;
    font-size: 1.8rem;
}

.close-reader {
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    transition: color 0.2s;
}

.close-reader:hover {
    color: var(--accent-hover);
}

.reader-controls {
    display: flex;
    gap: 1rem;
}

.reader-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.reader-btn:hover {
    background: var(--accent-color);
    color: var(--primary-color);
}

.reader-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: #fcfcfc;
    /* Beautiful islamic pattern for reading background */
    background-image: url('data:image/svg+xml;utf8,<svg width="60" height="60" viewBox="0 0 60 60" xmlns="http://www.w3.org/2000/svg"><path d="M30 0l30 30-30 30L0 30z" fill="rgba(212,175,55,0.03)"/></svg>');
}

.bismillah {
    text-align: center;
    font-family: 'Amiri', serif;
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(13, 59, 46, 0.1);
}

.bismillah.hidden {
    display: none;
}

.quran-text {
    direction: rtl;
    text-align: justify;
    text-justify: inter-word;
    line-height: 2.2;
    padding: 0 1rem;
    /* We start at 24px and allow it to be changed via JS */
    font-size: 24px;
    color: #222;
    /* Use a traditional font for Quran if 'Amiri' is the base */
    font-family: 'Amiri', serif;
}

.ayah-text {
    display: inline;
}

.ayah-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8em;
    height: 1.8em;
    margin: 0 0.4em;
    background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><path d="M50 5 L95 50 L50 95 L5 50 Z" fill="none" stroke="%23d4af37" stroke-width="4"/></svg>') center/contain no-repeat;
    font-size: 0.6em;
    color: var(--primary-color);
    font-weight: bold;
    font-family: 'Tajawal', sans-serif;
}