/* =========================================================
   Motor Listrik Entry Level — style.css
   Tema hijau elektrik, mobile-first, zero dependencies
   ========================================================= */

/* ── Variables ──────────────────────────────────────────── */
:root {
    --green-700: #15803d;
    --green-600: #16a34a;
    --green-500: #22c55e;
    --green-200: #bbf7d0;
    --green-100: #dcfce7;
    --green-50: #f0fdf4;

    --amber-500: #f59e0b;
    --amber-100: #fef3c7;

    --red-600: #dc2626;

    --gray-900: #111827;
    --gray-700: #374151;
    --gray-500: #6b7280;
    --gray-400: #9ca3af;
    --gray-300: #d1d5db;
    --gray-200: #e5e7eb;
    --gray-100: #f3f4f6;
    --gray-50: #f9fafb;
    --white: #ffffff;

    --text: var(--gray-900);
    --muted: var(--gray-500);
    --border: var(--gray-200);
    --bg: var(--gray-50);

    --radius: 10px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md:
        0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);

    --font:
        "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont,
        "Helvetica Neue", Arial, sans-serif;
}

/* ── Reset ───────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

/* Fix: prevent CSS display rules from overriding the HTML [hidden] attribute */
[hidden] {
    display: none !important;
}

body {
    font-family: var(--font);
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    padding: 1.5rem 0 2.5rem;
}

a {
    color: var(--green-600);
}

/* ── Layout ──────────────────────────────────────────────── */
.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ── HERO ────────────────────────────────────────────────── */
.hero {
    background: linear-gradient(135deg, #064e3b 0%, #15803d 55%, #34d399 100%);
    color: var(--white);
    padding: 2.25rem 0 2rem;
}

.hero-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
}

.hero-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.hero-icon {
    font-size: 3.5rem;
    line-height: 1;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

h1 {
    font-size: clamp(1.35rem, 4vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.5px;
}

.hero-sub {
    font-size: 0.88rem;
    opacity: 0.85;
    margin-top: 0.2rem;
    line-height: 1.5;
}

/* Hero stat chips */
.hero-stats {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.stat-chip {
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    text-align: center;
    min-width: 88px;
}

.stat-val {
    display: block;
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1.1;
}

.stat-lbl {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.85;
    margin-top: 0.15rem;
}

/* ── FILTER PANEL ────────────────────────────────────────── */
.filter-panel {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem 0.9rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.filter-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
    gap: 0.7rem 1rem;
    margin-bottom: 0.8rem;
}

/* filter labels */
.filter-group label:not(.check-label) {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.3rem;
}

/* inputs & selects */
.filter-group input[type="search"],
.filter-group select {
    width: 100%;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 0.9rem;
    font-family: var(--font);
    background: var(--white);
    color: var(--text);
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
}

.filter-group input[type="search"]:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--green-600);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

/* checkbox */
.filter-check {
    display: flex;
    align-items: flex-end;
    padding-bottom: 0.05rem;
}

.check-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    user-select: none;
}

.check-label input[type="checkbox"] {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--green-600);
    flex-shrink: 0;
}

/* meta bar */
.filter-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.7rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.4rem;
}

.count-label {
    font-size: 0.85rem;
    color: var(--muted);
}

.btn-ghost {
    background: none;
    border: 1px solid var(--border);
    padding: 0.28rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--muted);
    font-family: var(--font);
    transition:
        border-color 0.15s,
        color 0.15s;
}

.btn-ghost:hover {
    border-color: var(--green-600);
    color: var(--green-600);
}

/* ── TABLE CARD ───────────────────────────────────────────── */
.table-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.table-scroller {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

/* ── Table head ── */
thead th {
    background: var(--gray-100);
    padding: 0.65rem 0.9rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

thead th.col-num {
    text-align: right;
}
thead th.col-ctr {
    text-align: center;
}

/* sortable headers */
thead th.col-sort {
    cursor: pointer;
    user-select: none;
}

thead th.col-sort:hover {
    background: #e4e5e8;
    color: var(--gray-700);
}

/* sort indicator: the <b> inside each sortable th */
thead th.col-sort b {
    font-weight: normal;
    font-size: 0.75rem;
    margin-left: 0.12rem;
    opacity: 0.35;
}

thead th.col-sort b::after {
    content: "⇅";
}
thead th.col-sort.sort-asc b::after {
    content: "↑";
    opacity: 1;
}
thead th.col-sort.sort-desc b::after {
    content: "↓";
    opacity: 1;
}

thead th.sort-asc,
thead th.sort-desc {
    background: var(--green-100);
    color: var(--green-700);
}

thead th.sort-asc b,
thead th.sort-desc b {
    opacity: 1;
}

/* ── Table body ── */
tbody tr {
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: background 0.1s;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--green-50);
}
tbody tr:focus {
    outline: 2px solid var(--green-500);
    outline-offset: -2px;
    background: var(--green-50);
}

tbody td {
    padding: 0.68rem 0.9rem;
    vertical-align: middle;
}

/* Specific cells */
.td-brand {
    /* font-weight moved to .brand-name-text to not affect the thumbnail img */
}

.brand-thumb-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
}

