/* ============================================================
   GDB — Gemini Chat -> DynamoDB overlay  (light theme)
   ============================================================ */

.gdb-hidden { display: none !important; }

/* ---------- Overlay backdrop ---------- */
#gdb-overlay {
    /* local palette, shared with the splash page and the dashboard */
    --g-paper:   #c9d2e2;
    --g-card:    #ffffff;
    --g-card-2:  #e8edf6;
    --g-line:    #97a6c0;
    --g-divider: #bcc7db;
    --g-text:    #0a1430;
    --g-soft:    #2b3a58;
    --g-faint:   #3f4f6c;
    --g-accent:  #5b21b6;
    --g-green:   #116a33;
    --g-red:     #c0262d;

    position: absolute;
    inset: 0;
    background: var(--g-paper);
    border: 1px solid var(--g-line);
    z-index: 9999;
    display: flex;
    justify-content: flex-start;
    align-items: stretch;
    border-radius: 14px;
    box-shadow: 0 6px 24px rgba(10, 20, 48, 0.25);
    overflow-y: auto;
    animation: gdbFadeIn 0.25s ease-out;
}

@keyframes gdbFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Main container ---------- */
.gdb-container {
    width: 100%;
    max-width: 1400px;
    height: 100%;
    max-height: 90vh;   /* when the dashboard stacks its two panels, stay one panel tall */
    min-height: 560px;
    display: flex;
    flex-direction: column;
    padding: 24px;
    background: transparent;
}

/* ---------- Header ---------- */
.gdb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0 18px 0;
    flex-shrink: 0;
}

.gdb-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gdb-title-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.gdb-title h2 {
    font-family: var(--font-display, "Sora", "Inter", system-ui, sans-serif);
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: var(--g-text);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.gdb-subtitle {
    font-size: 13px;
    color: var(--g-soft);
    line-height: 1.3;
}

.gdb-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #2fb67c;
    box-shadow: 0 0 8px rgba(47, 182, 124, 0.7);
    animation: gdbPulse 2s ease-in-out infinite;
}

@keyframes gdbPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.gdb-header-actions { display: flex; align-items: center; gap: 12px; }

.gdb-status {
    font-size: 11px;
    color: var(--g-soft);
    letter-spacing: 0.4px;
    text-transform: uppercase;
}
.gdb-status.connected { color: var(--g-green); }
.gdb-status.error     { color: var(--g-red); }

.gdb-saved-count {
    font-size: 11px;
    color: var(--g-soft);
    letter-spacing: 0.4px;
    text-transform: uppercase;
    padding-left: 12px;
    border-left: 1px solid var(--g-line);
    transition: color 0.2s;
}
.gdb-saved-count.pulse { color: var(--g-green); }

.gdb-close {
    background: none;
    border: none;
    color: var(--g-soft);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px 0 12px;
    margin-left: 6px;
    border-left: 1px solid var(--g-line);
    transition: color 0.15s;
}
.gdb-close:hover { color: var(--g-text); }

/* ---------- Body: two-column split ---------- */
.gdb-body {
    flex: 1;
    min-height: 0;
    display: flex;
    gap: 16px;
}

.gdb-chat-col {
    flex: 1 1 55%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--g-card);
    border: 1px solid var(--g-line);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(10, 20, 48, 0.14);
    overflow: hidden;
}

.gdb-db-col {
    flex: 1 1 45%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--g-card);
    border: 1px solid var(--g-line);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(10, 20, 48, 0.14);
    overflow: hidden;
}

/* ---------- Chat: messages ---------- */
.gdb-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.gdb-messages::-webkit-scrollbar { width: 8px; }
.gdb-messages::-webkit-scrollbar-thumb {
    background: rgba(18, 32, 58, 0.16);
    border-radius: 4px;
}
.gdb-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(18, 32, 58, 0.28);
}

.gdb-msg { display: flex; align-items: flex-start; min-width: 0; }
.gdb-msg-user      { justify-content: flex-end; }
.gdb-msg-assistant { justify-content: flex-start; }

.gdb-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--g-text);
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    animation: gdbMsgIn 0.2s ease-out;
}

@keyframes gdbMsgIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.gdb-msg-user .gdb-bubble {
    max-width: 72%;
    background: #ff9900;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.gdb-msg-assistant .gdb-bubble {
    max-width: 100%;
    width: 100%;
    background: var(--g-card-2);
    border: 1px solid var(--g-divider);
    border-bottom-left-radius: 4px;
}

/* ---------- Save tag ---------- */
.gdb-save-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: -4px;
    margin-left: 14px;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--g-soft);
    letter-spacing: 0.2px;
    opacity: 0;
    animation: gdbSaveFadeIn 0.3s ease-out 0.15s forwards;
}

.gdb-save-tag .gdb-check { color: var(--g-green); font-size: 12px; line-height: 1; }
.gdb-save-tag .gdb-save-sep { color: var(--g-faint); }

@keyframes gdbSaveFadeIn { to { opacity: 1; } }

