/* GoFig Assistant - Custom Styles */

/* Favicon override */
link[rel="icon"] {
    /* Chainlit should pick up /public/favicon.png automatically */
}

/* Constrain logo size in header */
header img[alt*="logo"],
header img[src*="logo"] {
    max-height: 40px;
    width: auto;
}

/* Login page logo sizing */
img[src*="logo.png"] {
    max-width: 400px;
}

/* Scrollbar theming for dark mode */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: hsl(160, 10%, 8%);
}

::-webkit-scrollbar-thumb {
    background: hsl(160, 15%, 25%);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: hsl(160, 20%, 35%);
}

/* ---------------------------------------------------------------------------
   Projects UI
   --------------------------------------------------------------------------- */

.project-trigger-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: calc(100% - 16px);
    margin: 0 8px 8px;
    padding: 8px 12px;
    border: 1px solid hsl(160 8% 22%);
    border-radius: 8px;
    background: hsl(160 8% 12%);
    color: hsl(160 5% 65%);
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.project-trigger-btn:hover {
    border-color: hsl(160 60% 45%);
    background: hsl(160 10% 15%);
}
.project-trigger-btn svg { flex-shrink: 0; opacity: 0.6; }
.project-trigger-btn.active {
    border-color: hsl(160 60% 45%);
    color: hsl(160 60% 70%);
}
.project-trigger-btn .active-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: hsl(160 60% 45%);
    margin-left: auto;
}

.project-overlay {
    position: fixed; inset: 0; z-index: 10000;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: 8vh;
    animation: project-fade-in 0.15s ease;
}
@keyframes project-fade-in { from { opacity: 0 } to { opacity: 1 } }

.project-modal {
    width: 560px; max-width: 92vw; max-height: 80vh;
    background: hsl(160 8% 12%);
    border: 1px solid hsl(160 8% 22%);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    display: flex; flex-direction: column; overflow: hidden;
}

.project-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid hsl(160 8% 22%);
}
.project-header h2 {
    margin: 0; font-size: 16px; font-weight: 600;
    color: hsl(160 5% 90%);
}
.project-header-actions { display: flex; gap: 8px; }
.project-header-actions button {
    background: none; border: none; cursor: pointer;
    color: hsl(160 5% 65%); font-size: 13px; padding: 4px 8px;
    border-radius: 6px;
}
.project-header-actions button:hover { background: hsl(160 10% 18%); color: hsl(160 5% 90%); }

.project-body { overflow-y: auto; flex: 1; padding: 8px 0; }

.project-list-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px; cursor: pointer;
    border-bottom: 1px solid hsl(160 8% 16%);
    transition: background 0.1s;
}
.project-list-item:hover { background: hsl(160 10% 16%); }
.project-list-item .name {
    font-weight: 600; color: hsl(160 5% 90%); font-size: 14px;
    flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.project-list-item .desc {
    font-size: 12px; color: hsl(160 5% 50%);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;
}
.project-list-item .active-badge {
    font-size: 10px; color: hsl(160 60% 60%); font-weight: 600;
    background: hsl(160 60% 45% / 0.15); padding: 2px 8px; border-radius: 4px;
}

.project-empty {
    padding: 40px 20px; text-align: center;
    color: hsl(160 5% 50%); font-size: 13px;
}

/* Detail view */
.project-detail { padding: 16px 20px; }
.project-detail label {
    display: block; font-size: 12px; font-weight: 600;
    color: hsl(160 5% 55%); margin: 12px 0 4px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.project-detail label:first-child { margin-top: 0; }
.project-detail input[type="text"],
.project-detail textarea {
    width: 100%; box-sizing: border-box;
    background: hsl(160 8% 16%); border: 1px solid hsl(160 8% 25%);
    border-radius: 6px; padding: 8px 10px;
    color: hsl(160 5% 90%); font-size: 14px; font-family: inherit;
    outline: none; resize: vertical;
}
.project-detail input[type="text"]:focus,
.project-detail textarea:focus {
    border-color: hsl(160 60% 45%);
}
.project-detail textarea { min-height: 80px; }

.project-detail .file-list { margin-top: 8px; }
.project-file-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 0; font-size: 13px; color: hsl(160 5% 80%);
}
.project-file-item .size { color: hsl(160 5% 50%); font-size: 11px; }
.project-file-item .delete-btn {
    margin-left: auto; background: none; border: none; cursor: pointer;
    color: hsl(0 60% 60%); font-size: 12px; padding: 2px 6px; border-radius: 4px;
}
.project-file-item .delete-btn:hover { background: hsl(0 60% 60% / 0.15); }

.project-detail .actions {
    display: flex; gap: 8px; margin-top: 16px; padding-top: 12px;
    border-top: 1px solid hsl(160 8% 22%);
}

.project-btn {
    padding: 8px 16px; border: none; border-radius: 6px;
    font-size: 13px; font-weight: 500; cursor: pointer;
    transition: background 0.15s;
}
.project-btn-primary {
    background: hsl(160 60% 45%); color: hsl(160 10% 10%);
}
.project-btn-primary:hover { background: hsl(160 60% 50%); }
.project-btn-secondary {
    background: hsl(160 8% 20%); color: hsl(160 5% 80%);
}
.project-btn-secondary:hover { background: hsl(160 8% 25%); }
.project-btn-danger {
    background: hsl(0 60% 45% / 0.15); color: hsl(0 60% 65%);
}
.project-btn-danger:hover { background: hsl(0 60% 45% / 0.25); }
.project-btn-activate {
    background: hsl(160 60% 45% / 0.15); color: hsl(160 60% 65%);
}
.project-btn-activate:hover { background: hsl(160 60% 45% / 0.25); }

.project-upload-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 12px; margin-top: 8px;
    background: hsl(160 8% 20%); border: 1px dashed hsl(160 8% 30%);
    border-radius: 6px; color: hsl(160 5% 65%); font-size: 12px;
    cursor: pointer;
}
.project-upload-btn:hover { border-color: hsl(160 60% 45%); color: hsl(160 5% 90%); }

/* ---------------------------------------------------------------------------
   Mobile UX hardening
   --------------------------------------------------------------------------- */
@media (max-width: 767px) {
    /* Keep the mobile history drawer narrower so chat content remains legible. */
    [data-sidebar="sidebar"][data-mobile="true"] {
        width: min(16rem, 78vw) !important;
        max-width: min(16rem, 78vw) !important;
    }

    /* Prevent horizontal bleed when any sidebar animation runs on small screens. */
    .group\/sidebar-wrapper {
        overflow-x: hidden;
    }

    /* Hide Projects button on mobile — it's in the Sheet portal which has its own lifecycle */
    .project-trigger-btn {
        display: none !important;
    }
}