.motor-thumb-sm {
    display: block;
    width: 52px;
    height: 39px;
    border-radius: 5px;
    object-fit: cover;
    flex-shrink: 0;
}

.brand-name-text {
    font-weight: 700;
    display: block;
    line-height: 1.2;
}
.td-model {
    color: var(--gray-700);
}

.td-price {
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

/* price colour tiers */
.p-low {
    color: var(--green-700);
}
.p-mid {
    color: #b45309;
} /* amber-700 */
.p-high {
    color: var(--red-600);
}

.td-num {
    text-align: right;
    white-space: nowrap;
}
.td-ctr {
    text-align: center;
}

/* Subsidi badges */
.badge-yes,
.badge-no {
    display: inline-flex;
    align-items: center;
    gap: 0.22rem;
    padding: 0.18rem 0.5rem;
    border-radius: 20px;
    font-size: 0.71rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.badge-yes {
    background: var(--amber-100);
    color: #92400e;
    border: 1px solid #fcd34d;
}

.badge-no {
    background: var(--gray-100);
    color: var(--gray-400);
    border: 1px solid var(--gray-200);
}

/* Range mini progress bar */
.range-wrap {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.45rem;
}

.range-track {
    width: 52px;
    height: 5px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}

.range-fill {
    height: 100%;
    background: var(--green-500);
    border-radius: 3px;
    transition: width 0.35s ease;
}

/* No-results state */
.no-results {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--muted);
}

.no-results-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.no-results p {
    font-size: 0.9rem;
}

/* Table footnote */
.table-foot {
    padding: 0.65rem 1rem;
    font-size: 0.78rem;
    color: var(--muted);
    background: var(--gray-50);
    border-top: 1px solid var(--border);
    line-height: 1.65;
}

/* ── Responsive: hide columns ────────────────────────────── */

/* ≤ 900 px  →  hide Baterai (9) & Garansi (10) */
@media (max-width: 900px) {
    thead th:nth-child(9),
    thead th:nth-child(10),
    tbody td:nth-child(9),
    tbody td:nth-child(10) {
        display: none;
    }
}

/* ≤ 640 px  →  also hide Subsidi (5) & Daya Motor (8) */
@media (max-width: 640px) {
    thead th:nth-child(5),
    tbody td:nth-child(5),
    thead th:nth-child(8),
    tbody td:nth-child(8) {
        display: none;
    }

    .hero-icon {
        font-size: 2.5rem;
    }
    h1 {
        font-size: 1.3rem;
    }
    .hero-sub {
        font-size: 0.8rem;
    }
    .stat-chip {
        min-width: 72px;
    }
}

/* ── INFO CARDS ──────────────────────────────────────────── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.25rem;
    box-shadow: var(--shadow-sm);
}

.card h2 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.7rem;
    color: var(--text);
}

.card p,
.card li {
    font-size: 0.875rem;
    color: var(--muted);
    line-height: 1.65;
}

.card ul {
    padding-left: 1.1rem;
}

.card li {
    margin-bottom: 0.35rem;
}

/* ── FOOTER ──────────────────────────────────────────────── */
.site-footer {
    background: var(--gray-900);
    color: var(--gray-500);
    padding: 1.5rem 0;
    text-align: center;
    margin-top: auto;
}

.site-footer p {
    font-size: 0.8rem;
    line-height: 1.75;
}

.site-footer a {
    color: var(--green-500);
    text-decoration: none;
}
.site-footer a:hover {
    text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════
   COMPARISON FEATURE
   ═══════════════════════════════════════════════════════ */

/* ── Compare checkbox column ── */
.col-check {
    width: 40px;
    text-align: center;
    padding: 0;
}
.td-check {
    width: 40px;
    text-align: center;
    padding: 0;
}

.compare-check {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--green-600);
    cursor: pointer;
}

/* row selected highlight */
tbody tr.row-selected {
    background: var(--green-50);
    box-shadow: inset 3px 0 0 var(--green-500);
}

/* ── Compare Bar (fixed bottom) ── */
.compare-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--gray-900);
    color: var(--white);
    z-index: 100;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
    animation: slideUp 0.25s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.compare-bar.shake {
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }
    20% {
        transform: translateX(-6px);
    }
    40% {
        transform: translateX(6px);
    }
    60% {
        transform: translateX(-4px);
    }
    80% {
        transform: translateX(4px);
    }
}

.compare-bar-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    flex-wrap: wrap;
}

.compare-bar-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-400);
    white-space: nowrap;
}

.compare-chips {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 1;
}

.compare-chip {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 0.22rem 0.7rem;
    font-size: 0.8rem;
    white-space: nowrap;
}

