/* =========================================================
   style.css — Option B (Settings modal)
   Goals:
   - Keep current design intact
   - Add global “safe” defaults (box-sizing, focus)
   - Add Option B utilities (light buttons, modal helpers)
   - Scope changes so we don’t break existing pages
   ========================================================= */

:root {
    --Default_Text: #333;
    --Light_Text: #666;
    --navy: #1a1a2e;
    --navy_over: #4ECDC4;
    --cyan: #4ECDC4;
    --cyan_hover: #3dbdb5;
    --orange: #EBAA3F;
    --orange_shadow: #cf8714a4;
    --body: #e0e0e0;
    --body_light: #f5f5f5;
    --element: #f0f0f0;
    --element_border: #ccc;
    --element_shadow: #d5d5d5;
    --element_shadow_dark: #c0c0c0;
    --element_contrast: #f8f9fa;
    --header_bg: #1a1a2e;

    --base-padding: 12px;
    --small-padding: 8px;
    --medium-padding: 16px;
    --large-padding: 24px;

    --font-main: 'Roboto', sans-serif;
    --font-serif: Georgia, 'Times New Roman', serif;

    /* Titlebar fixed + can hide: JS updates both vars dynamically */
    --titlebar-height: 60px;
    --chat-top-offset: 120px;

    /* === AI panel layout (chatbot) === */
    --ai-panel-width: 600px;          /* matches current .form-ai_panel width */
    --ai-panel-gutter: 20px;          /* breathing room */
    --ai-panel-width-collapsed: 64px; /* thin tab when collapsed */
    --ai-panel-min: 280px;            /* resize: minimum width */
    --ai-panel-max: 50vw;             /* resize: maximum width */
    --section-topbar-height: 46px;    /* used by topbar constraint calc */
    --ai-resize-handle-width: 6px;    /* drag handle strip width */

    /* === TYPOGRAPHY SCALE === */
    --fs-sm: 1rem;
    --fs-md: 1.1rem;
    --fs-lg: 1.3rem;
    --fs-xl: 2rem;
    --fs-xxl: 2.5rem;
    --fw-light: 300;
    --fw-regular: 400;
    --fw-medium: 500;

    /* Option B helpers */
    --radius-sm: 10px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-padding-top: var(--chat-top-offset);
}

body {
    font-size: var(--fs-md);
    font-family: var(--font-main);
    display: block;
    margin: 0;
    line-height: 1.5;
    color: var(--Default_Text);
    background-color: var(--body);
    min-height: 100vh;

    /* keep layout aligned with JS-controlled offset */
    padding-top: var(--titlebar-height);
}

footer {
    position: relative;
    width: 100%;
    margin: 0;
    background-color: transparent; /* .site-footer handles its own bg */
    text-align: center;
    box-shadow: none; /* .site-footer has border-top instead */
}

h1 {
    text-align: center;
    line-height: 1.2em;
    margin: 0.5em 0;
    padding: 0.5em 1em;
    color: var(--Default_Text);
    font-family: var(--font-serif);
    font-size: var(--fs-xxl);
    font-weight: var(--fw-regular);
    font-style: italic;
}

h2 {
    margin-top: 0.5em;
    margin-bottom: var(--small-padding);
    padding: var(--small-padding);
    text-align: center;
    color: var(--Default_Text);
    font-family: var(--font-serif);
    font-size: var(--fs-xl);
    font-weight: var(--fw-regular);
}

p {
    display: block;
    margin-block-start: 1em;
    margin-block-end: 1em;
    margin-inline-start: 0;
    margin-inline-end: 0;
    text-align: justify;
    padding: var(--small-padding);
}

a {
    text-decoration: none;
    font-weight: bold;
    color: var(--navy);
}

