:root {
    --primary-color: #1B5E20;
    --primary-light: #4C8C4A;
    --secondary-color: #FFA000;
    --bg-color: #F8F9FA;
    --card-bg: rgba(255, 255, 255, 0.85);
    --text-main: #2C3E50;
    --text-muted: #7F8C8D;
    --danger: #E74C3C;
    --warning: #F1C40F;
    --success: #27AE60;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.25);
    --radius: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(var(--primary-light) 0.5px, transparent 0.5px);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

h1,
h2,
h3,
h4 {
    font-weight: 700;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.9rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-light);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
}

/* Glassmorphism */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
}

/* Header */
.app-header {
    background: var(--primary-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 800;
}

.status-indicator {
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
}

.status-indicator.offline {
    background: var(--danger);
}

/* Main layout */
.app-main {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 80px;
    /* space for bottom nav */
}

/* Views */
.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dashboard */
.dashboard-header {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-header p {
    color: var(--text-muted);
}


.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
}

.stat-icon {
    background: rgba(27, 94, 32, 0.1);
    color: var(--primary-color);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-info h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.stat-info p {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.actions-row {
    padding-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.dashboard-charts-wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.dashboard-charts-wrapper.layout-row {
    flex-direction: row;
    align-items: stretch;
}

.dashboard-charts-wrapper.layout-row .charts-container {
    flex: 1;
    min-width: 0;
    /* Prevents flex items from overflowing */
}

.charts-container {
    padding: 15px;
    display: flex;
    flex-direction: column;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    flex-grow: 1;
    min-height: 250px;
    /* Base height to prevent collapsing */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Surahs List */
.view-header {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.search-box {
    background: white;
    padding: 8px 15px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-sm);
    flex: 1;
    min-width: 200px;
}

.search-box input {
    border: none;
    outline: none;
    font-family: inherit;
    width: 100%;
}

.surahs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

.surah-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.surah-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.surah-number {
    background: var(--primary-color);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-family: 'Amiri', serif;
}

.surah-details {
    flex: 1;
    margin-right: 15px;
}

.surah-name {
    font-family: 'Amiri', serif;
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--primary-color);
}

.surah-verses {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Reading View */
.read-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 15px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    position: sticky;
    top: 0;
    z-index: 5;
}

.bismillah {
    text-align: center;
    font-family: 'Amiri', serif;
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 25px;
}

.verses-container {
    background: white;
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    line-height: 2.8;
    text-align: justify;
    text-justify: inter-word;
    font-family: 'Amiri', serif;
    font-size: 1.6rem;
    direction: rtl;
}

.verse {
    cursor: pointer;
    transition: background-color 0.3s;
    padding: 0 5px;
    border-radius: 4px;
}

.verse:hover {
    background-color: rgba(255, 160, 0, 0.1);
}

/* Verse Number symbol ۝ */
.verse-num {
    font-size: 1.1rem;
    color: var(--secondary-color);
    margin: 0 8px;
    white-space: nowrap;
}

/* Mistake Types and Mutashabihat styling */
.verse.error-tajweed {
    background-color: rgba(52, 152, 219, 0.4); /* Blue-ish */
}
.verse.error-tashkeel {
    background-color: rgba(241, 196, 15, 0.4); /* Yellow-ish */
}
.verse.error-hifz {
    background-color: rgba(231, 76, 60, 0.4); /* Red-ish */
}
.verse.has-mutashabeh {
    background-color: rgba(155, 89, 182, 0.35); /* Purple-ish */
    text-decoration: none;
}

/* Recitation Session Hidden Verse */
.recitation-hidden {
    color: transparent !important;
    text-shadow: 0 0 15px rgba(0,0,0,0.5);
    transition: all 0.3s ease;
    user-select: none;
}

/* Active Session Indicator */
.session-active {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(231, 76, 60, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
    }
}


/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    display: flex;
    justify-content: space-around;
    padding: 15px 10px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 10;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}

.nav-item {
    text-decoration: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    transition: color 0.3s;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-item i {
    font-size: 1.3rem;
}

/* --- Recitation Controls --- */
.recitation-controls {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    padding: 1rem;
    border-radius: 20px;
    display: none;
    gap: 1rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    z-index: 900;
    width: 90%;
    max-width: 400px;
}
.recitation-controls.active {
    display: flex;
}

/* --- Install PWA Card --- */
.install-card {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    padding: 1.5rem;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(27, 94, 32, 0.1), rgba(27, 94, 32, 0.05));
    border: 1px solid rgba(27, 94, 32, 0.2);
    margin-bottom: 2rem;
}

.install-card-content {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.install-icon {
    width: 60px;
    height: 60px;
    background: var(--primary-color);
    color: white;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: 0 5px 15px rgba(27, 94, 32, 0.3);
}

.install-text h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--primary-color);
}

.install-text p {
    margin: 0.3rem 0 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 500px;
    border-radius: var(--radius);
    padding: 0;
    box-shadow: var(--shadow-md);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
}

.modal-body {
    padding: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

@media (max-width: 480px) {
    .modal-actions {
        flex-direction: column;
    }
    .modal-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

.ayah-preview {
    font-family: 'Amiri', serif;
    font-size: 1.2rem;
    color: var(--primary-color);
    background: rgba(27, 94, 32, 0.05);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    line-height: 1.6;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
}

textarea,
input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.3s;
}

textarea:focus,
input:focus,
select:focus {
    border-color: var(--primary-color);
    outline: none;
}

.tags-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.tag-radio input {
    display: none;
}

.tag {
    display: inline-block;
    padding: 6px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    border: 1px solid #ddd;
    color: var(--text-muted);
    transition: all 0.2s;
}

.tag-radio input:checked+.tag-hifz {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.tag-radio input:checked+.tag-tashkeel {
    background: var(--warning);
    color: #333;
    border-color: var(--warning);
}

.tag-radio input:checked+.tag-tajweed {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

/* Mutashabihat List Items */
.mutashabeh-card {
    background: white;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: var(--shadow-sm);
    border-right: 4px solid var(--secondary-color);
}

.m-verse {
    font-family: 'Amiri', serif;
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.m-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.m-rule {
    background: rgba(255, 160, 0, 0.1);
    padding: 10px;
    border-radius: 6px;
    font-weight: 500;
    color: #b27300;
}

/* Mutashabihat Search */
.mut-search-results {
    display: none;
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: var(--shadow-sm);
}
.mut-search-result-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-family: 'Amiri', serif;
    font-size: 1.1rem;
    line-height: 1.5;
}
.mut-search-result-item:hover {
    background: rgba(27, 94, 32, 0.05);
}
.mut-search-result-meta {
    font-family: 'Tajawal', sans-serif;
    font-size: 0.8rem;
    color: var(--primary-color);
    margin-bottom: 5px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Custom Confirm Dialog */
.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.confirm-overlay.show {
    opacity: 1;
    visibility: visible;
}

.confirm-dialog {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 90%;
    text-align: center;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.confirm-overlay.show .confirm-dialog {
    transform: translateY(0);
}

.confirm-dialog h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--text-main);
    font-size: 1.4rem;
}

.confirm-dialog p {
    margin-bottom: 25px;
    color: var(--text-muted);
    line-height: 1.6;
    font-size: 1.1rem;
}

.confirm-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.confirm-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

@media (max-width: 480px) {
    .confirm-buttons {
        flex-direction: column;
    }
    .confirm-buttons .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Desktop optimization */
@media (min-width: 768px) {
    body {
        flex-direction: row;
    }

    .hide-on-mobile {
        display: flex;
    }

    .app-header {
        display: none;
    }

    /* Could hide mobile header or move logo */
    .bottom-nav {
        position: relative;
        flex-direction: column;
        width: 100px;
        height: 100vh;
        justify-content: flex-start;
        padding-top: 30px;
        gap: 20px;
        border-radius: 0;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.05);
        order: -1;
    }

    .recitation-controls {
        bottom: 30px;
        left: calc(50% + 50px);
    }

    .nav-item i {
        font-size: 1.8rem;
    }

    .app-main {
        padding-bottom: 20px;
        padding-left: 20px;
    }

    .verses-container {
        padding: 40px 80px;
    }

    /* Default desktop layout - charts side by side */
    .dashboard-charts-wrapper {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}