@import url("https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&family=Outfit:wght@300;400;500;600&display=swap");

:root {
    --primary-color: #1b4332;
    --primary-light: #2d6a4f;
    --secondary-color: #d8f3dc;
    --accent-color: #b7b7a4;
    --text-color: #404040;
    --dark-text: #081c15;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --nav-bg: #ffffff;
    --nav-border: #e0e0e0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --bottom-nav-height: 70px;

    --arabic-font: "Amiri", serif;
    --eng-font: "Outfit", sans-serif;
}

/* Dark Mode Variables */
body.dark-mode {
    --primary-color: #40916c;
    --primary-light: #52b788;
    --secondary-color: #1b4332;
    --accent-color: #74c69d;
    --text-color: #e0e0e0;
    --dark-text: #ffffff;
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --nav-bg: #1e1e1e;
    --nav-border: #333333;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    font-family: var(--eng-font);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    padding-bottom: calc(
        var(--bottom-nav-height) + 20px
    ); /* Space for bottom nav */
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header */
header {
    background: var(--nav-bg);
    color: var(--primary-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--nav-border);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

header .container {
    display: flex;
    justify-content: center; /* Center logo */
    align-items: center;
}

header .logo a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 2rem 1rem;
    margin-bottom: 1rem;
}

.hero h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    margin-top: 0;
}

.hero p {
    color: var(--text-color);
    font-size: 1rem;
    opacity: 0.8;
}

/* Search */
.search-container {
    margin: 1.5rem 0;
}

.search-input {
    width: 100%;
    padding: 14px 20px;
    border-radius: 16px;
    border: 1px solid var(--nav-border);
    background: var(--card-bg);
    color: var(--dark-text);
    font-size: 1rem;
    outline: none;
    box-shadow: var(--shadow);
    transition: all 0.3s;
    font-family: var(--eng-font);
}

.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(27, 67, 50, 0.1);
}

/* Surah Grid */
.surah-grid {
    display: grid;
    grid-template-columns: 1fr; /* Mobile first: 1 column */
    gap: 16px;
}

@media (min-width: 768px) {
    .surah-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

.surah-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
    border: 1px solid transparent;
    transition: transform 0.2s;
}

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

.surah-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.surah-number {
    background: var(--secondary-color);
    color: var(--primary-color);
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
}

.surah-names h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--dark-text);
    font-weight: 600;
}

.surah-names span {
    font-size: 0.8rem;
    color: var(--text-color);
    opacity: 0.8;
}

.surah-arabic h3 {
    font-family: var(--arabic-font);
    margin: 0;
    font-size: 1.3rem;
    color: var(--primary-color);
}

.surah-arabic span {
    font-size: 0.75rem;
    color: var(--text-color);
    opacity: 0.7;
    display: block;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--bottom-nav-height);
    background: var(--nav-bg);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--nav-border);
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    padding: 0 10px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-color);
    font-size: 0.75rem;
    gap: 4px;
    width: 100%;
    height: 100%;
    opacity: 0.6;
    transition: all 0.2s;
}

.nav-item svg {
    width: 24px;
    height: 24px;
}

.nav-item.active {
    color: var(--primary-color);
    opacity: 1;
}

/* Surah Page */
.quran-text-block {
    font-family: var(--arabic-font);
    font-size: 2rem;
    line-height: 2.2;
    text-align: justify;
    text-align-last: center;
    direction: rtl;
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
    color: var(--dark-text);
    margin-top: 1rem;
}

.ayah-end-symbol {
    color: var(--primary-color);
    font-size: 0.8em;
    margin: 0 4px;
}

.bismillah {
    text-align: center;
    font-family: var(--arabic-font);
    font-size: 2rem;
    color: var(--primary-color);
    margin: 1rem 0;
}

/* Interactive Ayah Selection */
.ayah-span {
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-radius: 8px;
    padding: 2px 4px;
    display: inline;
}

.ayah-span:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

body.dark-mode .ayah-span:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.ayah-span.active {
    background-color: var(--secondary-color);
    color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--secondary-color);
}

body.dark-mode .ayah-span.active {
    background-color: rgba(64, 145, 108, 0.2);
    box-shadow: 0 0 0 2px rgba(64, 145, 108, 0.2);
    color: var(--primary-light);
}

/* Navigation Buttons in Surah */
.surah-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    gap: 10px;
}

.nav-btn {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
    background: var(--card-bg);
    color: var(--primary-color);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    border: 1px solid var(--nav-border);
    box-shadow: var(--shadow);
    font-size: 0.9rem;
}

/* Bookmark Button */
.bookmark-btn {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 20px);
    right: 20px; /* Closer to edge on mobile */
    background: var(--primary-color);
    color: #fff;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    box-shadow: 0 4px 15px rgba(27, 67, 50, 0.4);
    cursor: pointer;
    z-index: 900; /* Below nav but above content */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.bookmark-btn:hover {
    transform: scale(1.1);
}

.bookmark-btn svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.bookmark-btn.saved svg {
    fill: currentColor;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 80px); /* Above bookmark btn */
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 30px; /* Pill shape */
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    width: max-content;
    max-width: 90%;
    text-align: center;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0 1rem;
    font-size: 0.8rem;
    color: var(--text-color);
    opacity: 0.6;
}

/* Utilities */
.hidden {
    display: none !important;
}
