/* AgroBot Styling - PHP & XAMPP Modern Theme */
:root {
    --primary: #15803d;
    --primary-dark: #14532d;
    --primary-light: #22c55e;
    --accent: #ca8a04;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

body {
    background: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: #ffffff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 44px;
    height: 44px;
    background: #dcfce7;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    border-radius: 10px;
}

.brand-text h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-dark);
}

.brand-text span {
    font-size: 12px;
    color: var(--text-muted);
}

.nav-section {
    margin-bottom: 24px;
}

.nav-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-left: 8px;
}

.nav-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-main);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: #f1f5f9;
}

.nav-btn.active {
    background: #dcfce7;
    color: var(--primary-dark);
    font-weight: 600;
}

.system-status {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
}

.status-info {
    display: flex;
    flex-direction: column;
}

.status-label {
    font-size: 12px;
    font-weight: 600;
}

.status-sub {
    font-size: 10px;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #f8fafc;
}

.top-header {
    background: #ffffff;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-title h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-dark);
}

.header-title p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.btn-action {
    background: #ffffff;
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-action:hover {
    background: #f1f5f9;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

/* Chat Area */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
}

.bot-message {
    align-self: flex-start;
}

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.bot-avatar {
    background: #dcfce7;
    color: var(--primary);
}

.user-avatar {
    background: #0284c7;
    color: #ffffff;
}

.bubble {
    background: #ffffff;
    padding: 14px 18px;
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    font-size: 14.5px;
    line-height: 1.6;
}

.user-message .bubble {
    background: #15803d;
    color: #ffffff;
    border: none;
}

.bubble ul, .bubble ol {
    margin: 8px 0 8px 20px;
}

.bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
}

.bubble th, .bubble td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    font-size: 13px;
}

.bubble th {
    background: #f1f5f9;
}

