/* ============================================================
   Salsabeel.org.uk - Main Stylesheet
   Islamic Manuscript Aesthetic - Deep Forest Green & Gold
   ============================================================ */

:root {
    --green-deep:    #0d2318;
    --green-dark:    #1a3a2a;
    --green-mid:     #2d5a40;
    --green-light:   #4a8c62;
    --green-pale:    #e8f4ed;
    --gold:          #c9a84c;
    --gold-light:    #e8c97a;
    --gold-pale:     #fdf6e3;
    --cream:         #faf7f0;
    --cream-dark:    #f0ebe0;
    --text-dark:     #1a1208;
    --text-mid:      #3d3020;
    --text-light:    #7a6a50;
    --arabic-red:    #8b1a1a;
    --shadow:        rgba(13,35,24,0.18);
    --radius:        12px;
    --radius-lg:     20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
    background: var(--cream);
    color: var(--text-dark);
    line-height: 2;
    direction: rtl;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ---- Geometric Background ---- */
.geometric-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse at 15% 20%, rgba(45,90,64,0.07) 0%, transparent 55%),
        radial-gradient(ellipse at 85% 80%, rgba(201,168,76,0.06) 0%, transparent 55%),
        url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%232d5a40' fill-opacity='0.03'%3E%3Cpath d='M40 0 L80 20 L80 60 L40 80 L0 60 L0 20Z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    background-color: var(--cream);
}

/* ---- Navbar ---- */
.navbar {
    background: var(--green-deep);
    border-bottom: 2px solid var(--gold);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 20px var(--shadow);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 70px;
}