a:hover { color: var(--navy_over); }

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: var(--medium-padding);
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th { background-color: #f2f2f2; }
tr:nth-child(even) { background-color: #f9f9f9; }
tr:hover { background-color: #f5f5f5; }

label {
    margin-left: 1em;
    margin-bottom: var(--small-padding);
    margin-top: 2px;
    margin-right: 10px !important;
}

/* Inputs: small quality-of-life */
input, select, textarea {
    font-family: var(--font-main);
    font-size: var(--fs-md);
}

/* Focus (keep consistent across the app) */
input:focus, select:focus, textarea:focus,
button:focus, .button:focus {
    outline: 2px solid rgba(21, 42, 105, 0.35);
    outline-offset: 2px;
}

/* =========================================================
   Buttons
   - Keep legacy behavior but avoid overriding chatbot/tooling buttons
   ========================================================= */
.button,
#submit,
#submit1,
.modal-content input[type="submit"],
button:not(.btn-access):not(.btn-outline):not(.btn-cyan):not(.btn-light)
      :not(.btn-join):not(.btn-pending)
      :not(.hintButton):not(.tb-btn):not(.mode-btn):not(.debug-toggle)
      :not(#chatbot-send):not(#chatbot-collapse-btn):not(#chatbot-context-preview-toggle)
      :not(.user-avatar-btn):not(.user-dropdown-item-btn):not(.avatar-btn--danger) {    height: auto;
    transition: background-color 0.3s, transform 0.3s;
    text-decoration: none;
    padding: var(--small-padding) var(--medium-padding);
    background-color: var(--navy);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: var(--fs-md);
    margin: 5px;
    flex-grow: 0;
}

.button:hover,
button:not(.btn-access):not(.btn-outline):not(.btn-cyan):not(.btn-light)
      :not(.btn-join):not(.btn-pending)
      :not(.hintButton):not(.tb-btn):not(.mode-btn):not(.debug-toggle)
      :not(#chatbot-send):not(#chatbot-collapse-btn):not(#chatbot-context-preview-toggle)
      :not(.user-avatar-btn):not(.user-dropdown-item-btn):not(.avatar-btn--danger):hover,.modal-content input[type="submit"]:hover {
    background-color: #0f1f52;
}

.button:active,
button:not(.btn-access):not(.btn-outline):not(.btn-cyan):not(.btn-light)
      :not(.btn-join):not(.btn-pending)
      :not(.hintButton):not(.tb-btn):not(.mode-btn):not(.debug-toggle)
      :not(#chatbot-send):not(#chatbot-collapse-btn):not(#chatbot-context-preview-toggle)
      :not(.user-avatar-btn):not(.user-dropdown-item-btn):not(.avatar-btn--danger):active {
    transform: scale(1);
}

/* CTA / variants */
.btn-access {
    padding: 10px 20px;
    border-radius: 999px;
    font-weight: 600;
    background-color: var(--cyan);
    color: #fff;
    border: none;
    transition: background-color 0.2s ease;
    box-shadow: none;
    margin: 0;
}

.btn-access:hover {
    background-color: var(--cyan_hover);
    color: #fff;
}

.btn-outline {
    padding: 10px 24px;
    border-radius: 999px;
    font-weight: 500;
    background-color: transparent;
    color: var(--Default_Text);
    border: 2px solid var(--Default_Text);
    transition: all 0.2s ease;
    box-shadow: none;
    margin: 0;
}

.btn-outline:hover {
    background-color: var(--Default_Text);
    color: #fff;
}

.btn-cyan {
    padding: 10px 24px;
    border-radius: 999px;
    font-weight: 500;
    background-color: var(--cyan);
    color: #fff;
    border: none;
    transition: background-color 0.2s ease;
    box-shadow: none;
    margin: 0;
}

.btn-cyan:hover { background-color: var(--cyan_hover); }

/* Light “card/button” style (useful inside the settings modal) */
.btn-light {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    user-select: none;
    border: 1px solid rgba(0,0,0,0.08);
    background: rgba(255,255,255,0.70);
    color: var(--Default_Text);
    font-weight: 500;
    box-shadow: none;
    margin: 0;
}
.btn-light:hover {
    background: rgba(255,255,255,0.95);
    border-color: rgba(0,0,0,0.12);
}
.btn-light.danger {
    color: #a8071a;
    background: rgba(253, 232, 232, 0.75);
    border-color: rgba(168, 7, 26, 0.20);
}
.btn-light.danger:hover { background: rgba(253, 232, 232, 0.95); }

/* =========================================================
   Main menu
   ========================================================= */
.mainmenu {
    position: static;
    top: auto;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    background: transparent;
    z-index: auto;
    box-shadow: none;
}

.mainmenu-item { flex-grow: 0; }

.mainmenu-item,
.mainmenu a {
    display: inline-block;
    text-align: center;
    text-transform: none;
    font-size: var(--fs-md);
    font-weight: 500;
    color: #fff;
    text-decoration: none;
    padding: var(--small-padding) var(--medium-padding);
    border-radius: 8px;
    transition: color .2s ease, opacity .2s ease;
}

.mainmenu-item:hover,
.mainmenu-item:focus-visible,
.mainmenu a:hover,
.mainmenu a:focus-visible {
    opacity: 0.8;
    color: #fff;
}

/* =========================================================
   Form layout
   ========================================================= */
.form-body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
}

.form-container { display: flex; }

.form-content {
    flex: 1;
    margin-left: var(--large-padding);
    margin-right: calc(var(--ai-panel-width) + var(--ai-panel-gutter) + var(--large-padding)); /* symmetric: matches left */
    margin-top: 0; /* offset handled by body padding-top */
    padding: 20px;
    padding-top: var(--large-padding); /* breathing room below sticky topbar */
    transition: margin-right 0.2s ease; /* smooth when collapsing */
}

/* Gap between sticky topbar and first visible wizard section */
.wizard-section.active:first-of-type,
.wizard-section.active {
    padding-top: var(--large-padding);
}

.form-ai_panel {
    position: fixed;
    right: 0;
    top: var(--chat-top-offset);
    width: var(--ai-panel-width);
    height: calc(100vh - var(--chat-top-offset));
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--element_border);
    background-color: var(--element);
    box-shadow: 0 4px 8px var(--element_shadow);
    z-index: 101;
    transition: width 0.2s ease; /* smooth when collapsing */
}

/* Footer: full-width background, content inset from AI panel */
.form-body .site-footer {
    padding-right: calc(var(--ai-panel-width) + var(--ai-panel-gutter) + 40px);
    transition: padding-right 0.2s ease;
}

/* =========================================================
   Chatbot panel collapsed layout
   - JS toggles: document.body.classList.toggle('chatbot-collapsed', ...)
   ========================================================= */
body.chatbot-collapsed {
    --ai-panel-width: var(--ai-panel-width-collapsed);
}

body.chatbot-collapsed .form-ai_panel {
    width: var(--ai-panel-width);
}

/* optional: prevent title overflow in thin mode */
body.chatbot-collapsed #chatbot-title { display: none; }

/* =========================================================
   Progress Bar
   ========================================================= 
.progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: #ddd;
    z-index: 1000;
}

.progress-bar {
    height: 5px;
    background: #007bff;
    width: 0%;
    transition: width 0.3s ease;
}
*/

/* =========================================================
   Generic containers / lists
   ========================================================= */
.container {
    margin-left: 15vw;
    margin-right: 15vw;
    margin-bottom: var(--large-padding);
    margin-top: 0 !important;
    padding-top: 0 !important;
    flex: 1;
}

.container-nobottom {
    margin-left: 15vw;
    margin-right: 15vw;
    flex: 1;
}

div.list-item {
    margin-bottom: var(--small-padding);
    max-height: 800em !important;
}

div.list-item.S {
    display: flex;
    flex-direction: row;
}

.list-item div.S {
    display: flex;
    flex-direction: column;
    background: var(--element);
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-height: none;
    padding: var(--medium-padding);
    padding-right: var(--large-padding);
}

div.list-container {
    flex-direction: column;
    flex-wrap: nowrap;
    flex-grow: 1;
    max-height: 600em !important;
    clear: both;
}

div.grow {
    max-height: 600em !important;
    display: flex;
    width: 100%;
}

li::marker { color: var(--navy); }

.indexaccent {
    border: 2px solid var(--navy);
    background-color: var(--navy);
    color: var(--element);
    font-weight: bold;
    border-radius: 30px;
    padding: 0 var(--medium-padding);
}

/* =========================================================
   Footer
   ========================================================= */
.footer {
    width: 100%;
    background-color: var(--orange);
    color: var(--element);
    text-align: center;
}

.footer-flex {
    display: flex;
    flex-wrap: nowrap;
}

.footer-last {
    display: flex;
    background-color: var(--navy);
    padding: var(--small-padding);
    justify-content: flex-end;
}

.footer-item { flex-grow: 1; }
.footer-item-fix { flex-grow: 0; }

/* Footer logo: same “small logo” behavior as header */
.footer-last .footer-brand-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--element);
    font-weight: 600;
}

.footer-last .footer-brand-link img {
    height: 26px;
    width: 26px;
    max-height: 26px;
    max-width: 26px;
    display: block;
}

.footer-last .footer-brand-link .brand-title {
    color: var(--element);
    line-height: 1;
}

/* Utility */
.hidden {
    display: none !important;
    height: 0;
    width: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* =========================================================
   Option B: reduce unwanted global styles inside Settings modal
   ========================================================= */
#settingsModal p {
    text-align: left;
    padding-left: 0;
    padding-right: 0;
}

#settingsModal label {
    margin-left: 0;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1200px) {
    :root {
        --ai-panel-width: 300px;
        --ai-panel-gutter: 20px;
    }

    .form-content {
        margin-left: var(--large-padding);
        margin-right: calc(var(--ai-panel-width) + var(--ai-panel-gutter) + var(--large-padding)); /* symmetric: matches left */
    }

    .form-ai_panel {
        position: fixed;
        right: 0;
        top: var(--chat-top-offset);
        width: var(--ai-panel-width);
        height: calc(100vh - var(--chat-top-offset));
        display: flex;
        flex-direction: column;
        border-left: 1px solid var(--element_border);
        background-color: var(--element);
        box-shadow: 0 4px 8px var(--element_shadow);
        z-index: 101;
    }

    body.chatbot-collapsed { --ai-panel-width: var(--ai-panel-width-collapsed); }
}

@media screen and (max-width: 768px) {
    .form-container { flex-direction: column; }

    .form-content {
        width: 100%;
        padding: 0.5em;
        margin-left: 0;
        margin-right: 0;
    }

    .form-ai_panel {
        display: none; /* hidden on mobile — form is the sole focus */
    }

    .question {
        margin-top: .5em;
        margin-bottom: 0.5em;
    }

    .question label {
        margin-left: 0;
        margin-bottom: 0.5em;
    }

    div.list-item.S { flex-direction: column; }
    .list-item div.S { padding: 0.8em; }

    .mainmenu {
        padding: 0.25em 5vw;
        flex-wrap: wrap;
    }

    .mainmenu-item {
        flex-basis: 50%;
        text-align: center;
    }

    .form-body .site-footer {
        padding-right: 20px; /* restore mobile default */
    }
}

@media screen and (max-width: 480px) {
    button,
    .button,
    input[type="submit"] {
        padding: 12px 20px;
        width: 100%;
        margin: 5px 0;
    }

    input[type="radio"] {
        transform: scale(1.2);
        margin: 8px;
    }

}

/* =========================================================
   Hint button (legend / helper)
   ========================================================= */

/* Grayed-out style for buttons */
.hintButton.grayed-out {
    background-color: lightgray;
    color: darkgray;
    cursor: pointer; /* still clickable */
}

/* Active style */
.hintButton:not(.grayed-out) {
    background-color: var(--navy);
    color: var(--element);
    cursor: pointer;
}

/* Required legend */
.required-legend {
    color: red;
    font-size: var(--fs-sm);
    margin-top: 5px;
    display: none;
}
.required-legend.show { display: block !important; }

.hintButton {
    display: flex;
    align-items: center;
    justify-content: center;

    background: rgba(0, 0, 0, 0.1);
    border: none;
    cursor: pointer;

    padding: var(--small-padding);
    width: 35px;
    height: 35px;

    border-radius: 8px;
    overflow: hidden;
    white-space: nowrap;
    transition: all 0.3s ease-in-out;

    font-size: 0.7em;
    margin-left: auto;
    margin-top: -3em;
    margin-bottom: 0;

    pointer-events: auto;
    position: relative;
}

/* Icon visible initially */
.chatbot-icon {
    width: 20px;
    height: 20px;
    transition: opacity 0.3s ease-in-out;
}

/* Text starts hidden */
.hint-text {
    opacity: 0;
    visibility: hidden;
    position: absolute;
    color: white;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    white-space: nowrap;
    transition: opacity 0.3s ease-in-out;
}

/* Expand on hover */
.hintButton:hover {
    width: auto;
    padding: var(--small-padding) var(--medium-padding);
    transform: scale(1.07);
}

/* Hide icon on hover */
.hintButton:hover .chatbot-icon {
    opacity: 0;
    width: 0;
    height: 0;
    transition: none;
}

/* Show text on hover */
.hintButton:hover .hint-text {
    opacity: 1;
    visibility: visible;
    position: relative;
}

/* =========================================================
   Phase 4 — Shared components
   Avatars, empty states, button variants, badges, overlay anim
   ========================================================= */

/* --- Avatar (circular thumbnail: photo or initials) --- */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    vertical-align: middle;
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
}

