﻿/* ====== GLOBAL ====== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f3f4f6;
    color: #111827;
}

/* ====== TOP BAR ====== */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #111827;
    color: #f9fafb;
    padding: 0.75rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    position: sticky;
    top: 0;
    z-index: 10;
}

    .topbar h1 {
        margin: 0;
        font-size: 1.25rem;
        font-weight: 600;
    }

    .topbar nav {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

        .topbar nav button {
            padding: 0.4rem 0.9rem;
            border-radius: 999px;
            border: 1px solid transparent;
            background: transparent;
            color: #e5e7eb;
            cursor: pointer;
            font-size: 0.85rem;
        }

            .topbar nav button:hover {
                background: #1f2937;
                border-color: #374151;
            }

            .topbar nav button.hidden {
                display: none;
            }

/* ====== LAYOUT ====== */
.container {
    max-width: 1100px;
    margin: 1.5rem auto;
    padding: 0 1rem 2rem;
}

/* ====== CARD ====== */
.card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.75rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

    .card h2 {
        margin-top: 0;
        margin-bottom: 0.25rem;
        font-size: 1.3rem;
        font-weight: 600;
    }

    .card p {
        margin-top: 0.25rem;
        margin-bottom: 0.75rem;
        color: #4b5563;
        font-size: 0.95rem;
    }

/* ====== FORM ELEMENTS ====== */
label {
    display: block;
    margin-top: 0.75rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: #374151;
}

input,
textarea,
select {
    width: 100%;
    padding: 0.55rem 0.65rem;
    margin-top: 0.25rem;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    background: #f9fafb;
    resize: vertical;
}

    input:focus,
    textarea:focus,
    select:focus {
        border-color: #2563eb;
        box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
        background: #ffffff;
    }

/* dropdown di admin (filter status) */
#admin-question-filter {
    max-width: 200px;
}

/* ====== BUTTONS ====== */
button[type="submit"],
.btn-send-otp,
#btn-refresh-questions,
#manual-answer-save {
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background: #2563eb;
    color: #f9fafb;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.1s ease;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
}

    button[type="submit"]:hover,
    .btn-send-otp:hover,
    #btn-refresh-questions:hover,
    #manual-answer-save:hover {
        background: #1d4ed8;
        transform: translateY(-0.5px);
        box-shadow: 0 4px 8px rgba(37, 99, 235, 0.35);
    }

    button[type="submit"]:disabled,
    .btn-send-otp:disabled {
        opacity: 0.6;
        cursor: default;
        box-shadow: none;
    }

/* tombol sekunder (dipakai di tabel admin, modal, dan sidebar project) */
.btn-secondary {
    padding: 0.4rem 0.8rem;
    background: #ffffff;
    color: #111827;
    border-radius: 999px;
    border: 1px solid #d1d5db;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease, box-shadow 0.1s ease;
}

    .btn-secondary:hover {
        background: #f3f4f6;
        border-color: #9ca3af;
        transform: translateY(-0.5px);
        box-shadow: 0 2px 4px rgba(15, 23, 42, 0.08);
    }

    .btn-secondary:disabled {
        opacity: 0.6;
        cursor: default;
        box-shadow: none;
    }

/* ====== MESSAGE / HINT ====== */
.message {
    margin-top: 1rem;
    font-size: 0.9rem;
}

    .message.error {
        color: #b91c1c;
    }

    .message.success {
        color: #166534;
    }

    .message.info {
        color: #0369a1;
    }

.hint {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: #6b7280;
}

    .hint a {
        color: #2563eb;
        text-decoration: none;
        font-weight: 500;
    }

        .hint a:hover {
            text-decoration: underline;
        }

/* ====== CHAT LAYOUT + PROJECT SIDEBAR ====== */
/* ====== CHAT LAYOUT + PROJECT SIDEBAR ====== */
.chat-layout {
    display: flex;
    gap: 1.25rem;
}

/* Sidebar project di kiri chat */
.sidebar-projects {
    width: 260px;
    min-width: 220px;
    background: #f9fafb;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    padding: 0.9rem 0.8rem 0.75rem;
    display: flex;
    flex-direction: column;
}

/* Header "Projects" */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.45rem;
}

.sidebar-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #111827;
}

/* Tombol + New Project full width */
.btn-sidebar-new {
    width: 100%;
    margin: 0 0 0.5rem 0;
    padding: 0.4rem 0.7rem;
    border-radius: 999px;
    border: 1px dashed #9ca3af;
    background: #f9fafb;
    font-size: 0.8rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

    .btn-sidebar-new:hover {
        background: #e5e7eb;
        border-color: #6b7280;
        transform: translateY(-0.5px);
    }

/* List project */
.project-list {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    overflow-y: auto;
}

/* Item project (seperti pill) */
.project-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #111827;
    transition: background 0.12s ease, color 0.12s ease;
    margin-bottom: 0.25rem;
}

    .project-item:hover {
        background: #e5e7eb;
    }

    .project-item.active {
        background: #2563eb;
        color: #f9fafb;
    }