.nav-logo {
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.logo-arabic {
    font-family: 'Lateef', 'Amiri', serif;
    font-size: 2rem;
    color: var(--gold);
    line-height: 1.1;
}

.logo-sub {
    font-size: 0.7rem;
    color: var(--green-pale);
    opacity: 0.8;
    letter-spacing: 0.5px;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.nav-links a {
    color: var(--cream);
    text-decoration: none;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid transparent;
}

.nav-links a:hover,
.nav-links a.active {
    background: var(--green-mid);
    border-color: var(--gold);
    color: var(--gold-light);
}

.nav-toggle {
    display: none;
    background: none;
    border: 1px solid var(--gold);
    color: var(--gold);
    padding: 0.4rem 0.7rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
}

.nav-mobile {
    display: none;
    background: var(--green-dark);
    border-bottom: 1px solid var(--gold);
    padding: 0.5rem;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-mobile a {
    color: var(--cream);
    text-decoration: none;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    display: block;
}

.nav-mobile a:hover { background: var(--green-mid); color: var(--gold); }
.nav-mobile.open { display: flex; }

/* ---- Main Content ---- */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ---- Hero Section ---- */
.hero {
    text-align: center;
    padding: 3rem 1rem;
    position: relative;
}

.hero-bismillah {
    font-family: 'Lateef', 'Amiri', serif;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    color: var(--arabic-red);
    margin-bottom: 1.5rem;
    text-shadow: 0 1px 3px rgba(139,26,26,0.15);
}

.hero-title {
    font-family: 'Lateef', 'Amiri', serif;
    font-size: clamp(3rem, 10vw, 7rem);
    color: var(--green-dark);
    line-height: 0.9;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 8px rgba(26,58,42,0.15);
}

.hero-verse {
    font-family: 'Amiri', serif;
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    color: var(--gold);
    margin: 1rem 0 0.4rem;
    direction: rtl;
}

.hero-verse-tr {
    font-size: 0.95rem;
    color: var(--text-light);
    margin-bottom: 0.3rem;
}

.hero-ref {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 2rem;
}

.hero-subtitle {
    font-size: clamp(1rem, 2.5vw, 1.35rem);
    color: var(--text-mid);
    margin-bottom: 0.5rem;
}

.hero-author {
    font-size: 1rem;
    color: var(--green-mid);
    margin-bottom: 2.5rem;
}

.hero-divider {
    width: 200px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    margin: 1.5rem auto;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.75rem;
    border-radius: var(--radius);
    font-family: 'Noto Nastaliq Urdu', serif;
    font-size: 1rem;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.25s;
    font-weight: 500;
}

.btn-primary {
    background: var(--green-dark);
    color: var(--gold-light);
    border: 2px solid var(--green-mid);
}
.btn-primary:hover {
    background: var(--green-mid);
    border-color: var(--gold);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow);
}

.btn-gold {
    background: var(--gold);
    color: var(--green-deep);
    border: 2px solid var(--gold-light);
    font-weight: 700;
}
.btn-gold:hover {
    background: var(--gold-light);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(201,168,76,0.3);
}

.btn-outline {
    background: transparent;
    color: var(--green-dark);
    border: 2px solid var(--green-mid);
}
.btn-outline:hover {
    background: var(--green-pale);
    border-color: var(--green-dark);
}

/* ---- Cards ---- */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.card {
    background: white;
    border: 1px solid var(--cream-dark);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 4px;
    height: 100%;
    background: var(--gold);
    opacity: 0;
    transition: opacity 0.25s;
}

.card:hover {
    border-color: var(--green-light);
    box-shadow: 0 8px 30px var(--shadow);
    transform: translateY(-3px);
}
.card:hover::before { opacity: 1; }

.card-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    display: block;
}

.card-title {
    font-size: 1.2rem;
    color: var(--green-dark);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.card-desc {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.8;
}

/* ---- Section Headers ---- */
.section-header {
    text-align: center;
    margin: 3rem 0 2rem;
}

.section-title {
    font-family: 'Lateef', 'Amiri', serif;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    color: var(--green-dark);
    margin-bottom: 0.5rem;
}

.section-line {
    width: 120px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    margin: 0.75rem auto;
}

.section-sub {
    color: var(--text-light);
    font-size: 0.95rem;
}

/* ---- Chapter List ---- */
.chapter-list {
    background: white;
    border: 1px solid var(--cream-dark);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.chapter-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--cream-dark);
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
    gap: 1rem;
}

.chapter-item:last-child { border-bottom: none; }
.chapter-item:hover { background: var(--green-pale); }

.chapter-num {
    background: var(--green-dark);
    color: var(--gold);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.chapter-name {
    flex: 1;
    font-size: 1rem;
    color: var(--text-dark);
}

.chapter-name-en {
    font-size: 0.8rem;
    color: var(--text-light);
    display: block;
    direction: ltr;
    text-align: right;
    font-family: Georgia, serif;
}

.chapter-page {
    font-size: 0.8rem;
    color: var(--text-light);
    direction: ltr;
    flex-shrink: 0;
}

/* ---- Reader ---- */
.reader-container {
    max-width: 800px;
    margin: 0 auto;
}

.reader-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--green-dark);
    color: var(--cream);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.page-indicator {
    color: var(--gold);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.reader-content {
    background: white;
    border: 1px solid var(--cream-dark);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: 0 4px 20px var(--shadow);
    min-height: 500px;
    position: relative;
}

.reader-content img {
    max-width: 100%;
    border-radius: 8px;
}

.page-text {
    font-size: 1.15rem;
    line-height: 2.4;
    color: var(--text-dark);
    text-align: justify;
}

.page-text .arabic {
    font-family: 'Amiri', serif;
    font-size: 1.3rem;
    color: var(--arabic-red);
    display: block;
    text-align: center;
    margin: 1rem 0;
    line-height: 2;
}

.reader-image {
    width: 100%;
    display: block;
    border-radius: 8px;
}

.no-image-text {
    padding: 1rem 0;
}

/* ---- Search ---- */
.search-box {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2rem;
    background: white;
    border: 2px solid var(--green-mid);
    border-radius: var(--radius-lg);
    padding: 0.4rem;
    transition: border-color 0.2s;
}

.search-box:focus-within {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201,168,76,0.15);
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-family: 'Noto Nastaliq Urdu', serif;
    font-size: 1rem;
    padding: 0.5rem 0.75rem;
    background: transparent;
    direction: rtl;
    color: var(--text-dark);
}

.search-btn {
    background: var(--green-dark);
    color: var(--gold);
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}
.search-btn:hover { background: var(--green-mid); }

.search-result {
    background: white;
    border: 1px solid var(--cream-dark);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: all 0.2s;
    border-right: 4px solid var(--green-light);
}

.search-result:hover {
    border-right-color: var(--gold);
    box-shadow: 0 4px 15px var(--shadow);
    transform: translateX(-3px);
}

.result-page {
    font-size: 0.8rem;
    color: var(--gold);
    background: var(--green-dark);
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
    display: inline-block;
    margin-bottom: 0.5rem;
}

.result-snippet {
    font-size: 0.95rem;
    color: var(--text-mid);
    line-height: 1.9;
}

mark {
    background: rgba(201,168,76,0.3);
    color: var(--text-dark);
    padding: 0 2px;
    border-radius: 2px;
}

/* ---- AI Chat ---- */
.chat-container {
    max-width: 800px;
    margin: 0 auto;
}

.chat-intro {
    background: linear-gradient(135deg, var(--green-deep), var(--green-dark));
    color: white;
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--gold);
    text-align: center;
}

