/* Global Variables & Theme Colors */
:root {
    --bg-main: #f8f9fa;
    --bg-card: #ffffff;
    --bg-header: #1e1e2e;
    --text-main: #2d3748;
    --text-muted: #718096;
    --accent: #6c5ce7;
    --accent-light: #e0d7ff;
    --border-color: #e2e8f0;
    --success: #2ed573;
    --danger: #ff4757;
    --nav-bg: #ffffff;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

body.dark-mode {
    --bg-main: #121214;
    --bg-card: #1e1e24;
    --bg-header: #121214;
    --text-main: #e2e8f0;
    --text-muted: #a0aec0;
    --accent: #a29bfe;
    --accent-light: #2d2a4a;
    --border-color: #2d3748;
    --nav-bg: #1e1e24;
    --shadow: 0 4px 12px rgba(0,0,0,0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    transition: background-color 0.3s, color 0.3s;
    padding-bottom: 70px; /* Space for bottom navigation */
}

.text-accent { color: var(--accent); }

/* Header Layout */
.app-header {
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 15px 20px;
}
.header-container {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.app-header h1 {
    font-size: 1.3rem;
    font-weight: 700;
}

/* Icons and Main Layout Buttons */
.btn-icon {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.2rem;
    cursor: pointer;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px 15px;
}

/* Views Logic */
.app-view {
    display: none;
}
.app-view.active {
    display: block;
    animation: fadeIn 0.25s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Main Menu / Grid Setup */
.section-header {
    margin-bottom: 20px;
}
.section-header h2 {
    font-size: 1.4rem;
}
.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

.search-bar-container {
    position: relative;
    margin-bottom: 20px;
}
.search-bar-container input {
    width: 100%;
    padding: 12px 15px 12px 40px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
}
.search-bar-container .search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}

/* Menu Cards */
.bab-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}
.bab-card:active {
    transform: scale(0.97);
}
.card-number {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent);
}
.progress-bar-container {
    background-color: var(--border-color);
    height: 6px;
    border-radius: 3px;
    margin-top: 10px;
    overflow: hidden;
}
.progress-fill {
    background-color: var(--success);
    height: 100%;
    width: 0%;
    transition: width 0.3s;
}
.progress-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

/* Detail Bab & Navigation */
.view-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.btn-back {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
}
.mode-progress {
    background-color: var(--accent-light);
    color: var(--text-main);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Study Section Shortcuts */
.study-modes-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
}
.study-modes-container h3 {
    font-size: 1rem;
    margin-bottom: 10px;
}
.study-buttons {
    display: flex;
    gap: 8px;
}
.btn-study {
    flex: 1;
    padding: 10px 5px;
    border: none;
    border-radius: 8px;
    background-color: var(--accent-light);
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    text-align: center;
}

/* Table Style */
.table-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.kotoba-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}
.kotoba-table th, .kotoba-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
}
.kotoba-table th {
    background-color: var(--accent-light);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.kotoba-table tr:last-child td {
    border-bottom: none;
}
.jp-text {
    font-size: 1.1rem;
    font-weight: 600;
}
.romaji-text {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.btn-fav-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
}
.btn-fav-toggle.active {
    color: #ffb86c;
}

/* Flashcard Styles */
.flashcard-wrapper {
    perspective: 1000px;
    margin: 40px auto;
    width: 100%;
    max-width: 320px;
    height: 380px;
}
.flashcard {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.4s ease;
    cursor: pointer;
}
.flashcard.flipped {
    transform: rotateY(180deg);
}
.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 30px;
    gap: 20px;
    box-shadow: var(--shadow);
    border: 2px solid var(--border-color);
    background-color: var(--bg-card);
}
.card-back {
    transform: rotateY(180deg);
    border-color: var(--accent);
}
.card-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
}
.card-content-text {
    font-size: 2.4rem;
    font-weight: bold;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    width: 100%;
    line-height: 1.4;
}
.card-content-sub {
    font-size: 2rem;
    color: var(--accent);
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    width: 100%;
    line-height: 1.5;
    font-weight: 600;
}
.card-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}
.flashcard-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
}
.btn-action {
    padding: 12px 24px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-weight: bold;
    cursor: pointer;
}
.btn-action i { font-size: 1.2rem; }
.btn-priority {
    background-color: var(--accent-light);
    color: var(--text-main);
    border: none;
}

/* Quiz Design */
.quiz-container, .tebak-container {
    background-color: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}
.quiz-question-box {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}
.question-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.tebak-hint-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.btn-option {
    width: 100%;
    padding: 15px;
    text-align: left;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-main);
    color: var(--text-main);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-option:active { transform: scale(0.99); }
.btn-option.correct {
    background-color: var(--success);
    color: white;
    border-color: var(--success);
}
.btn-option.wrong {
    background-color: var(--danger);
    color: white;
    border-color: var(--danger);
}

.tebak-input-wrapper {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.tebak-input-wrapper input {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-main);
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
}
.btn-primary {
    padding: 12px 20px;
    background-color: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
}
.btn-primary:width-100 { width: 100%; }

.quiz-feedback {
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    margin: 15px 0;
}
.quiz-feedback.correct { background-color: rgba(46, 213, 115, 0.2); color: var(--success); }
.quiz-feedback.wrong { background-color: rgba(255, 71, 87, 0.2); color: var(--danger); }
.hidden { display: none !important; }

/* Favorites View Msg */
.empty-msg {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: var(--nav-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
}
.nav-item {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    flex: 1;
    padding: 8px 0;
}
.nav-item i {
    font-size: 1.2rem;
}
.nav-item.active {
    color: var(--accent);
}

/* --- FITUR LATIHAN KALIMAT --- */
.scramble-word { padding: 12px 18px; font-size: 1.1rem; background-color: var(--accent); color: white; border-radius: 8px; cursor: pointer; user-select: none; box-shadow: var(--shadow); transition: transform 0.2s; }
.scramble-word:active { transform: scale(0.95); }
.scramble-word.used { background-color: var(--border-color); color: var(--text-muted); cursor: not-allowed; opacity: 0.5; }