.avatar--sm  { width: 26px; height: 26px; font-size: 0.7rem; }
.avatar--lg  { width: 40px; height: 40px; font-size: 0.95rem; }

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #fff;
    font-weight: 600;
    text-transform: uppercase;
    line-height: 1;
    letter-spacing: 0.02em;
}

/* --- Avatar stack (overlapping group) --- */
.avatar-stack {
    display: inline-flex;
    align-items: center;
}

.avatar-stack .avatar {
    margin-left: -8px;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.06);
}

.avatar-stack .avatar:first-child { margin-left: 0; }

.avatar-overflow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--element);
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.06);
    margin-left: -8px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--Light_Text);
    flex-shrink: 0;
}

/* --- Empty states --- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.55;
    line-height: 1.2;
}

.empty-state-message {
    color: var(--Light_Text);
    font-size: var(--fs-md);
    margin: 0 0 1rem 0;
    padding: 0;
    text-align: center;
}

.empty-state-cta {
    display: inline-block;
    margin-top: 0.25rem;
    text-decoration: none;
}

/* --- Button variants (complement .btn-access already defined) --- */
.btn-join {
    padding: 10px 20px;
    border-radius: 999px;
    font-weight: 600;
    background-color: var(--navy);
    color: #fff;
    border: none;
    transition: background-color 0.2s ease;
    box-shadow: none;
    margin: 0;
}
.btn-join:hover  { background-color: #0f1f52; color: #fff; }

.btn-create {
    display: inline-block;
    text-decoration: none;
    white-space: nowrap;
}

.btn-danger       { color: #C2185B !important; }
.btn-danger:hover { color: #a01048 !important; }

.btn-sm { font-size: 0.85em; }

.btn-pending {
    opacity: 0.55;
    cursor: default;
    pointer-events: none;
}

.copy-button {
    background-color: #4CAF50;
}

/* --- Badges --- */
.subject-badge {
    display: inline-block;
    font-size: 0.8em;
    padding: 2px 10px;
    border-radius: 12px;
    background: #e8f0fe;
    color: #1a56db;
    white-space: nowrap;
    line-height: 1.5;
}

.role-badge {
    display: inline-block;
    font-size: 0.8em;
    padding: 2px 8px;
    border-radius: 3px;
    background: var(--element);
    white-space: nowrap;
}

.collab-overflow {
    font-size: 0.8em;
    font-weight: 600;
    color: var(--Light_Text);
}

.notif-badge--inline {
    display: inline-block;
    font-size: 0.75em;
    background: #C2185B;
    color: #fff;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: 0.4rem;
    vertical-align: middle;
    line-height: 1.4;
}

/* --- Overlay fade-in (supplements style_modal.css) --- */
.modal-fade {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal-fade.is-visible {
    opacity: 1;
}

.overlay-icon {
    font-size: 1.4rem;
    margin-right: 0.4rem;
    vertical-align: middle;
}

.overlay-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-top: 1rem;
}