.chat-intro h2 {
    font-family: 'Lateef', 'Amiri', serif;
    font-size: 1.8rem;
    color: var(--gold-light);
    margin-bottom: 0.5rem;
}

.chat-intro p {
    font-size: 0.9rem;
    opacity: 0.85;
    line-height: 1.8;
}

.chat-messages {
    background: white;
    border: 1px solid var(--cream-dark);
    border-radius: var(--radius-lg);
    min-height: 400px;
    max-height: 550px;
    overflow-y: auto;
    padding: 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.msg {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius);
    max-width: 85%;
    font-size: 0.95rem;
    line-height: 2;
    animation: fadeInUp 0.3s ease;
}

.msg-user {
    background: var(--green-dark);
    color: var(--cream);
    align-self: flex-start;
    border-bottom-right-radius: 4px;
}

.msg-ai {
    background: var(--gold-pale);
    border: 1px solid rgba(201,168,76,0.25);
    color: var(--text-dark);
    align-self: flex-end;
    border-bottom-left-radius: 4px;
}

.msg-ai .msg-label {
    font-size: 0.7rem;
    color: var(--gold);
    margin-bottom: 0.25rem;
    display: block;
}

.chat-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 0.75rem 1rem;
}

.chat-typing span {
    width: 8px; height: 8px;
    background: var(--green-mid);
    border-radius: 50%;
    animation: bounce 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

.chat-input-area {
    display: flex;
    gap: 0.75rem;
    background: white;
    border: 2px solid var(--green-mid);
    border-radius: var(--radius-lg);
    padding: 0.4rem;
    transition: border-color 0.2s;
}

.chat-input-area:focus-within {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201,168,76,0.15);
}

.chat-input {
    flex: 1;
    border: none;
    outline: none;
    font-family: 'Noto Nastaliq Urdu', serif;
    font-size: 0.95rem;
    padding: 0.5rem 0.75rem;
    background: transparent;
    resize: none;
    min-height: 46px;
    max-height: 120px;
    direction: rtl;
    color: var(--text-dark);
}

.chat-send {
    background: var(--green-dark);
    color: var(--gold);
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
    align-self: flex-end;
}
.chat-send:hover { background: var(--green-mid); }
.chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

.suggested-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.suggested-q {
    background: var(--green-pale);
    border: 1px solid var(--green-light);
    color: var(--green-dark);
    padding: 0.4rem 0.85rem;
    border-radius: 20px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Noto Nastaliq Urdu', serif;
}
.suggested-q:hover {
    background: var(--green-dark);
    color: var(--gold);
    border-color: var(--gold);
}

/* ---- Translation Toggle ---- */
.lang-toggle {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.lang-btn {
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--green-mid);
    background: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.82rem;
    transition: all 0.15s;
    color: var(--text-mid);
}

.lang-btn.active,
.lang-btn:hover {
    background: var(--green-dark);
    color: var(--gold);
    border-color: var(--green-dark);
}

/* ---- About ---- */
.about-card {
    background: white;
    border: 1px solid var(--cream-dark);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: 0 4px 20px var(--shadow);
    max-width: 800px;
    margin: 0 auto;
}

.about-title {
    font-family: 'Lateef', 'Amiri', serif;
    font-size: 2rem;
    color: var(--green-dark);
    margin-bottom: 1rem;
    text-align: center;
}