/* ---------- Typing indicator ---------- */
.gdb-typing .gdb-bubble::after {
    content: '▋';
    animation: gdbBlink 1s steps(2) infinite;
    margin-left: 2px;
    color: var(--g-accent);
}
@keyframes gdbBlink { 50% { opacity: 0; } }

/* ---------- DB panel header ---------- */
.gdb-db-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    background: var(--g-card-2);
    border-bottom: 1px solid var(--g-divider);
    font-size: 12px;
    font-weight: 600;
    color: var(--g-soft);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    flex-shrink: 0;
}

.gdb-db-icon { color: var(--g-accent); font-size: 14px; }

.gdb-db-title {
    flex: 1;
    color: var(--g-soft);
    font-weight: 600;
}

.gdb-db-count {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 11px;
    color: var(--g-soft);
    background: var(--g-paper);
    padding: 2px 8px;
    border-radius: 10px;
}

/* ---------- DB panel list ---------- */
.gdb-db-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px 0;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 11px;
}

.gdb-db-list::-webkit-scrollbar { width: 8px; }
.gdb-db-list::-webkit-scrollbar-thumb {
    background: rgba(18, 32, 58, 0.16);
    border-radius: 4px;
}

.gdb-db-empty {
    padding: 30px 20px;
    text-align: center;
    color: var(--g-faint);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 12px;
    line-height: 1.6;
}

/* ---------- DB item row — fixed grid columns ---------- */
.gdb-db-item {
    display: grid;
    grid-template-columns: 70px 1fr 1.3fr 0.9fr;
    gap: 12px;
    padding: 6px 14px;
    color: var(--g-text);
    border-bottom: 1px solid var(--g-divider);
    animation: gdbDbItemIn 0.25s ease-out;
    white-space: nowrap;
    align-items: center;
}

.gdb-db-item:hover { background: rgba(255, 153, 0, 0.10); }

.gdb-db-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.gdb-db-item .gdb-db-time   { color: var(--g-accent); }
.gdb-db-item .gdb-db-input  { color: var(--g-text); }
.gdb-db-item .gdb-db-resp   { color: var(--g-soft); }
.gdb-db-item .gdb-db-conv   { color: var(--g-faint); }

.gdb-db-item.is-new {
    animation: gdbDbItemNew 1.2s ease-out;
}