.compare-chip em {
    font-style: normal;
    opacity: 0.75;
}

.compare-bar-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-compare {
    background: var(--green-600);
    color: var(--white);
    border: none;
    padding: 0.45rem 1.1rem;
    border-radius: 7px;
    font-size: 0.88rem;
    font-weight: 700;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.btn-compare:hover:not(:disabled) {
    background: var(--green-700);
}
.btn-compare:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-ghost-white {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--gray-400);
    padding: 0.4rem 0.85rem;
    border-radius: 7px;
    font-size: 0.82rem;
    font-family: var(--font);
    cursor: pointer;
    transition:
        border-color 0.15s,
        color 0.15s;
    white-space: nowrap;
}

.btn-ghost-white:hover {
    border-color: var(--white);
    color: var(--white);
}

/* ── Compare Modal ── */
.compare-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem 5rem;
    overflow-y: auto;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.compare-modal {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 960px;
    animation: scaleIn 0.2s ease;
    overflow: hidden;
}

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.compare-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--gray-50);
}

.compare-modal-header h2 {
    font-size: 1rem;
    font-weight: 700;
}

.compare-close {
    background: none;
    border: 1px solid var(--border);
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    font-family: var(--font);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background 0.1s,
        color 0.1s;
}

.compare-close:hover {
    background: var(--gray-200);
    color: var(--text);
}

.compare-modal-body {
    overflow-x: auto;
    padding: 0 0 1rem;
}

/* ── Comparison Table ── */
.cmp-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.cmp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.cmp-table thead th {
    background: var(--green-100);
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--green-200);
    font-size: 0.75rem;
    text-transform: none;
    color: var(--text);
}

.cmp-spec-th {
    background: var(--gray-100) !important;
    color: var(--muted) !important;
    text-align: left !important;
    font-size: 0.72rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    font-weight: 700 !important;
    white-space: nowrap;
    width: 140px;
    min-width: 120px;
}

.cmp-motor-th {
    text-align: center;
    min-width: 170px;
    padding: 0.9rem 0.75rem 0.7rem;
    vertical-align: bottom;
}

.motor-thumb-lg {
    display: block;
    width: 120px;
    height: 85px;
    border-radius: 8px;
    margin: 0 auto 0.6rem;
    object-fit: cover;
}

.cmp-brand {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
}

.cmp-model {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 0.1rem;
}

.cmp-table tbody tr {
    border-bottom: 1px solid var(--gray-100);
}

.cmp-table tbody tr:last-child {
    border-bottom: none;
}

.cmp-table tbody td {
    padding: 0.65rem 1rem;
    text-align: center;
    vertical-align: middle;
}

.cmp-table tbody th.cmp-spec-th {
    padding: 0.65rem 1rem;
}

/* Best value highlight */
.cmp-best {
    background: var(--green-50);
    font-weight: 700;
    color: var(--green-700);
    position: relative;
}

.cmp-best::after {
    content: "★";
    font-size: 0.65rem;
    position: absolute;
    top: 0.25rem;
    right: 0.3rem;
    color: var(--green-500);
}

/* Modal footnote */
.cmp-note {
    padding: 0.65rem 1.25rem;
    font-size: 0.78rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
    background: var(--gray-50);
    line-height: 1.6;
}

.cmp-best-legend {
    color: var(--green-600);
}

/* Website button inside modal */
.btn-website {
    display: inline-block;
    background: var(--green-600);
    color: var(--white);
    text-decoration: none;
    padding: 0.35rem 0.85rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    transition: background 0.15s;
    white-space: nowrap;
}

.btn-website:hover {
    background: var(--green-700);
    color: var(--white);
}

/* ── Battery type badges ── */
.batt-badge {
    display: inline-block;
    padding: 0.18rem 0.5rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
}

.batt-lfp {
    background: #dcfce7;
    color: #14532d;
    border: 1px solid #86efac;
}
.batt-li {
    background: #dbeafe;
    color: #1e3a8a;
    border: 1px solid #93c5fd;
}
.batt-sla {
    background: #fef9c3;
    color: #713f12;
    border: 1px solid #fde047;
}
.batt-mixed {
    background: #fef3c7;
    color: #78350f;
    border: 1px solid #fcd34d;
}

/* ── Dealer network badges ── */
.dealer-badge {
    display: inline-block;
    padding: 0.18rem 0.5rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
}

.dealer-luas {
    background: #dcfce7;
    color: #14532d;
    border: 1px solid #86efac;
}
.dealer-sedang {
    background: #fef9c3;
    color: #713f12;
    border: 1px solid #fde047;
}
.dealer-terbatas {
    background: #fee2e2;
    color: #7f1d1d;
    border: 1px solid #fca5a5;
}

/* ── Body scroll lock when modal open ── */
body.modal-open {
    overflow: hidden;
}

/* ── Extra bottom padding when compare bar is visible ── */
body.compare-active main {
    padding-bottom: 5rem;
}