.about-dates {
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.about-body {
    font-size: 1rem;
    line-height: 2.2;
    color: var(--text-mid);
    margin-bottom: 1.5rem;
}

.duaa-box {
    background: var(--green-deep);
    color: var(--cream);
    border-radius: var(--radius);
    padding: 1.75rem;
    text-align: center;
    margin-top: 2rem;
    border: 1px solid var(--gold);
}

.duaa-arabic {
    font-family: 'Amiri', serif;
    font-size: 1.4rem;
    color: var(--gold);
    direction: rtl;
    margin-bottom: 0.75rem;
    line-height: 2;
}

.duaa-urdu {
    font-size: 0.9rem;
    opacity: 0.85;
    line-height: 2;
}

/* ---- Pagination ---- */
.pagination {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin: 2rem 0;
}

.pagination a, .pagination span {
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--cream-dark);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-mid);
    font-size: 0.9rem;
    transition: all 0.15s;
    direction: ltr;
}

.pagination a:hover { background: var(--green-pale); border-color: var(--green-mid); }
.pagination .current { background: var(--green-dark); color: var(--gold); border-color: var(--green-dark); }

/* ---- Notice/Alert ---- */
.notice {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin: 1rem 0;
    font-size: 0.9rem;
}
.notice-gold { background: var(--gold-pale); border: 1px solid rgba(201,168,76,0.4); color: var(--text-mid); }
.notice-green { background: var(--green-pale); border: 1px solid var(--green-light); color: var(--green-dark); }
.notice-red { background: #fff5f5; border: 1px solid #f5c6c6; color: #8b0000; }

/* ---- Footer ---- */
.footer {
    background: var(--green-deep);
    color: var(--cream);
    margin-top: 4rem;
    border-top: 2px solid var(--gold);
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 1.5rem;
}

.footer-top {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-arabic {
    font-family: 'Lateef', 'Amiri', serif;
    font-size: 2.5rem;
    color: var(--gold);
    margin-bottom: 0.5rem;
}

.footer-verse {
    font-family: 'Amiri', serif;
    font-size: 1rem;
    color: var(--gold-light);
    direction: rtl;
    margin-bottom: 0.25rem;
}

.footer-verse-tr {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-bottom: 0.2rem;
}

.footer-ref {
    font-size: 0.75rem;
    opacity: 0.5;
}

.footer-links h4,
.footer-duaa h4 {
    color: var(--gold);
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.footer-links a {
    display: block;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.88rem;
    margin-bottom: 0.3rem;
    transition: color 0.15s;
}
.footer-links a:hover { color: var(--gold); }

.duaa-arabic {
    font-family: 'Amiri', serif;
    font-size: 1.1rem;
    color: var(--gold-light);
    direction: rtl;
    margin-bottom: 0.5rem;
    line-height: 2;
}

.duaa-urdu {
    font-size: 0.82rem;
    opacity: 0.75;
    line-height: 2;
    margin-bottom: 0.5rem;
}

.sadqa-note {
    font-size: 0.82rem;
    color: var(--gold);
    margin-top: 0.75rem;
}

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 1.25rem;
    text-align: center;
    font-size: 0.82rem;
    opacity: 0.65;
    line-height: 1.8;
}

.footer-sub { margin-top: 0.25rem; font-style: italic; }

/* ---- Animations ---- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

.fade-in {
    animation: fadeInUp 0.5s ease both;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .nav-links { display: none; }
    .nav-toggle { display: block; }

    .hero { padding: 2rem 0.5rem; }
    .hero-title { font-size: 4rem; }

    .reader-content { padding: 1.25rem; }
    .page-text { font-size: 1rem; }

    .chat-messages { max-height: 380px; }

    .about-card { padding: 1.5rem; }

    .main-content { padding: 1.5rem 1rem; }

    .cards-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .hero-title { font-size: 3rem; }
    .btn { padding: 0.6rem 1.25rem; font-size: 0.9rem; }
}

/* ---- Loader ---- */
.loader {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Import mode scrollbar ---- */
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: var(--cream-dark); border-radius: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--green-light); border-radius: 3px; }

/* ---- RTL input fix ---- */
input[type="text"], input[type="search"], textarea {
    font-family: 'Noto Nastaliq Urdu', serif;
}
