/* ===================================================================== */
/* 1. VARIABEL & PENGATURAN DASAR (TEMA LONTARA BUGIS MAROON)
/* ===================================================================== */
:root {
    --primary-color: #A91D3A; 
    --primary-hover: #8A152D;
    --secondary-color: #F9E0E3; 
    --background-color: #F8F9FA;
    --text-color: #212529;
    --border-color: #DEE2E6;
    /* [PERBAIKAN KOTAK-KOTAK] Tambahkan Noto Sans Buginese sebagai Fallback Font Utama */
    --font-latin: 'Poppins', 'Noto Sans Buginese', sans-serif; 
    --font-lontara: 'Noto Sans Buginese', serif; 
}


*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { font-family: var(--font-latin); background-color: var(--background-color); color: var(--text-color); line-height: 1.6; margin: 0; padding: 0; overflow-x: hidden; }

/* ===================================================================== */
/* 2. STRUKTUR UTAMA
/* ===================================================================== */
/* .container { max-width: 1200px; margin: 0 auto; padding: 15px; }  */
header { text-align: center; } 
header h1 { color: var(--primary-color); margin-bottom: 5px; font-weight: 600; font-size: 1.8em; } 
header p { color: #6C757D; font-size: 1em; max-width: 600px; margin: 0 auto; }
.main-layout-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
.main-content-column, .sidebar-column { display: grid; grid-template-columns: 1fr; gap: 20px; align-content: start; }

/* ===================================================================== */
/* 3. KOMPONEN KARTU (CARD)
/* ===================================================================== */
.card { background-color: #fff; padding: 25px; border-radius: 12px; box-shadow: 0 4px 25px rgba(0,0,0,0.06); border: 1px solid var(--border-color); margin-bottom: 0; }
.card h2 { margin-top: 0; color: var(--primary-color); border-bottom: 1px solid var(--border-color); padding-bottom: 10px; font-size: 1.4em; }
.card h3 { color: var(--primary-color); font-size: 1.2em; margin-bottom:10px; }

/* ===================================================================== */
/* 4. ALAT TRANSLITERASI (Poin 6: Hover/Focus Textarea)
/* ===================================================================== */
.io-container { display: grid; grid-template-columns: 1fr; gap: 20px; margin-top: 15px; } 
textarea, .output-box { width: 100%; height: 250px; padding: 15px; border: 2px solid var(--border-color); border-radius: 8px; font-size: 16px; resize: vertical; transition: all 0.2s ease; background-color: #fff;}
textarea { font-family: var(--font-latin); }

/* Poin 6: Border berubah warna saat hover/focus */
textarea:hover, .output-box:hover { border-color: var(--secondary-color); }
textarea:focus, .output-box:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 4px var(--secondary-color); }

textarea::placeholder { color: #ADB5BD; font-size: 15px; }

/* Poin 11: Pastikan font Lontara dirender dengan benar */
.output-box { overflow-y: auto; font-size: 30px; line-height: 1.8; color: var(--text-color); }
.font-lontara { font-family: var(--font-lontara) !important; font-weight: normal; } 
.output-box .word { cursor: pointer; position: relative; transition: background-color 0.2s ease; border-radius: 4px; padding: 0 2px; margin: 0 -2px; color: var(--primary-color);}
.output-box .word:hover { background-color: var(--secondary-color); }

/* ===================================================================== */
/* 5. TOGGLE SWITCH MODERN (Poin 8)
/* ===================================================================== */
.modern-toggle {
    display: flex;
    position: relative;
    background-color: #f1f3f5;
    border-radius: 8px;
    padding: 4px;
    width: 100%;
    max-width: 400px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}
.modern-toggle input[type="radio"] {
    display: none;
}
.modern-toggle label {
    flex: 1;
    text-align: center;
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #6c757d;
    cursor: pointer;
    z-index: 2;
    transition: color 0.3s ease;
    margin: 0;
}
.modern-toggle .toggle-slider {
    position: absolute;
    top: 4px;
    left: 4px;
    bottom: 4px;
    width: calc(50% - 4px);
    background-color: var(--primary-color);
    border-radius: 6px;
    z-index: 1;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.modern-toggle input[id="lontaraToLatin"]:checked ~ .toggle-slider {
    transform: translateX(100%);
}
.modern-toggle input[type="radio"]:checked + label {
    color: #ffffff;
}

/* ===================================================================== */
/* FITUR BARU: FRASE POPULER (USER ENGAGEMENT)
/* ===================================================================== */
.popular-phrases-wrapper {
    margin-top: 15px;
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    border: 1px dashed var(--border-color);
}

.phrases-header {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.phrases-header i {
    color: #f39c12; /* Warna api oranye */
}

.phrases-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.phrase-pill {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.85rem;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: var(--font-latin); /* Memastikan font seragam */
    outline: none;
}

.phrase-pill:hover {
    background: #e9ecef;
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(169, 29, 58, 0.1);
}

.phrase-pill:active {
    transform: translateY(0);
}

/* ===================================================================== */
/* 6. TOOLTIP (Poin 1: Diperbaiki agar tidak timbul tenggelam)
/* ===================================================================== */
.word-tooltip { 
    position: absolute; 
    background: #FFFFFF;
    color: var(--text-color);
    padding: 12px 16px; 
    border-radius: 12px;
    font-size: 14px; 
    font-family: var(--font-latin); 
    z-index: 10000; 
    pointer-events: none; /* KUNCI: Membuat mouse menembus tooltip */
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0,0,0,0.05);
    max-width: 350px;
    opacity: 0;
    transform: translateY(5px);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}
.word-tooltip.tooltip-visible {
    opacity: 1;
    transform: translateY(0);
}
.tooltip-title { font-weight: 600; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border-color); color:var(--primary-color);}
.word-tooltip .tooltip-analysis { display: flex; flex-wrap: wrap; gap: 6px; }
.word-tooltip .tooltip-item { display: inline-flex; flex-direction: column; padding: 4px 8px; border-radius: 6px; background: var(--background-color); text-align: center; border: 1px solid var(--border-color); }
.word-tooltip .tooltip-item .lontara { font-size: 1.4em; color: var(--primary-color); line-height: 1;}
.word-tooltip .tooltip-item .latin { font-size: 0.75em; color: #6C757D; font-weight:600; margin-top:3px;}

/* ===================================================================== */
/* 7. SMART TOAST (Poin 2: Pojok Kanan Bawah)
/* ===================================================================== */
#kd-smart-toast-container {
    position: fixed;
    bottom: 25px; /* Pindah ke bawah */
    right: 25px;  /* Pindah ke kanan */
    z-index: 99999; /* Z-index sangat tinggi agar tidak tenggelam */
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.kd-toast {
    display: flex;
    align-items: center;
    background-color: #ffffff;
    border-left: 4px solid var(--primary-color);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    padding: 12px 20px;
    border-radius: 6px;
    gap: 12px;
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    font-family: var(--font-latin);
}
.kd-toast.show {
    opacity: 1;
    transform: translateX(0);
}
.kd-toast-success { border-left-color: #28a745; }
.kd-toast-success .kd-toast-icon i { color: #28a745; font-size: 20px;}
.kd-toast-msg { color: #333; font-weight: 500; font-size: 14px;}

/* ===================================================================== */
/* 8. KONTEN & LIST
/* ===================================================================== */
/* Poin 4: Rata kiri untuk Mode Analisis */
.analysis-container { margin-top: 0; padding: 15px; background-color: #F8F9FA; border-radius: 8px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-start; }
.analysis-item { display: inline-flex; flex-direction: column; padding: 6px 12px; border: 1px solid #ddd; border-radius: 6px; background: white; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.02);}
.analysis-item .lontara { font-size: 1.6em; color: var(--primary-color); line-height: 1.2;} 
.analysis-item .latin { font-size: 0.85em; color: #444; font-weight: 600; margin-top:2px;}
.analysis-item .type { font-size: 0.7em; color: #888; font-style: italic; }

/* Poin 10: Perbaikan border-radius pada Example Item */
.example-list { display: flex; flex-direction: column; gap: 15px; }
.example-item { 
    background-color: #f8f9fa; 
    border-left: 4px solid var(--primary-color); 
    padding: 15px 20px; 
    border-radius: 8px; 
    cursor: pointer; 
    transition: transform 0.2s ease, box-shadow 0.2s ease; 
    overflow: hidden; /* Mencegah border-left keluar dari radius */
}
.example-item:hover { background-color: var(--secondary-color); transform: translateY(-3px); box-shadow: 0 6px 15px rgba(0,0,0,0.06); border-left-color: var(--primary-hover);}

/* Poin 5: Label Petuah Bugis (Pappaseng) */
/* .ex-row {  */
    /* display: flex;  */
    /* align-items: flex-start; /* Ubah ke flex-start agar sejajar jika teks panjang */ */
    /* margin-bottom: 8px;  */
    /* gap: 10px; */
/* } */
/* .ex-label {  */
    /* font-size: 0.85em;  */
    /* color: var(--primary-color);  */
    /* font-weight: 600;  */
    /* width: 65px; /* Lebar tetap untuk membuat sejajar */ */
    /* flex-shrink: 0;  */
    /* letter-spacing: 0.5px; */
    /* position: relative; */
    /* padding-top: 4px; /* Menyelaraskan teks label dengan konten di sebelahnya */ */
/* } */
/* Tambahkan titik dua secara dinamis lewat CSS agar selalu sejajar di ujung kanan label */
.ex-label::after {
    content: ":";
    position: absolute;
    right: 0;
}
/* .ex-content { */
    /* flex-grow: 1; /* Konten mengambil sisa ruang */ */
/* } */
.ex-lontara { 
    font-size: 1.8em; 
    color: var(--text-color); 
    line-height: 1.2;
}
.ex-latin { 
    font-weight: 600; 
    color: #333; 
    font-size: 1em; 
    line-height: 1.4;
    padding-top: 2px;
}
.ex-arti { 
    font-style: italic; 
    color: #6c757d; 
    font-size: 0.95em; 
    line-height: 1.4;
    padding-top: 2px;
}

/* ===================================================================== */
/* SLIDER PETUAH BUGIS (PAPPASENG) + ANIMASI
/* ===================================================================== */
#example-content-wrapper {
    position: relative;
    min-height: 180px;
    overflow: hidden;
}

.example-slide {
    display: none;
    cursor: pointer;
    animation: fadeInSlide 0.3s ease-in-out;
}

.example-slide.active {
    display: block;
}

/* Desain Kotak Detail Contoh */
.example-detail-card {
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid var(--border-color);
    transition: all 0.2s ease;
}

/* Efek Hover pada Kotak */
.example-slide:hover .example-detail-card {
    background-color: var(--secondary-color);
    border-left: 4px solid var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

/* Struktur Baris (Label & Konten) - Kiri Kanan Sejajar */
.ex-row {
    display: flex !important;
    flex-direction: row !important; 
    flex-wrap: nowrap !important; 
    align-items: flex-start;
    margin-bottom: 10px;
    border-bottom: 1px dashed #e9ecef;
    padding-bottom: 10px;
    gap: 15px; 
}

.ex-row:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Desain Label (Kiri) agar titik dua (:) rata sempurna */
.ex-label {
    width: 65px !important; /* Kunci lebarnya */
    flex-shrink: 0 !important; /* Larang mengecil */
    font-size: 0.85em;
    font-weight: 600;
    color: var(--primary-color); 
    position: relative;
    padding-top: 2px;
    text-transform: uppercase;
}
.ex-label::after {
    content: ":";
    position: absolute;
    right: 0;
}

/* Desain Konten (Kanan) */
.ex-content {
    flex: 1 1 auto !important; 
    min-width: 0 !important; 
    word-break: break-word; 
    text-align: left;
}

/* Tipografi Konten Lontara */
.ex-lontara-text {
    font-size: 26px;
    color: var(--text-color);
    line-height: 1.2;
    display: block;
}

.ex-latin-text {
    font-weight: 600;
    color: #333;
    display: block;
    font-size: 15px;
    padding-top: 2px;
}

.ex-arti-text {
    font-size: 0.9em;
    color: #6C757D;
    font-style: italic;
    display: block;
    padding-top: 2px;
}

/* CTA & Animasi Denyut (Pulse) Merah Maroon */
.ex-cta-text {
    margin-top: 15px;
    text-align: center;
    font-size: 0.85em;
    color: #ffffff;
    background-color: var(--primary-color);
    padding: 8px 12px;
    border-radius: 20px;
    font-weight: 600;
    display: block;
    width: 100%;
    box-sizing: border-box;
}

.pulse-animation {
    animation: pulseBtnLontara 2s infinite;
}

/* Keyframes Animasi Slider & Pulse */
@keyframes fadeInSlide {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulseBtnLontara {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(169, 29, 58, 0.5); }
    50% { transform: scale(1.02); box-shadow: 0 0 0 8px rgba(169, 29, 58, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(169, 29, 58, 0); }
}

/* Glosarium Statis (SEO) */
.glossary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 12px; text-align: center; }
.glossary-item { background: #fff; padding: 15px 10px; border-radius: 8px; border: 1px solid var(--border-color); display:flex; flex-direction:column; box-shadow: 0 2px 5px rgba(0,0,0,0.02);}
.g-lontara { font-size: 2.2em; line-height: 1.2; color: var(--primary-color); margin-bottom:5px;}
.g-latin { font-size:0.85em; font-weight:600; color:#555;}

/* FAQ CSS */
.faq-item { border-bottom: 1px solid var(--border-color); } 
.faq-question { padding: 15px 0; font-weight: 600; cursor: pointer; position: relative; color:var(--primary-color);} 
.faq-answer { color: #555; padding-bottom: 15px; } 

/* ===================================================================== */
/* 9. KEYBOARD VIRTUAL
/* ===================================================================== */
.tabs { display: flex; border-bottom: 1px solid var(--border-color); margin-bottom: 0; overflow-x: auto; }
.tab-button { padding: 10px 15px; cursor: pointer; border: none; background-color: transparent; border-bottom: 3px solid transparent; font-size: 0.9em; color: #6C757D; white-space: nowrap; font-weight: 600; transition: color 0.2s;}
.tab-button.active { border-bottom: 3px solid var(--primary-color); color: var(--primary-color); }
.tab-button:hover:not(.active) { color:var(--primary-hover); }
.tab-content { display: none; } 
.tab-content.active { display: block; padding-top: 15px; }
.keyboard-row { display: flex; justify-content: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.key { background-color: #fff; border: 1px solid #ccc; border-radius: 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60px; gap: 4px; padding: 5px; min-width: 45px; flex-grow: 1; transition: all 0.1s;}
.key:active { transform: scale(0.95); }
.key:hover { background-color: var(--secondary-color); border-color: var(--primary-color); box-shadow: 0 2px 5px rgba(169, 29, 58, 0.1);}
.key .lontara { font-family: var(--font-lontara); font-size: 28px; line-height: 1; color: var(--primary-color); }
.key .latin { font-family: var(--font-latin); font-size: 11px; color: #6C757D; font-weight:500; text-transform:uppercase;}

/* ===================================================================== */
/* 10. TOOLS & BUTTONS
/* ===================================================================== */
.control-deck { background-color: #FFFFFF; border: 1px solid var(--border-color); border-radius: 12px; padding: 20px; margin-top: 25px; }
.deck-title { margin-top: 0; margin-bottom: 15px; font-size: 1.1em; color: #555; border-bottom: 1px solid var(--border-color); padding-bottom: 10px;}
.features-cohesive { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.btn-cohesive { display:flex; align-items:center; justify-content:center; background-color: #f8f9fa; border: 1px solid #e9ecef; border-radius: 8px; padding: 12px; cursor: pointer; color: #495057; font-size: 14px; transition: all 0.2s; text-align: center; font-weight: 600;}
.btn-cohesive:hover { border-color: var(--primary-color); color: var(--primary-color); background-color: var(--secondary-color); }

.nav-circle-btn { background: #fff; border: 1px solid #ccc; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; color: #555; transition: all 0.2s; display:flex; align-items:center; justify-content:center;}
.nav-circle-btn:hover { background: var(--primary-color); color: white; border-color: var(--primary-color); }

/* ===================================================================== */
/* 11. RESPONSIVE BREAKPOINTS (Poin 12)
/* ===================================================================== */
/* ===================================================================== */
/* 11. RESPONSIVE BREAKPOINTS (Poin 12 - Anti Overflow X)
/* ===================================================================== */
@media (max-width: 480px) {
    /* 1. Perbaikan Body & Container agar tidak tumpah */
    body { overflow-x: hidden; }
    .container { padding: 0 10px; overflow-x: hidden; }
    .card { padding: 15px; overflow-x: hidden; } /* Card tidak boleh melebar */
    
    header h1 { font-size: 1.5em; }
    
    /* 2. Perbaikan Tools & Pengaturan (Button Grid) */
    .features-cohesive { 
        grid-template-columns: 1fr 1fr; /* Di layar sangat kecil (320px-400px), jadikan 1 kolom saja */
        gap: 8px;
    }
    
    /* 3. Perbaikan Segmented Control (Toggle Arah Konversi) */
    .modern-toggle {
        flex-direction: column; /* Ubah bentuk toggle menjadi vertikal atas-bawah */
        width: 100%;
    }
    .modern-toggle label { 
        padding: 8px; 
        font-size: 13px; 
        width: 100%;
    }
    .modern-toggle .toggle-slider {
        width: calc(100% - 8px);
        height: calc(50% - 4px);
        transition: transform 0.3s ease;
    }
    /* Jika radio kedua dipilih, geser slider ke BAWAH (bukan ke samping) */
    .modern-toggle input[id="lontaraToLatin"]:checked ~ .toggle-slider {
        transform: translateY(100%);
    }

    /* 4. Perbaikan Virtual Keyboard agar muat */
    .keyboard-row { gap: 4px; }
    .key { 
        min-width: 0; /* Hapus min-width yang memakan tempat */
        padding: 5px 2px; /* Perkecil padding */
        min-height: 45px; 
    }
    .key .lontara { font-size: 20px; }
    .key .latin { font-size: 8px; }
    
    /* 5. Perbaikan Output Text dan Area Analisis Edukatif */
    .output-box { font-size: 24px; height: 180px; }
    textarea { height: 180px; }
    
    .analysis-container { flex-direction: column; gap: 5px; } /* Susun vertikal jika perlu */
    .analysis-item { width: 100%; flex-direction: row; justify-content: space-between; align-items: center; padding: 8px; }

    /* 6. Pappaseng (Slider) Label Mobile Stacked */
    /* .ex-row {  */
        /* flex-direction: column !important; /* Paksa vertikal di HP */ */
        /* align-items: flex-start !important; */
        /* gap: 2px !important;  */
        /* margin-bottom: 12px; */
    /* } */
    /* .ex-label {  */
        /* width: 100% !important; /* Label mengambil lebar penuh */ */
        /* border-bottom: 1px solid #ddd;  */
        /* padding-bottom: 2px; */
    /* } */
    /* .ex-label::after { */
        /* display: none; /* Hilangkan titik dua (:) saat di HP karena sudah turun baris */ */
    /* } */
    
    /* 7. Perbaikan Slider Kaidah Lontara (Tip Comparison) */
    .tip-comparison {
        grid-template-columns: 1fr; /* Jadikan 1 kolom Atas (Benar) - Bawah (Salah) */
        gap: 15px;
    }
}
/* Penyesuaian Sedang (Tablet Kecil / Landscape HP) */
@media (min-width: 481px) and (max-width: 767px) {
    .features-cohesive { grid-template-columns: 1fr 1fr; }
    .modern-toggle { flex-direction: row; }
    .modern-toggle .toggle-slider { width: calc(50% - 4px); height: calc(100% - 8px); }
    .modern-toggle input[id="lontaraToLatin"]:checked ~ .toggle-slider { transform: translateX(100%); }
}

@media (min-width: 768px) {
    .io-container { grid-template-columns: 1fr 1fr; }
    /* Kembalikan toggle ke format asli (menyamping) */
    .modern-toggle { flex-direction: row; }
    .modern-toggle .toggle-slider { width: calc(50% - 4px); height: calc(100% - 8px); }
    .modern-toggle input[id="lontaraToLatin"]:checked ~ .toggle-slider { transform: translateX(100%); }
}

@media (min-width: 1024px) {
    .main-layout-grid { grid-template-columns: 2fr 1fr; }
    .output-box, textarea { height: 280px; }
}
