/* ============================================================
   PNPB Chat Box - New Layout
   File: chat_box_new.css
   NON modificare chat_box.css originale
   ============================================================ */

/* ── MODAL OVERLAY ────────────────────────────────────────── */
.readme-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    overflow: hidden;
}

/* ── CONTENITORE PRINCIPALE ───────────────────────────────── */
.readme-modal-content {
    display: flex;
    flex-direction: column;
    background: #2a2a2a;
    margin: 10px auto;
    width: 96%;
    height: 96vh;
    border-radius: 12px;
    overflow: hidden;
    padding: 0;
}

/* ── TESTA ────────────────────────────────────────────────── */
#chat-header {
    background: #1a1a1a;
    color: #fff;
    padding: 12px 20px;
    font-size: 1.1em;
    font-weight: bold;
    text-align: center;
    border-bottom: 1px solid #444;
    flex-shrink: 0;
}

/* ── BODY (sidebar + chat) ────────────────────────────────── */
#chat-body {
    display: flex;
    flex-direction: row;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ── SIDEBAR SX ───────────────────────────────────────────── */
#chat-sidebar {
    width: 180px;
    min-width: 180px;
    background: #1a1a1a;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #333;
    overflow-y: auto;
    scrollbar-width: none;       /* Firefox */
    -ms-overflow-style: none;    /* IE/Edge */
}
#chat-sidebar::-webkit-scrollbar { display: none; } /* Chrome/Safari */

#chat-sidebar .sidebar-section {
    padding: 10px;
    border-bottom: 1px solid #333;
}

#chat-sidebar .sidebar-title {
    color: #aaa;
    font-size: 0.75em;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 8px;
    padding-left: 5px;
}

#chat-sidebar .sidebar-title-toggle {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 4px;
}
#chat-sidebar .sidebar-title-toggle:hover { color: #fff; }
#chat-sidebar .sidebar-title-arrow {
    font-size: 0.7em;
    transition: transform 0.2s;
}
#chat-sidebar .sidebar-items {
    padding-left: 4px;
}

#chat-sidebar .artist-item {
    color: #eee;
    padding: 8px 10px;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.9em;
    margin-bottom: 4px;
    transition: background 0.2s;
}

#chat-sidebar .artist-item:hover,
#chat-sidebar .artist-item.active {
    background: #2b87f2;
    color: #fff;
}

#chat-sidebar .action-item {
    color: #ccc;
    padding: 7px 10px;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.85em;
    margin-bottom: 3px;
    transition: background 0.2s;
}

#chat-sidebar .action-item:hover {
    background: #333;
    color: #fff;
}

/* ── MAIN (chat + input) ──────────────────────────────────── */
#chat-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    background: #1e3a5f;
    position: relative;
}

/* ── Pannelli sovrapposti — coprono l'area chat con margine uniforme ── */
#lb-panel, #la-panel, #ca-panel, #project-panel, #gm-panel, #cd-panel, #ce-panel,
#lbs1-panel, #suno-panel, #game-panel {
    position: absolute;
    inset: 10px;
    z-index: 20;
    overflow-y: auto;
    margin: 0 !important;
    display: flex;
    flex-direction: column;
}

/* ── CHAT MESSAGES ────────────────────────────────────────── */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    max-width: 100%;
    padding: 15px 15px 30px 15px;
    display: flex !important;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: #1e3a5f;
    border: none;
    margin-bottom: 0;
    height: auto;
    width: 100%;
}

/* ── FOOTER INPUT ─────────────────────────────────────────── */
#chat-footer {
    background: #2a2a2a;
    padding: 10px 15px;
    border-top: 1px solid #444;
    flex-shrink: 0;
}

#chat-input {
    width: 100%;
    height: 70px;
    background: #222;
    color: #eee;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 10px;
    resize: none;
    box-sizing: border-box;
    font-size: 0.95em;
}

/* ── BUTTON GROUP ─────────────────────────────────────────── */
.button-group {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
    width: 100%;
}

/* ── CHAT MESSAGES-2 (prompt output) nascosto ─────────────── */
#chat-messages-2 {
    display: none;
}

/* ── ARTIST SELECT nascosto (sostituito dalla sidebar) ─────── */
#artist-select {
    display: none;
}

/* ── FUMETTI ──────────────────────────────────────────────── */
.tipo1 {
    align-self: flex-end;
    background-color: #90ee90;
    color: #1a1a1a;
    border-radius: 18px 18px 2px 18px;
    max-width: 70%;
    padding: 12px 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    margin-right: 15px;
    max-width: 70%;
    word-wrap: break-word;
}

.tipo2 {
    align-self: flex-start;
    background-color: #3a6a9a;
    color: #eee;
    border-radius: 18px 18px 18px 2px;
    max-width: 75%;
    padding: 15px 20px;
    line-height: 1.5;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    margin-left: 15px;
    max-width: 75%;
    word-wrap: break-word;
}

.user-msg {
    justify-content: flex-end;
    padding-right: 15px;
}

.ai-msg {
    justify-content: flex-start;
}

.chat-message-wrapper {
    display: flex;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* ── MOBILE ───────────────────────────────────────────────── */
@media (max-width: 768px) {

    .readme-modal-content {
        margin: 0;
        width: 100%;
        height: 100vh;
        border-radius: 0;
    }

    #chat-header {
        display: flex;
        align-items: center;
        gap: 10px;
        text-align: left;
    }

    #chat-header-toggle {
        font-size: 1.2em;
        cursor: pointer;
        flex-shrink: 0;
        padding: 2px 6px;
        border-radius: 4px;
        user-select: none;
    }
    #chat-header-toggle:hover { background: #333; }

    #chat-header-title {
        flex: 1;
        text-align: center;
    }

    /* Sidebar nascosta di default su mobile */
    #chat-sidebar {
        display: none;
        position: absolute;
        top: 0;
        left: 0;
        width: 220px;
        height: 100%;
        z-index: 30;
        background: #1a1a1a;
        border-right: 1px solid #444;
        overflow-y: auto;
        box-shadow: 4px 0 20px rgba(0,0,0,0.5);
    }

    /* Visibile quando aperta dal toggle */
    #chat-sidebar.sidebar-mobile-open {
        display: flex;
    }

    #chat-input {
        height: 60px;
    }

    #chat-messages {
        overflow-x: hidden;
        padding: 10px;
    }
    .tipo1 {
        max-width: 82%;
        margin-left: auto;
        margin-right: 4px;
        overflow: hidden;
        overflow-wrap: break-word;
    }
    .tipo2 {
        max-width: 82%;
        margin-left: 4px;
        margin-right: auto;
        overflow: hidden;
        overflow-wrap: break-word;
    }
}