:root {
    --primary-color: #27ae60;
    --secondary-color: #2c3e50;
    --bg-color: #f0f4f3;
    --white: #ffffff;
    --text-muted: #7f8c8d;
}

* {
    box-sizing: border-box; /* Memastikan padding tidak merusak lebar elemen */
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--secondary-color), #34495e);
    color: var(--white);
    padding: 50px 20px;
    text-align: center;
    width: 100%;
}

header h1 {
    margin: 0;
    font-size: 1.8rem;
}

/* Container & Search */
.search-container {
    width: 90%;
    max-width: 600px;
    margin: -30px auto 30px auto; /* Membuat kolom search "melayang" di atas header */
}

#searchInput {
    width: 100%;
    padding: 18px 25px;
    font-size: 16px;
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    outline: none;
    transition: 0.3s;
}

#searchInput:focus {
    box-shadow: 0 10px 35px rgba(39, 174, 96, 0.2);
}

/* Loading Animation */
#loading {
    text-align: center;
    padding: 50px;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 15px;
    border: 4px solid #ddd;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Main Content Container */
.container {
    width: 95%; /* Lebih lebar di layar kecil */
    max-width: 900px;
    margin: 0 auto 50px auto;
}

/* Card Style */
.card {
    background: var(--white);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transition: transform 0.2s;
    border: 1px solid #eef2f1;
}

.card:active {
    transform: scale(0.98); /* Efek sentuhan di HP */
}

.arabic {
    font-size: 1.8rem;
    color: var(--primary-color);
    text-align: right;
    direction: rtl;
    font-family: 'Amiri', serif;
    margin-bottom: 12px;
    font-weight: bold;
}

.translation {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 15px;
}

/* Grid Info yang Fleksibel */
.meta-grid {
    display: grid;
    grid-template-columns: 1fr; /* Default: 1 kolom (Mobile) */
    gap: 12px;
    border-top: 1px solid #f0f0f0;
    padding-top: 15px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.meta-item b {
    color: #34495e;
}

/* ---------- MEDIA QUERIES ---------- */

/* Tablet & Desktop (Layar > 600px) */
@media (min-width: 600px) {
    header h1 {
        font-size: 2.5rem;
    }

    .meta-grid {
        grid-template-columns: 1fr 1fr; /* Jadi 2 kolom di layar tablet */
    }

    .arabic {
        font-size: 2.2rem;
    }

    .container {
        width: 90%;
    }
}

/* Layar Besar (Desktop > 900px) */
@media (min-width: 900px) {
    .meta-grid {
        grid-template-columns: repeat(3, 1fr); /* Jadi 3 kolom di layar PC */
    }
}


/* Menyejajarkan elemen di dalam meta-item */
.info-row {
    display: flex;
    justify-content: space-between; /* Memberi jarak antara Sumber dan Halaman */
    gap: 15px;
    grid-column: 1 / -1; /* Membuat baris Sumber & Hal memenuhi lebar penuh kartu agar lebih sejajar */
    background: #f9f9f9;
    padding: 8px 12px;
    border-radius: 6px;
}

.source {
    flex: 2; /* Memberi ruang lebih besar untuk nama novel */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page {
    flex: 1;
    text-align: right;
    white-space: nowrap;
}

/* Gaya tambahan untuk kotak contoh kalimat */
.example-box {
    margin-top: 15px;
    padding: 12px;
    background-color: #f8fcf9;
    border-right: 4px solid var(--primary-color);
    border-radius: 8px;
}

.arabic-sentence {
    font-size: 1.1rem;
    color: #2c3e50;
    text-align: right;
    direction: rtl;
    margin: 0;
}

.indo-sentence {
    font-size: 13px;
    color: #666;
    margin: 8px 0 0 0;
    font-style: italic;
}

.full-width {
    grid-column: 1 / -1; /* Memastikan baris ini mengambil lebar penuh kartu */
    background-color: #f9f9f9;
    padding: 10px;
    border-radius: 8px;
    font-size: 14px;
    color: #555;
    border-left: 3px solid var(--primary-color);
}

.meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}

/* Memastikan di mobile tetap rapi */
@media (max-width: 600px) {
    .meta-grid {
        grid-template-columns: 1fr;
    }
}


.header-main {
    display: flex;
    justify-content: space-between; /* Arab di satu sisi, Tag di sisi lain */
    align-items: center; /* Sejajar secara vertikal */
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
    direction: rtl; /* Mengikuti arah baca Arab */
}

.tags-container {
    display: flex;
    gap: 10px;
    direction: ltr; /* Agar teks label tetap dibaca kiri ke kanan */
}

.tag-item {
    font-size: 12px;
    background: #f0f4f8;
    color: #555;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid #dce3e8;
    white-space: nowrap;
}

.arabic {
    font-size: 1.8rem;
    font-weight: bold;
    color: #2c3e50;
    margin: 0;
}

/* Penyesuaian Mobile */
@media (max-width: 600px) {
    .header-main {
        flex-direction: column;
        align-items: flex-end;
        gap: 10px;
    }
}


.header-right {
    display: flex;
    width: 100%;
    /* Memastikan konten didorong ke kanan secara paksa */
    justify-content: flex-end; 
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
    /* Menetapkan arah baca dari kanan ke kiri untuk seluruh baris */
    direction: rtl; 
}

.arabic-group {
    display: flex;
    align-items: baseline;
    gap: 10px;
    /* Memastikan teks tidak pecah ke baris baru di desktop */
    white-space: nowrap; 
}

.arabic {
    font-size: 2.2rem; /* Sedikit lebih besar untuk desktop */
    font-weight: bold;
    color: var(--primary-color);
    font-family: 'Amiri', serif; /* Pastikan font Arab terpasang */
}

.arabic-meta {
    font-size: 16px;
    color: #888;
    font-weight: normal;
    /* Memberikan sedikit jarak setelah koma secara visual tanpa spasi ketik */
    letter-spacing: 0.5px; 
}

/* Mengunci posisi agar tidak berubah di Desktop maupun Mobile */
.header-left {
    display: flex !important; /* Paksa gunakan flex */
    width: 100% !important;
    justify-content: flex-start !important; /* Paksa selalu di KIRI */
    align-items: baseline;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
    direction: ltr !important; /* Paksa arah konten dari kiri ke kanan */
}

.arabic-group {
    display: flex;
    flex-direction: row; 
    align-items: baseline;
    gap: 8px;
    white-space: nowrap; /* Mencegah teks turun ke bawah di layar kecil */
}

.arabic {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--primary-color);
    direction: rtl; /* Teks Arabnya tetap kanan-ke-kiri, tapi posisinya dikunci di kiri */
}