@keyframes gdbDbItemIn {
    from { opacity: 0; transform: translateX(6px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes gdbDbItemNew {
    0%   { background: rgba(21, 128, 61, 0.20); }
    100% { background: transparent; }
}

/* ---------- Session details ---------- */
.gdb-session-details {
    margin-top: 16px;
    border: 1px solid var(--g-line);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(10, 20, 48, 0.14);
    overflow: hidden;
    background: var(--g-card);
    font-size: 12px;
    color: var(--g-soft);
    flex-shrink: 0;
}

.gdb-session-details summary {
    padding: 10px 20px;
    cursor: pointer;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--g-soft);
    letter-spacing: 0.3px;
}
.gdb-session-details summary::-webkit-details-marker { display: none; }
.gdb-session-details summary::before {
    content: '▸';
    display: inline-block;
    transition: transform 0.15s;
    color: var(--g-faint);
}
.gdb-session-details[open] summary::before { transform: rotate(90deg); }
.gdb-session-details summary:hover { color: var(--g-text); }

.gdb-session-body {
    padding: 8px 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid var(--g-divider);
}

.gdb-session-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.gdb-session-label {
    color: var(--g-faint);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.gdb-session-row code {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 11px;
    color: var(--g-text);
    background: var(--g-paper);
    padding: 2px 6px;
    border-radius: 4px;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Input row ---------- */
.gdb-input-row {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    padding: 12px 14px;
    border: 1px solid var(--g-line);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(10, 20, 48, 0.14);
    background: var(--g-card);
    flex-shrink: 0;
}

#gdb-input {
    flex: 1;
    background: #ffffff;
    border: 1px solid var(--g-line);
    border-radius: 10px;
    padding: 10px 14px;
    color: var(--g-text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
#gdb-input:focus {
    border-color: #ec7211;
    box-shadow: 0 0 0 3px rgba(255, 153, 0, 0.30);
}
#gdb-input::placeholder { color: var(--g-faint); }

#gdb-send {
    background: #ff9900;
    border: none;
    color: white;
    padding: 0 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.1s, filter 0.15s;
}
#gdb-send:hover    { filter: brightness(1.1); }
#gdb-send:active   { transform: scale(0.97); }
#gdb-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .gdb-container { max-width: 100%; padding: 16px; }
    .gdb-body { flex-direction: column; }
    .gdb-db-col {
        max-height: 40%;
    }
}

/* ============================================================
   AWS light theme (overrides, kept last on purpose)
   orange #ff9900 | squid ink #232f3e (text/accents only) | greys
   ============================================================ */
#gdb-overlay {
    --g-paper:   #e3e7ea;
    --g-card:    #ffffff;
    --g-card-2:  #f4f6f7;
    --g-line:    #b4bec6;
    --g-divider: #dde2e6;
    --g-text:    #16191f;
    --g-soft:    #37475a;
    --g-faint:   #545b64;
    --g-accent:  #c45500;
    --g-green:   #1d8102;
    --g-red:     #d13212;
    background: linear-gradient(160deg, #f4f6f7 0%, #dde2e6 55%, #cfd6db 100%);
    border-color: #b4bec6;
}
.gdb-container {
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
}

/* header: light bar, navy text, orange rule, soft lift */
.gdb-header {
    background: linear-gradient(180deg, #ffffff, #eef1f3);
    border: 1px solid #b4bec6;
    border-bottom: 3px solid #ff9900;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 4px 14px rgba(35, 47, 62, 0.15);
    position: relative;
    z-index: 2;
}
.gdb-title h2 { color: #232f3e; }
.gdb-subtitle { color: #37475a; }
.gdb-status { color: #37475a; }
.gdb-status.connected { color: #1d8102; font-weight: 600; }
.gdb-status.error { color: #d13212; }
.gdb-saved-count { color: #37475a; border-left-color: #b4bec6; }
.gdb-saved-count.pulse { color: #c45500; }
.gdb-close { color: #545b64; border-left-color: #b4bec6; }
.gdb-close:hover { color: #c45500; }

/* body panels float as cards with real shadows */
.gdb-body { gap: 16px; padding: 16px 0 0; overflow: visible; }
.gdb-chat-col, .gdb-db-col {
    background: #ffffff;
    border: 1px solid #b4bec6;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(35, 47, 62, 0.16), 0 1px 3px rgba(35, 47, 62, 0.12);
    overflow: hidden;
}

/* chat */
.gdb-msg-user .gdb-bubble {
    background: linear-gradient(180deg, #ffad33, #ec8f00);
    color: #16191f;
    font-weight: 500;
    box-shadow: 0 3px 8px rgba(196, 85, 0, 0.30);
}
.gdb-msg-assistant .gdb-bubble {
    background: linear-gradient(180deg, #ffffff, #f4f6f7);
    border: 1px solid #b4bec6;
    color: #16191f;
    box-shadow: 0 2px 6px rgba(35, 47, 62, 0.10);
}
.gdb-typing .gdb-bubble::after { color: #ec7211; }
.gdb-save-tag { color: #37475a; }
.gdb-save-tag .gdb-check { color: #1d8102; }
.gdb-session-details, .gdb-input-row {
    background: linear-gradient(180deg, #ffffff, #f4f6f7);
    border: 1px solid #b4bec6;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(35, 47, 62, 0.12);
}
#gdb-input { border: 1px solid #8d99a3; box-shadow: inset 0 1px 3px rgba(35, 47, 62, 0.14); }
#gdb-input:focus { border-color: #ec7211; box-shadow: 0 0 0 3px rgba(255, 153, 0, 0.30); }
#gdb-send {
    background: linear-gradient(180deg, #ffad33, #ec8f00);
    color: #16191f;
    box-shadow: 0 3px 8px rgba(196, 85, 0, 0.35);
}
#gdb-send:hover { filter: brightness(1.06); }

/* right panel: light table, navy header band, strong text */
.gdb-db-header { background: linear-gradient(180deg, #2d3b4d, #232f3e); border-bottom: 2px solid #ff9900; color: #ffffff; }
.gdb-db-icon { color: #ff9900; }
.gdb-db-title { color: #ffffff; }
.gdb-db-count { background: #ff9900; color: #16191f; font-weight: 700; }
.gdb-db-list { background: #ffffff; }
.gdb-db-empty { color: #37475a; }
.gdb-db-list::-webkit-scrollbar-thumb { background: #b4bec6; }
.gdb-db-item { color: #16191f; border-bottom: 1px solid #dde2e6; }
.gdb-db-item:nth-child(even) { background: #f4f6f7; }
.gdb-db-item:hover { background: #fff1d6; }
.gdb-db-item .gdb-db-time  { color: #c45500; font-weight: 600; }
.gdb-db-item .gdb-db-input { color: #0f1b2a; font-weight: 600; }
.gdb-db-item .gdb-db-resp  { color: #37475a; }
.gdb-db-item .gdb-db-conv  { color: #545b64; }
@keyframes gdbDbItemNew { 0% { background: rgba(255, 153, 0, 0.40); } 100% { background: transparent; } }

/* fill the whole frame, pinned to the top */
#gdb-overlay { align-items: flex-start; padding: 12px; box-sizing: border-box; }
.gdb-container { width: 100%; max-width: none; height: 100%; }
@media (max-width: 900px) { .gdb-container { max-width: none; } }

/* header spacing: room around the dot, title and actions */
.gdb-header { padding: 16px 24px; }
.gdb-title { gap: 14px; }
.gdb-title-text { gap: 4px; }
.gdb-header-actions { gap: 14px; }
.gdb-body { padding-top: 18px; }