/* Quick Prompts */
.quick-prompts {
    padding: 8px 24px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

.chip {
    background: #ffffff;
    border: 1px solid var(--border);
    padding: 7px 12px;
    border-radius: 20px;
    font-size: 12.5px;
    color: var(--primary-dark);
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.chip:hover {
    background: #dcfce7;
    border-color: #86efac;
}

/* Input Area */
.input-area {
    padding: 16px 24px 20px;
    background: #ffffff;
    border-top: 1px solid var(--border);
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px 12px;
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-size: 14px;
    max-height: 120px;
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.send-btn:hover {
    background: var(--primary-dark);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-dialog {
    background: #ffffff;
    width: 90%;
    max-width: 720px;
    max-height: 85vh;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 16px;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* Table */
.table-responsive {
    overflow-x: auto;
}

.table-data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.table-data th, .table-data td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.table-data th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11.5px;
    font-weight: 600;
}

.badge-naik { background: #fee2e2; color: #dc2626; }
.badge-turun { background: #dcfce7; color: #16a34a; }
.badge-stabil { background: #f1f5f9; color: #475569; }

/* Form Calculator */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.form-group input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.res-card {
    background: #f8fafc;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.res-card span {
    font-size: 11px;
    color: var(--text-muted);
}

.res-card strong {
    font-size: 14px;
    color: var(--primary-dark);
    margin-top: 2px;
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .results-grid { grid-template-columns: 1fr; }
}

/* =========================================================
   MOBILE / RESPONSIVE POLISH
   Presentation-only overrides: no application logic changed.
   ========================================================= */
:root {
    --mobile-green: #16803b;
    --mobile-green-dark: #0f5f2d;
    --mobile-soft: #f3f8f4;
    --shadow-soft: 0 8px 24px rgba(15, 23, 42, .07);
}

html { height: 100%; }

button, input, textarea, select { -webkit-tap-highlight-color: transparent; }

.mobile-nav { display: none; }

/* Smoother desktop baseline too */
.chat-container { scroll-behavior: smooth; }
.bubble { overflow-wrap: anywhere; }

@media (max-width: 768px) {
    html, body {
        width: 100%;
        min-height: 100%;
        height: 100%;
    }

    body {
        overflow: hidden;
        background: #f5f8f6;
    }

    .app-container,
    .main-content {
        width: 100%;
        min-width: 0;
        min-height: 0;
        height: 100dvh;
        max-height: 100dvh;
    }

    .sidebar { display: none; }

    .main-content {
        background: linear-gradient(180deg, #f7faf8 0%, #f3f7f5 100%);
    }

    .top-header {
        min-height: 68px;
        padding: max(10px, env(safe-area-inset-top)) 14px 10px;
        gap: 10px;
        background: rgba(255,255,255,.94);
        box-shadow: 0 1px 0 rgba(15,23,42,.05);
        position: relative;
        z-index: 5;
    }

    .header-title { min-width: 0; }
    .header-title h1 {
        font-size: 16px;
        line-height: 1.25;
        letter-spacing: -.2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-title p {
        font-size: 10.5px;
        line-height: 1.35;
        margin-top: 3px;
        max-width: 240px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-actions { flex-shrink: 0; }
    .btn-action {
        min-height: 40px;
        padding: 9px 11px;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(15,23,42,.04);
    }

    .btn-action:not(.btn-sync-prices) { font-size: 0; gap: 0; }
    .btn-action:not(.btn-sync-prices) i { font-size: 15px; }

    .mobile-nav {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
        padding: 7px 8px;
        background: rgba(255,255,255,.97);
        border-bottom: 1px solid rgba(226,232,240,.9);
        box-shadow: 0 3px 12px rgba(15,23,42,.045);
        z-index: 4;
    }

    .mobile-nav-btn {
        min-width: 0;
        min-height: 48px;
        border: 0;
        border-radius: 12px;
        background: transparent;
        color: #64748b;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        font-size: 10px;
        font-weight: 650;
        cursor: pointer;
        transition: .18s ease;
    }

    .mobile-nav-btn i { font-size: 16px; }
    .mobile-nav-btn.active {
        color: var(--mobile-green-dark);
        background: #e9f7ed;
    }
    .mobile-nav-btn:active { transform: scale(.96); }

    .chat-container {
        min-height: 0;
        padding: 16px 12px 10px;
        gap: 12px;
        overscroll-behavior: contain;
    }

    .message {
        width: auto;
        max-width: 94%;
        gap: 7px;
    }

    .avatar {
        width: 31px;
        height: 31px;
        border-radius: 10px;
        font-size: 13px;
    }

    .bubble {
        padding: 10px 12px;
        border-radius: 14px;
        font-size: 13.5px;
        line-height: 1.52;
        box-shadow: var(--shadow-soft);
    }

    .bubble ul, .bubble ol { margin: 7px 0 7px 18px; }
    .bubble table { min-width: 520px; }
    .bubble th, .bubble td { padding: 6px 8px; font-size: 12px; }

    .quick-prompts {
        flex: 0 0 auto;
        padding: 7px 10px 8px;
        gap: 7px;
        background: rgba(255,255,255,.74);
        border-top: 1px solid rgba(226,232,240,.55);
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .quick-prompts::-webkit-scrollbar { display: none; }

    .chip {
        min-height: 36px;
        padding: 8px 11px;
        border-radius: 18px;
        font-size: 11.5px;
        box-shadow: 0 2px 7px rgba(15,23,42,.035);
    }

    .input-area {
        padding: 8px 10px max(10px, env(safe-area-inset-bottom));
        background: rgba(255,255,255,.98);
        box-shadow: 0 -5px 20px rgba(15,23,42,.055);
    }

    .input-wrapper {
        min-height: 50px;
        gap: 7px;
        padding: 5px 6px 5px 13px;
        border-radius: 17px;
        background: #f8faf9;
        border-color: #dce7df;
        box-shadow: inset 0 1px 2px rgba(15,23,42,.025);
    }

    .input-wrapper textarea {
        min-height: 38px;
        padding: 9px 0;
        font-size: 14px;
        line-height: 1.4;
    }

    .input-wrapper textarea::placeholder { color: #94a3b8; }

    .send-btn {
        width: 42px;
        height: 42px;
        border-radius: 13px;
        flex: 0 0 42px;
        box-shadow: 0 5px 12px rgba(21,128,61,.2);
    }

    /* Modals become bottom sheets on phones */
    .modal {
        align-items: flex-end;
        padding: 0;
        background: rgba(15,23,42,.48);
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
    }

    .modal-dialog,
    .modal-dialog[style] {
        width: 100% !important;
        max-width: none !important;
        max-height: 92dvh;
        max-height: 92vh;
        border-radius: 22px 22px 0 0;
        box-shadow: 0 -10px 40px rgba(15,23,42,.18);
        animation: mobileSheetIn .2s ease-out;
    }

    .modal-header {
        padding: 14px 15px;
        min-height: 58px;
        gap: 8px;
        position: sticky;
        top: 0;
        background: rgba(255,255,255,.97);
        z-index: 2;
    }

    .modal-header h3 {
        min-width: 0;
        font-size: 14px;
        line-height: 1.35;
    }

    .close-btn {
        width: 38px;
        height: 38px;
        flex: 0 0 38px;
        border-radius: 50%;
        background: #f1f5f9;
        font-size: 23px;
        line-height: 1;
    }

    .modal-body {
        padding: 14px 12px max(18px, env(safe-area-inset-bottom));
        overflow-x: hidden;
    }

    .modal-body > div[style*="background"] {
        padding: 12px !important;
        border-radius: 14px !important;
    }

    .form-grid { grid-template-columns: 1fr; gap: 10px; }
    .form-group { gap: 5px; }
    .form-group label { font-size: 11.5px; }
    .form-group input,
    .form-group select,
    .modal-body select {
        width: 100%;
        min-height: 43px;
        padding: 10px 12px !important;
        border-radius: 11px !important;
        font-size: 14px;
    }

    .results-grid,
    #weatherAdvice { grid-template-columns: 1fr !important; }

    .table-responsive {
        width: 100%;
        overflow-x: auto;
        border: 1px solid #e8eef0;
        border-radius: 12px;
        -webkit-overflow-scrolling: touch;
    }

    .table-data {
        min-width: 620px;
        font-size: 12px;
    }

    .table-data th, .table-data td { padding: 9px 10px; }

    /* Price filters stack naturally and remain touch-friendly */
    #modalHarga .modal-body > div:first-child {
        align-items: stretch !important;
        flex-direction: column !important;
        gap: 8px !important;
    }
    #modalHarga .filter-group {
        width: 100%;
        align-items: stretch !important;
        flex-direction: column;
    }
    #modalHarga .filter-group label { font-size: 11.5px; }
    #modalHarga .filter-group select,
    #modalHarga #marketSource,
    #modalHarga #provinceSelect,
    #modalHarga #regencySelect { min-width: 0 !important; width: 100%; }
    #modalHarga .btn-sync-prices {
        width: 100%;
        min-height: 42px;
        margin: 0 !important;
        order: 1;
    }
    #modalHarga .close-btn { order: 2; position: absolute; right: 9px; top: 9px; }

    /* Inline-style panels used by the existing markup get a softer mobile card look */
    #weatherSummary,
    #weatherAdvice > *,
    #weatherContent > div[style*="background"] {
        border-radius: 13px !important;
    }

    .btn-primary { min-height: 42px; border-radius: 11px; }
}

@media (max-width: 380px) {
    .top-header { padding-left: 10px; padding-right: 10px; }
    .header-title h1 { font-size: 14.5px; }
    .header-title p { max-width: 205px; }
    .mobile-nav-btn { min-height: 45px; font-size: 9.5px; }
    .message { max-width: 96%; }
    .bubble { font-size: 13px; padding: 9px 10px; }
    .chip { font-size: 11px; }
}

@keyframes mobileSheetIn {
    from { transform: translateY(18px); opacity: .85; }
    to { transform: translateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .modal-dialog { animation: none; }
    .chat-container { scroll-behavior: auto; }
}


/* =========================================================
   AGROBOT ELEGANT UI — PRESENTATION ONLY
   Tidak mengubah PHP, JavaScript, API, ID, class, atau alur aplikasi.
   ========================================================= */

:root {
    --e-green-950: #063b1d;
    --e-green-900: #07552a;
    --e-green-800: #0b6b35;
    --e-green-700: #118447;
    --e-green-600: #16a05a;
    --e-green-100: #e8f7ee;
    --e-green-50: #f3fbf6;
    --e-gold: #d59b27;
    --e-ink: #17251d;
    --e-muted: #6b7c72;
    --e-line: #e4ece7;
    --e-shadow: 0 10px 30px rgba(13, 55, 31, .07);
    --e-shadow-lg: 0 18px 50px rgba(13, 55, 31, .11);
}

/* Desktop canvas */
body {
    background:
        radial-gradient(circle at 90% 0%, rgba(22,160,90,.055), transparent 28%),
        linear-gradient(135deg, #f8fbf9 0%, #f3f8f5 100%);
    color: var(--e-ink);
}

.app-container {
    background: transparent;
}

/* Elegant sidebar */
.sidebar {
    width: 292px;
    padding: 22px 17px;
    background:
        linear-gradient(180deg, #ffffff 0%, #fbfefc 72%, #f4faf6 100%);
    border-right: 1px solid rgba(228,236,231,.95);
    box-shadow: 8px 0 28px rgba(12, 57, 32, .035);
    position: relative;
    z-index: 10;
}

.sidebar::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--e-green-900), var(--e-green-600), var(--e-gold));
}

.brand {
    gap: 13px;
    margin-bottom: 30px;
    padding: 5px 5px 19px;
    border-bottom-color: #e8efe9;
}

.brand-icon {
    width: 47px;
    height: 47px;
    border-radius: 15px;
    background: linear-gradient(145deg, #e7f8ed, #d7f2e1);
    color: var(--e-green-800);
    box-shadow: inset 0 0 0 1px rgba(22,160,90,.08), 0 7px 18px rgba(22,160,90,.09);
}

.brand-text h2 {
    color: var(--e-green-900);
    letter-spacing: -.3px;
}

.brand-text span {
    color: #718077;
}

.nav-section {
    margin-bottom: 27px;
}

.nav-title {
    color: #829087;
    letter-spacing: .85px;
    font-size: 10.5px;
}

.nav-btn {
    min-height: 44px;
    margin: 3px 0;
    padding: 10px 12px;
    border: 1px solid transparent;
    color: #314239;
    border-radius: 12px;
}

.nav-btn i {
    width: 20px;
    text-align: center;
    color: #718178;
    transition: .2s ease;
}

.nav-btn:hover {
    background: #f1f8f4;
    border-color: #e1eee6;
    transform: translateX(2px);
}

.nav-btn:hover i,
.nav-btn.active i {
    color: var(--e-green-700);
}

.nav-btn.active {
    background: linear-gradient(100deg, #e5f7ec, #f0faf4);
    color: var(--e-green-900);
    border-color: #d5ecdd;
    box-shadow: 0 5px 16px rgba(22,160,90,.06);
}

.system-status {
    padding: 12px 13px;
    border-radius: 14px;
    background: linear-gradient(135deg, #f3faf5, #ffffff);
    border-color: #deebe2;
    box-shadow: 0 5px 16px rgba(13,55,31,.035);
}

.status-indicator {
    box-shadow: 0 0 0 5px rgba(34,197,94,.10);
}

/* Header */
.main-content {
    background:
        radial-gradient(circle at 100% 0%, rgba(22,160,90,.04), transparent 30%),
        #f7faf8;
}

.top-header {
    min-height: 76px;
    padding: 15px 28px;
    background: rgba(255,255,255,.92);
    border-bottom-color: rgba(224,234,227,.9);
    box-shadow: 0 3px 18px rgba(15,50,29,.035);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: relative;
    z-index: 5;
}

.header-title h1 {
    color: var(--e-green-900);
    font-size: 19px;
    letter-spacing: -.25px;
}

.header-title p {
    color: #718078;
}

.btn-action {
    min-height: 40px;
    border-radius: 11px;
    background: #fff;
    border-color: #dfe9e3;
    box-shadow: 0 4px 13px rgba(15,50,29,.035);
}

.btn-action:hover {
    background: #f2faf5;
    border-color: #cfe5d7;
    color: var(--e-green-900);
    transform: translateY(-1px);
}

/* Chat */
.chat-container {
    padding: 28px clamp(16px, 3vw, 40px) 18px;
    gap: 18px;
    scroll-padding-bottom: 18px;
}

.message {
    max-width: min(860px, 88%);
    gap: 11px;
    animation: elegantMessageIn .22s ease-out both;
}

.avatar {
    border-radius: 12px;
    box-shadow: 0 5px 13px rgba(15,50,29,.07);
}

.bot-avatar {
    background: linear-gradient(145deg, #e4f7eb, #d7f0df);
    color: var(--e-green-800);
}

.user-avatar {
    background: linear-gradient(145deg, #1683c1, #0d6eaa);
}

.bubble {
    padding: 15px 18px;
    border-radius: 17px;
    border-color: #e2ebe5;
    box-shadow: var(--e-shadow);
    line-height: 1.65;
    color: #25372d;
}

.bot-message .bubble {
    border-top-left-radius: 7px;
}

.user-message .bubble {
    background: linear-gradient(135deg, #0d7438, #14934d);
    border-top-right-radius: 7px;
    box-shadow: 0 8px 24px rgba(13,116,56,.16);
}

.bubble strong {
    color: inherit;
}

.bubble code {
    background: #f0f5f2;
    border-radius: 5px;
    padding: 2px 5px;
}

.bubble blockquote {
    border-left: 3px solid #55ad75;
    padding-left: 11px;
    margin: 9px 0;
    color: #607167;
}

.bubble th {
    background: #eef6f1;
    color: #264335;
}

/* Quick prompt bar */
.quick-prompts {
    padding: 10px clamp(16px, 3vw, 40px);
    gap: 9px;
    border-top: 1px solid rgba(226,234,229,.65);
    background: rgba(255,255,255,.70);
}

.chip {
    min-height: 37px;
    padding: 8px 13px;
    border-radius: 19px;
    background: rgba(255,255,255,.96);
    border-color: #dfe9e3;
    box-shadow: 0 3px 10px rgba(15,50,29,.035);
}

.chip i {
    color: var(--e-green-700);
}

.chip:hover {
    background: #ecf9f1;
    border-color: #bfe2cb;
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(22,160,90,.08);
}

/* Input */
.input-area {
    padding: 14px clamp(16px, 3vw, 40px) 22px;
    background: rgba(255,255,255,.92);
    border-top-color: #e2ebe5;
    box-shadow: 0 -7px 25px rgba(15,50,29,.035);
}

.input-wrapper {
    min-height: 55px;
    border-radius: 17px;
    padding: 6px 7px 6px 16px;
    background: #fbfdfc;
    border-color: #dce8e0;
    box-shadow: 0 7px 24px rgba(13,55,31,.045), inset 0 1px 2px rgba(15,50,29,.02);
    transition: .2s ease;
}

.input-wrapper:focus-within {
    border-color: #77bf91;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(22,160,90,.08), 0 9px 25px rgba(13,55,31,.07);
}

.input-wrapper textarea {
    color: #203229;
    font-size: 14.5px;
    line-height: 1.5;
}

.send-btn {
    width: 43px;
    height: 43px;
    flex: 0 0 43px;
    border-radius: 13px;
    background: linear-gradient(145deg, #159650, #0d7438);
    box-shadow: 0 6px 15px rgba(13,116,56,.20);
}

.send-btn:hover {
    background: linear-gradient(145deg, #0d7438, #095c2c);
    transform: translateY(-1px);
}

/* Modal */
.modal {
    background: rgba(5, 25, 14, .52);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-dialog {
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,.7);
    box-shadow: var(--e-shadow-lg);
}

.modal-header {
    min-height: 62px;
    padding: 14px 19px;
    background: linear-gradient(180deg, #ffffff, #fbfdfc);
}

.modal-header h3 {
    color: var(--e-green-900);
}

.close-btn {
    border-radius: 10px;
    background: #f2f6f3;
    color: #53645a;
    transition: .18s ease;
}

.close-btn:hover {
    background: #e4f3e9;
    color: var(--e-green-900);
    transform: rotate(2deg);
}

/* Generic cards/results */
.results-grid > *,
.form-grid > * {
    min-width: 0;
}

.table-responsive {
    border-radius: 13px;
}

.table-data {
    border-radius: 13px;
    overflow: hidden;
}

.table-data thead th {
    background: linear-gradient(180deg, #eef8f2, #e7f4eb);
    color: #244335;
}

.table-data tbody tr {
    transition: background .15s ease;
}

.table-data tbody tr:hover {
    background: #f6fbf8;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
}

button:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(22,160,90,.22);
    outline-offset: 2px;
}

/* Better tablet layout */
@media (max-width: 1024px) and (min-width: 769px) {
    .sidebar {
        width: 245px;
        padding-left: 13px;
        padding-right: 13px;
    }

    .header-title h1 {
        font-size: 17px;
    }

    .chat-container {
        padding-left: 22px;
        padding-right: 22px;
    }

    .input-area,
    .quick-prompts {
        padding-left: 22px;
        padding-right: 22px;
    }
}

/* Phone refinements */
@media (max-width: 768px) {
    body {
        background: #f4f8f5;
    }

    .main-content {
        background:
            radial-gradient(circle at 100% 0%, rgba(22,160,90,.06), transparent 38%),
            linear-gradient(180deg, #f7faf8, #f2f7f4);
    }

    .top-header {
        min-height: 66px;
        padding-left: 13px;
        padding-right: 13px;
        border-bottom-color: #e3ebe6;
    }

    .header-title h1 {
        color: var(--e-green-900);
        font-weight: 750;
    }

    .btn-action {
        min-height: 39px;
        border-radius: 11px;
    }

    .mobile-nav {
        padding: 7px 8px;
        background: rgba(255,255,255,.96);
        border-bottom-color: #e2ebe5;
    }

    .mobile-nav-btn {
        border: 1px solid transparent;
    }

    .mobile-nav-btn.active {
        background: linear-gradient(145deg, #e5f7ec, #f0faf4);
        box-shadow: inset 0 0 0 1px #d6ecde;
    }

    .chat-container {
        padding: 15px 10px 9px;
        gap: 11px;
    }

    .message {
        max-width: 96%;
    }

    .bubble {
        padding: 10px 12px;
        border-radius: 15px;
        box-shadow: 0 7px 18px rgba(13,55,31,.055);
    }

    .quick-prompts {
        padding: 7px 9px 8px;
        background: rgba(255,255,255,.86);
    }

    .input-area {
        padding: 8px 9px max(10px, env(safe-area-inset-bottom));
    }

    .input-wrapper {
        border-radius: 16px;
    }

    .send-btn {
        width: 42px;
        height: 42px;
        flex-basis: 42px;
    }

    .modal-dialog,
    .modal-dialog[style] {
        border-radius: 22px 22px 0 0;
    }
}

@media (max-width: 380px) {
    .header-title h1 {
        font-size: 14px;
    }

    .header-title p {
        max-width: 190px;
    }

    .bubble {
        font-size: 12.8px;
    }
}

@keyframes elegantMessageIn {
    from { opacity: .65; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}


/* =========================================================
   MOBILE CHAT FIX — Android navigation bar safe area
   Presentation-only: does not change application logic.
   ========================================================= */
@media (max-width: 768px) {
    html, body {
        width: 100%;
        height: 100%;
        min-height: 0;
        overflow: hidden;
    }

    .app-container,
    .main-content {
        height: 100dvh !important;
        min-height: 0 !important;
        max-height: 100dvh !important;
        overflow: hidden;
    }

    /* Area pesan tetap menjadi area yang dapat di-scroll. */
    .chat-container {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        padding-bottom: 20px !important;
        scrollbar-width: thin;
    }

    /* Quick topics tetap ringkas agar input tidak terdorong ke bawah. */
    .quick-prompts {
        flex: 0 0 auto !important;
        max-height: 58px;
        overflow-x: auto;
        overflow-y: hidden;
    }

    /*
       Android navigation bar dapat menutupi bagian paling bawah viewport.
       Ruang aman tambahan membuat kolom input + tombol Submit selalu berada
       di atas navigation bar.
    */
    .input-area {
        position: relative;
        z-index: 50;
        flex: 0 0 auto !important;
        padding-bottom: max(72px, env(safe-area-inset-bottom)) !important;
    }

    .input-wrapper {
        position: relative;
        z-index: 51;
    }

    .send-btn {
        position: relative;
        z-index: 52;
    }
}


/* =========================================================
   MOBILE CHAT TABLE SCROLL — tabel hasil AI dapat digeser kiri/kanan
   Presentation-only: tidak mengubah logika/algoritma chatbot.
   ========================================================= */
.chat-table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
    scrollbar-width: thin;
    margin: 10px 0;
    padding-bottom: 3px;
}

.chat-table-scroll table {
    width: max-content !important;
    min-width: 100%;
    max-width: none !important;
    margin: 0 !important;
    border-collapse: collapse;
}

.chat-table-scroll th,
.chat-table-scroll td {
    white-space: nowrap;
}

/* Tabel data halaman lain juga nyaman digeser dengan jari di HP. */
.table-responsive {
    max-width: 100%;
    overflow-x: auto !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
    scrollbar-width: thin;
}

@media (max-width: 768px) {
    .bubble {
        min-width: 0;
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .chat-table-scroll {
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
}


/* =========================================================
   SIDEBAR TOGGLE + TWO-DIRECTION TABLE SCROLL
   Perubahan presentasi saja; tidak mengubah algoritma/output.
   ========================================================= */
.top-header {
    gap: 12px;
}
.sidebar-toggle {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 8px 11px;
    white-space: nowrap;
}
.sidebar-toggle i { font-size: 15px; }
.header-title { min-width: 0; flex: 1 1 auto; }
.header-actions { flex: 0 0 auto; }
.sidebar {
    overflow: hidden;
    transition: width .22s ease, padding .22s ease, border-color .22s ease;
}
.app-container.sidebar-collapsed .sidebar {
    width: 0 !important;
    min-width: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    border-right-width: 0 !important;
}
.app-container.sidebar-collapsed .main-content {
    min-width: 0;
    width: 100%;
}

/* Tabel dalam jawaban AI: scrollbar horizontal dan vertikal bila diperlukan. */
.chat-table-scroll {
    max-height: 62vh;
    overflow: auto !important;
    scrollbar-width: auto;
    scrollbar-color: #94a3b8 #e2e8f0;
    overscroll-behavior: contain;
    touch-action: pan-x pan-y;
    border: 1px solid var(--border);
    border-radius: 6px;
}
.chat-table-scroll table {
    width: max-content !important;
    min-width: 100%;
}
.chat-table-scroll::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}
.chat-table-scroll::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
}
.chat-table-scroll::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 10px;
}
.table-responsive {
    max-height: 65vh;
    overflow: auto !important;
    scrollbar-width: auto;
    scrollbar-color: #94a3b8 #e2e8f0;
    overscroll-behavior: contain;
}
.table-responsive table {
    width: max-content;
    min-width: 100%;
}
@media (max-width: 768px) {
    .top-header { padding: 10px 12px; gap: 8px; }
    .sidebar-toggle { padding: 8px 10px; }
    .sidebar-toggle .toggle-label { display: none; }
    .header-title h1 { font-size: 15px; }
    .header-title p { font-size: 11px; }
    .app-container.sidebar-collapsed .sidebar { display: none; }
    .chat-table-scroll, .table-responsive { max-height: 55vh; }
}