.arabic-meta {
    font-size: 14px;
    color: #888;
    direction: ltr;
}

/* Mengatur font Arab untuk kata kunci utama */
.arabic {
    font-family: 'Amiri', 'Scheherazade New', serif; /* Menggunakan Amiri sebagai utama */
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--primary-color);
    direction: rtl;
    line-height: 1.6; /* Memberikan ruang agar harakat tidak terpotong */
}

/* Mengatur font Arab untuk contoh kalimat di dalam example-box */
.arabic-sentence {
    font-family: 'Scheherazade New', 'Amiri', serif; /* Scheherazade biasanya lebih bagus untuk teks panjang */
    font-size: 1.5rem;
    color: #333;
    direction: rtl;
    text-align: right;
    margin-bottom: 8px;
    line-height: 1.8;
}

/* Kunci posisi header agar tetap konsisten di Mobile dan Desktop */
.header-left {
    display: flex !important;
    width: 100% !important;
    justify-content: flex-start !important; 
    align-items: baseline;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
    direction: ltr !important; 
}

.arabic-group {
    display: flex;
    flex-direction: row; 
    align-items: baseline;
    gap: 10px;
}

.arabic-meta {
    font-family: Arial, sans-serif; /* Meta (Akar/Kat) tetap font standar agar mudah dibaca */
    font-size: 14px;
    color: #888;
}

/* Mengunci posisi di sebelah kiri untuk semua ukuran layar */
.header-left {
    display: flex !important;
    width: 100% !important;
    justify-content: flex-start !important; /* Memaksa posisi ke kiri */
    align-items: baseline;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
    direction: ltr !important; /* Arah kontainer dari kiri ke kanan */
}

.arabic-group {
    display: flex;
    flex-direction: row; 
    align-items: baseline;
    gap: 12px;
    white-space: nowrap;
}