/* bagian kiri: icon + nama */
.project-main {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    min-width: 0;
}

.project-icon {
    font-size: 0.9rem;
}

.project-name {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

/* bagian kanan: tombol rename/delete (muncul saat hover) */
.project-actions {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
}

.project-item:hover .project-actions {
    opacity: 1;
    pointer-events: auto;
}

.project-action-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0.05rem 0.15rem;
    border-radius: 999px;
    color: inherit;
}

    .project-action-btn:hover {
        background: rgba(0, 0, 0, 0.06);
    }

/* Chat main agar memenuhi sisa ruang */
.chat-main {
    flex: 1;
    min-width: 0;
}


/* ====== CHAT (USER) - Q&A BLOCK ====== */
.chat-history {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 0.75rem;
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 0.75rem;
    background: #f9fafb;
}

/* Satu blok = 1 pertanyaan + 1 (atau lebih) jawaban */
.qa-block {
    background: #ffffff;
    border-radius: 12px;
    padding: 0.65rem 0.7rem;
    margin-bottom: 0.6rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    border: 1px solid #e5e7eb;
}

/* Baris umum dalam blok */
.qa-line {
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Pertanyaan user: bold, warna hitam, sedikit highlight */
.qa-line-user {
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.35rem;
}

/* Jawaban AI: teks normal */
.qa-line-ai {
    font-weight: 400;
    color: #111827;
}

    /* Jika suatu saat ada lebih dari satu jawaban AI dalam 1 blok */
    .qa-line-ai + .qa-line-ai {
        margin-top: 0.25rem;
        padding-top: 0.25rem;
        border-top: 1px dashed #e5e7eb;
    }

/* ====== TABLES (OTP & ADMIN) ====== */
.otp-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.85rem;
}

    .otp-table th,
    .otp-table td {
        border: 1px solid #e5e7eb;
        padding: 0.45rem 0.55rem;
        text-align: left;
        vertical-align: top;
    }

    .otp-table th {
        background: #f3f4f6;
        font-weight: 600;
        color: #374151;
    }

    .otp-table tbody tr:nth-child(even) {
        background: #f9fafb;
    }

/* baris filter admin */
.admin-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

/* ====== MODAL JAWABAN MANUAL ====== */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.modal-dialog {
    position: relative;
    background: #ffffff;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
}

    .modal-dialog h3 {
        margin: 0 0 0.25rem;
        font-size: 1.1rem;
        font-weight: 600;
    }

.modal-question {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
    color: #4b5563;
    background: #f9fafb;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
}

.modal-dialog label {
    margin-top: 0.25rem;
}

.modal-actions {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

    .modal-actions #manual-answer-save {
        margin-top: 0;
    }

/* ====== UTILS ====== */
.hidden {
    display: none;
}

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .container {
        margin-top: 1rem;
    }

    .card {
        padding: 1.25rem 1rem;
    }

    .chat-layout {
        flex-direction: column;
    }

    .sidebar-projects {
        width: 100%;
    }

    .otp-table {
        font-size: 0.8rem;
        display: block;
        overflow-x: auto;
    }

    .modal-dialog {
        max-width: 95%;
        padding: 1rem 1.1rem;
    }
}
/* ====== MODAL GENERIC (sudah ada, tambahkan styling header) ====== */

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.modal-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: #eff6ff; /* biru muda */
    color: #1d4ed8;
    font-size: 1rem;
}

.project-icon-large {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
}

.warning-icon {
    background: #fef2f2;
    color: #b91c1c;
}

.modal-subtitle {
    margin: 0;
    font-size: 0.85rem;
    color: #6b7280;
}

/* dialog untuk project / confirm, kasih border garis atas warna biru */
.project-modal-dialog {
    border-top: 4px solid #2563eb;
}

/* tombol close X di pojok kanan modal */
.modal-close-btn {
    padding: 0.1rem 0.4rem;
    font-size: 0.8rem;
    border-radius: 999px;
}

/* teks pertanyaan / konfirmasi di modal project & confirm */
#project-modal-message,
#confirm-modal-text {
    font-size: 0.9rem;
}

/* khusus tombol "Hapus" di confirm modal agar berwarna merah sedikit */
#confirm-modal-ok {
    background: #dc2626;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.25);
}

    #confirm-modal-ok:hover {
        background: #b91c1c;
        box-shadow: 0 4px 8px rgba(220, 38, 38, 0.35);
    }