.arabic {
    font-family: 'Amiri', serif; /* Menggunakan font Amiri */
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--primary-color);
    direction: rtl; /* Teks Arab tetap terbaca kanan ke kiri */
}

.arabic-meta {
    font-family: 'Scheherazade New', serif; /* Menggunakan font Scheherazade */
    font-size: 16px;
    color: #666;
}

.header-ar {
    display: flex !important;
    width: 100% !important;
    /* Mengatur urutan dari kanan ke kiri */
    flex-direction: row-reverse !important; 
    justify-content: space-between; /* Memberikan ruang antar elemen */
    align-items: baseline;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
    direction: rtl !important; /* Arah baca kanan ke kiri */
}

.arabic-group {
    display: flex;
    flex-direction: row-reverse; /* Arab di paling kanan, baru meta di kirinya */
    align-items: baseline;
    gap: 15px;
}

.arabic {
    font-family: 'Amiri', serif;
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--primary-color);
    /* Memastikan teks Arab tidak terpotong */
    line-height: 1.4;
}

.arabic-meta {
    font-family: 'Scheherazade New', serif;
    font-size: 16px;
    color: #666;
    /* Menjaga agar format [Akar] - [Kat] tidak terbalik urutan kurungnya */
    direction: ltr; 
    unicode-bidi: isolate;
}

.main-term-box {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    border-right: 4px solid var(--primary-color); /* Aksen garis di kanan */
    margin-bottom: 20px;
    text-align: right; /* Menghadap ke kanan */
    direction: rtl; /* Arah baca kanan ke kiri */
}

.arabic-term {
    font-family: 'Amiri', serif;
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.meta-term-group {
    display: flex;
    justify-content: flex-start; /* Karena direction rtl, ini akan menempel ke kanan */
    gap: 5px;
    align-items: center;
    color: #666;
    font-family: 'Scheherazade New', serif;
    font-size: 16px;
}

.meta-term {
    /* Menjaga agar isi di dalam kurung tidak terbalik urutannya */
    direction: ltr;
    display: inline-block;
}

.separator {
    margin: 0 5px;
}
.arabic-sentence {
    font-family: 'Scheherazade New', serif;
    font-size: 1.5rem;
    /* Mengubah warna teks menjadi biru */
    color: #0000FF; 
    direction: rtl;
    line-height: 1.8;
    margin-bottom: 8px;
    text-align: right;
}

/* Jika Anda ingin warna biru yang lebih lembut (biru royal) */
/* color: #4169E1; */
/* Mengatur kotak contoh kalimat (Kolom G) */
.example-box {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    /* Mengubah garis di sebelah kiri dari hijau menjadi BIRU */
    border-left: 4px solid #0000FF; 
    margin-top: 15px;
}

/* Memastikan teks Arab di dalamnya juga tetap biru untuk keselarasan */
.arabic-sentence {
    font-family: 'Scheherazade New', serif;
    font-size: 1.5rem;
    color: #0000FF; /* Warna biru */
    direction: rtl;
    line-height: 1.8;
    margin-bottom: 8px;
    text-align: right;
}
/* KHUSUS UNTUK KOLOM G */
.example-box {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    /* Mengubah garis kiri dan kanan menjadi BIRU khusus di kotak ini */
    border-left: 4px solid #0000FF; 
    border-right: 4px solid #0000FF; 
    margin-top: 15px;
}

/* Mengubah warna teks Arab khusus di dalam Kolom G menjadi BIRU */
.example-box .arabic-sentence {
    font-family: 'Scheherazade New', serif;
    font-size: 1.5rem;
    color: #0000FF; 
    direction: rtl;
    line-height: 1.8;
    margin-bottom: 8px;
    text-align: right;
}



/* Bagian lain seperti .main-term-box atau .arabic tetap pada warna aslinya */
/* Mengatur teks terjemahan di dalam Kolom G */
.indo-sentence {
    font-size: 20px !important; /* Ukuran diperbesar */
    color: #444 !important; /* Warna abu gelap agar tetap elegan */
    font-style: italic;
    text-align: right;
    line-height: 1.6;
    margin-top: 10px;
    display: block;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Pastikan box tetap rapi */
.example-box {
    padding: 20px !important;
}

