/* ============================================
    CSS VARIABLES - THEME TOKENS
    ============================================ */

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

:root {
    --primary: #181818;
    --primary-hover: #0f6cbd;
    --primary-surface:#242424;
    --primary-light: #616161;
    --primary-active: #115ea3;
    --primary-muted: #bdbdbd;
    --primary-danger: #b10e1c;
    
    /* Backgrounds */
    --bg-primary: #f5f5f5;
    --bg-highlight: #e6e6e6;
    --bg-surface: #ffffff;
    --bg-surface-highlight: var(--bg-primary);
    --bg-selected: #ebf3fc;    /* super light gray-blue for selected items */
    --bg-danger: #eeacb2;
    --bg-attention: #f2c661;   /* orange for attention-requiring items, e.g. unsaved files */

    
    /* Borders */
    --border-color: #c6c6c6;
    --border-color-subtle: #e6e6e6;
    
    /* Shadows */
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    
    /* Spacing & Sizing */
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

.dark {
    --primary: #d6d6d6;
    --primary-hover: #479ef5;
    --primary-surface:#ffffff;
    --primary-light: #d6d6d6;
    --primary-active: #2886de;
    --primary-muted: #5c5c5c;
    --primary-danger: #dc626d;
    
    /* Backgrounds */
    --bg-primary: #141414;
    --bg-highlight: #333333;
    --bg-surface: #292929;
    --bg-surface-highlight: var(--bg-highlight);
    --bg-selected: #0c3b5e;
    --bg-danger: #6e0811;
    --bg-attention: #835b00;   /* reuse same orange for attention-requiring items, e.g. unsaved files */

    --border-color: #5c5c5c;
    --border-color-subtle: #383838;

    --shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.6);
}


.roboto {
  font-family: "Roboto", sans-serif;
  font-optical-sizing: auto;
  font-weight: 400;
  font-style: normal;
  font-variation-settings:
    "wdth" 100;
}

/* ============================================
    BASE STYLES
    ============================================ */
body {
    background: var(--bg-primary);
    color: var(--primary);
    font-family: 'Roboto', system-ui, -apple-system, "Segoe UI", "Arial", sans-serif;
    font-weight: 400;
    transition: background-color 0.1s, color 0.1s;
}
.app-container {
    height: 100vh;
    overflow: hidden;
    display: flex;
    background-color: var(--bg-primary);
    color: var(--primary);
}

.workspace-visible {
    display: flex;
}

.workspace-hidden {
    display: none;
}

.is-hidden.login-overlay,
.is-hidden.popup-overlay,
.is-hidden.toast-container,
.is-hidden.workspace-container {
    display: none;
}

button, input, ul, li {
    color: inherit;
}

/* ============================================
    LOGIN OVERLAY
    ============================================ */

.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 149, 128, 0.32), transparent 36%),
        radial-gradient(circle at 80% 30%, rgba(122, 76, 255, 0.30), transparent 40%),
        radial-gradient(circle at 50% 75%, rgba(97, 183, 255, 0.24), transparent 42%),
        linear-gradient(135deg, rgba(23, 19, 38, 0.94) 0%, rgba(31, 26, 56, 0.94) 100%);
}

.login-overlay-container {
    width: 100%;
    max-width: 400px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.93);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(4px);
    padding: 32px;
}

.login-overlay-header h1 {
    color: #181818;
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-overlay-header p {
    color: #5a5a5a;
    font-size: 14px;
    margin-bottom: 22px;
}

.login-overlay-error {
    display: none;
    margin-bottom: 14px;
    font-size: 13px;
    border-radius: 8px;
    background: #ffe8e8;
    color: #8d1f1f;
    padding: 10px 12px;
}

.login-overlay-error.show {
    display: block;
}

.login-overlay-group {
    margin-bottom: 16px;
}

.login-overlay input[type="password"] {
    width: 100%;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 14px;
    outline: none;
    transition: border-color .2s ease;
}

.login-overlay input[type="password"]:focus {
    border-color: #6b5cff;
    box-shadow: 0 0 0 3px rgba(107, 92, 255, 0.14);
}

.login-overlay button[type="submit"] {
    width: 100%;
    justify-content: center;
    border: none;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #6b5cff 0%, #8057f8 100%);
    cursor: pointer;
}

.login-overlay button[type="submit"]:hover {
    color: #fff;
    opacity: 0.94;
}

.login-overlay button[type="submit"]:disabled {
    opacity: 0.65;
    cursor: wait;
}

/* ============================================
    SCROLLBAR STYLES
    ============================================ */
/* Chrome, Edge, Safari */
*::-webkit-scrollbar {
    width: 4px !important;
    height: 4px !important;
}
*::-webkit-scrollbar-track {
    background: transparent !important;
}
*::-webkit-scrollbar-thumb {
    background-color: var(--primary-muted) !important;
    border-radius: 4px !important;
}
*::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-hover) !important;
}
*::-webkit-scrollbar-button {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}
*::-webkit-scrollbar-corner {
    background: transparent !important;
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-muted) transparent;
}

/* ============================================
    ICON AND BUTTON GLOBAL STYLES
    ============================================ */

button {
    /* Reset button styles */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    background: transparent;
    color: inherit;         /* Inherit color from context (button default is not inheritting) */
}
button:hover {
    /* background to set in context */
    color: var(--primary-hover);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.3;
}



.icon {
    /* CRITICAL: References the font loaded in <head> */
    font-family: 'Material Symbols Rounded';
    
    /* Reset text styles so the icon doesn't break */
    font-weight: normal;
    font-style: normal;
    display: inline-block;
    line-height: 1;
    text-transform: none;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;

    /* Your custom settings */
    font-size: 22px;
    --icon-fill: 0;
    font-variation-settings: 'FILL' var(--icon-fill), 'wght' 100, 'GRAD' 100, 'opsz' 24;
}

button:hover > .icon,
.nav-item:hover > .icon,
.tab-item:hover .icon,
.icon.icon-filled,
.icon.active {
    --icon-fill: 1;
}
.icon-sm {
    font-size: 18px;
}
.icon-lg {
    font-size: 28px;
}
.icon-thumb {
    font-size: 42px;
}
.icon-thumb-lg {
    font-size: 56px;
}

input {
    display: block;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    line-height: 1.25rem;
    background-color: transparent;
    transition: all 0.2s;
}

input::placeholder {
    color: var(--primary-muted);
}

input:focus {
    outline: none;
    border-color: var(--primary-hover);
    box-shadow: 0 0 0 1px var(--primary-hover);
}

/* ============================================
    SIDEBAR COMPONENTS
    ============================================ */
.sidebar-container {
    width: 15rem;
    height: 100vh;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
    z-index: 11;
    background-color: transparent;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.2s ease, margin 0.2s ease;
}

/* Collapsed sidebar state */
.sidebar-collapsed .sidebar-container {
    width: 0;
    overflow: hidden;
    margin-left: -1rem;
}

.sidebar-collapsed .main-panel {
    margin-left: 1rem;
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 800px) {
    .sidebar-container {
        position: fixed;
        left: 0;
        top: 0;
        width: 15rem;
        height: 100vh;
        z-index: 11;
        background-color: var(--bg-primary);
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    /* When NOT collapsed on mobile, slide sidebar in */
    html:not(.sidebar-collapsed) .sidebar-container {
        transform: translateX(0);
    }

    /* Backdrop overlay when sidebar is open on mobile */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 10;
    }
    html:not(.sidebar-collapsed) .sidebar-backdrop {
        display: block;
    }

    /* On mobile, start collapsed */
    .sidebar-collapsed .sidebar-container {
        transform: translateX(-100%);
        width: 15rem;        /* keep width for slide animation */
        margin-left: 0;     /* override desktop negative margin */
    }

    /* Cancel the desktop margin compensation on mobile */
    .sidebar-collapsed .main-panel {
        margin-left: 0;
    }
}

.sidebar-header {
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: start;
    padding: 0 1rem;
}

.sidebar-brand {
    letter-spacing: -0.025em;
}

.sidebar-brand-icon {
    color: var(--primary);
    margin-right: 0.5rem;
}

.sidebar-brand-title {
    color: var(--primary);
    font-weight: 600;
}

.sidebar-brand-muted {
    color: var(--primary-muted);
}

.nav-section {
    margin: 1rem 0.5rem 0.5rem 1rem;
    padding: 0;
}

.nav-section-title {
    padding: 0;
    margin: 0 0 0.3rem 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--primary-light);
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    gap: 0.5rem;

    padding: 0.25rem 0.25rem 0.25rem 0.5rem;
    margin-top: 0.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 400;
    letter-spacing: 0.05rem;
    color: var(--primary);
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}
.nav-item:hover {
    background: var(--bg-highlight);
    color: var(--primary-hover);
}

.nav-item .pin-button {
    position: absolute;
    right: 0.5rem;
    opacity: 0;
}
.nav-item:hover .pin-button {
    opacity: 1;
}

.nav-item .menu-expand {
    position: absolute;
    right: 0.5rem;
    --icon-fill: 1;
    opacity: 1;
    cursor: pointer;
}


.nav-submenu {
    display: flex;
    flex-direction: column;
    margin-left: 2rem;
    margin-top: 0.25rem;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
}

.submenu-item {
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.1s;
    font-size: 0.75rem;
    font-weight: 400;
}
.submenu-item:hover {
    background-color: var(--bg-highlight);
}

.nav-section.footer {
    position: relative;
    margin-top: auto;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.nav-section.tree-section {
    display: flex;
    flex-direction: column;
    min-height: 8rem;
    max-height: 60rem;
    overflow: hidden;
}

.nav-section .callout-menu {
    position: absolute;
    bottom: 110%;      /* Place just below the button */
    left: 0;
    min-width: 2rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color-subtle);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    z-index: 15;
    display: none;   /* Hidden by default */
    flex-direction: column;
    padding: 0.2rem;
}

/* Folder Tree */

.folder-tree {
    flex: 1;
    overflow: auto;
    display: block;
}

.folder-tree ul {
    padding: 0 0 0 0.2rem;
    margin: 0 0 0 0.75rem;
    list-style: none; /* Removes duplicate implicit semantics */

    border-left: 1px solid var(--border-color-subtle);
}

/* first <ul> item i.e. the root */
.folder-tree > ul {
    margin: 0;
    border: none;
}

.folder-tree li {
    margin: 0;
    padding: 0;
}

.folder-tree button:hover {
    background-color: var(--bg-highlight);
}

.folder-tree button {
    width: max-content;
    min-width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.1rem;

    font-size: 0.9rem;
    font-weight: 400;
    color: var(--primary-light);
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;

    padding: 0.2rem;
    margin: 0;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    transition: background 0.1s;
    cursor: pointer;
}

.folder-tree span {
    padding: 0;
    margin: 0 0 0 0;
    align-items: start;
}


/* ============================================
    MAIN PANEL AND WORKSPACE LAYOUT
    ============================================ */

.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    position: relative;
    background-color: var(--bg-primary);

    padding: 0;
}

.header-bar {
    height: 3.5rem; 
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    position: relative;
    z-index: 2;
    background-color: transparent;
    padding: 0 0.5rem;
}

.header-bar button:hover {
    background-color: var(--bg-highlight);
}

.searchbox {
    flex: 1;
    max-width: 20rem;
    padding-right: 1rem;
    position: relative;
}

.search-icon-wrapper {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    padding-left: 0.75rem;
    display: flex;
    align-items: center;
    pointer-events: none;
    color: var(--primary-muted);
}

.search-input {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem 0.375rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    line-height: 1.25rem;
    background-color: var(--bg-surface);
    color: var(--primary);
    font-family: inherit;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.search-input::placeholder {
    color: var(--primary-muted);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-hover);
    box-shadow: 0 0 0 1px var(--primary-hover);
}

.search-clear {
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--primary-muted);
    cursor: pointer;
    padding: 0.125rem;
    border-radius: 50%;
    line-height: 1;
}

.search-clear:hover {
    color: var(--primary);
    background-color: var(--bg-highlight);
}

.searchbox.search-active .search-clear {
    display: flex;
}

.searchbox.search-active .search-input {
    padding-right: 2rem;
}

/* Search result path: show tail of path with leading ellipsis */
.search-result-path {
    direction: rtl;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    unicode-bidi: plaintext;
}

.action-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.host-info {
    font-size: 0.75rem;
    color: var(--primary-muted);
    margin-right: 0rem;
}

.divider-v {
    width: 1px;
    height: 0.9rem;
    align-self: center;
    background-color: var(--border-color);
    margin: 0 0.25rem;
}

.theme-toggle {
    color: var(--primary-muted);
}

.workspace-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    position: relative;
    padding: 0.5rem 1.5rem 0 1.5rem;
}

/* Workspace visibility is controlled by JavaScript via inline styles */
/* Initial state set in HTML, toggled by tab-manager.js */

.tool-container {
    flex: 1;
    margin: 1rem 0 0 0;
    padding-top: 2px;

    display: flex;
    flex-direction: column;
    align-items: stretch;
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}


.tool-menu-bar {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 0.25rem;
    overflow: hidden;

    padding: 0 0 0 1rem;
    margin: 0.5rem 0.5rem;

    white-space: nowrap;
}

.tool-content {
    flex: 1;
    background-color: black;
    overflow: auto;

    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* Editor specific */
.editor-content {
    flex: 1;
    min-height: 0; /* Allow flex child to shrink */
    position: relative; /* For Monaco absolute positioning */
}

/* Monaco editor container needs explicit height */
.editor-content > * {
    height: 100%;
}

.editor-status-message {
    min-width: 4rem;
    font-size: 0.75rem;
    color: var(--primary-muted);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.editor-status-message.visible {
    opacity: 1;
}

.editor-status-message[data-type="success"] {
    color: var(--primary-hover);
}

.editor-status-message[data-type="error"] {
    color: var(--primary-danger);
}

/* Breadcrumb Container */
.breadcrumb-bar {
    padding: 0;
    margin: 0 0 0 0;

    display: flex;
    align-items: center;
    justify-content: space-between;
}

.breadcrumb-list {
    display: flex;
    align-items: center;
    gap: 0;
}

.breadcrumb-item {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--primary-light);
    transition: color 0.15s;
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 0.2rem 0.75rem 0.2rem 0.75rem;
}
.breadcrumb-item:hover {
    color: var(--primary);
    text-decoration: underline;
    background-color: var(--bg-highlight);
}
.breadcrumb-current {
    padding-left: 0.25rem;
    color: var(--primary);
}
.breadcrumb-separator {
    color: var(--primary-muted);
}


/* ============================================
    FILE COMPONENTS
    ============================================ */

.surface-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.menu-bar {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 0.25rem;
    overflow: visible;

    padding: 0.5rem 0.5rem;
    margin: 0.75rem 0 0 0;

    white-space: nowrap;
    user-select: none;
}

.leading-block,
.trailing-block {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    overflow: visible;
}

.menu-bar button {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: transparent;
    color: var(--primary);

    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
}
.menu-bar button:hover {
    background: var(--bg-highlight);
    color: var(--primary-hover);
}

.menu-bar button.danger:hover {
    color: var(--primary-danger);
    background-color: var(--bg-danger);
}

/* Callout Menu */
.menu-container {
    position: relative;
    display: inline-block;
}

.callout-menu {
    position: absolute;
    top: 110%;      /* Place just below the button */
    left: 0;
    min-width: 2rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color-subtle);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    z-index: 3;
    display: none;   /* Hidden by default */
    flex-direction: column;
    padding: 0.2rem;
}

/* Show menu when button or menu is clicked/focused */
.menu-container:focus-within .callout-menu {
    display: flex;
}

/* Fallback for iOS Safari where :focus-within is unreliable on tap */
.menu-container.callout-open .callout-menu {
    display: flex;
}

.callout-menu button {
    justify-content: start;
    width: 100%;
    padding: 0.2rem 0.6rem 0.2rem 0.2rem;
    border-radius: var(--radius-sm);
    color: var(--primary-light);
}

.callout-menu button:hover {
    background: var(--bg-highlight);
}

@media (max-width: 800px) {
    .menu-bar button .text {
        display: none !important;
    }
    .menu-bar button {
        gap: 0;
        padding: 0.25rem 0.35rem;
    }
}

/* FILE LIST VIEW */

.file-container {
    flex: 1 1 0%;
    min-height: 0; /* Allow shrinking in flex context */
    margin: 1rem 0 0 0;
    padding-top: 2px;
    user-select: none;

    display: flex;
    flex-direction: column;
}

/* Custom element styling - must fill parent and act as flex container */
file-browser,
file-browser-logic {
    flex: 1 1 0%;
    min-height: 0; /* Critical for nested flex with overflow */
    display: flex;
    flex-direction: column;
}

.file-list-box {
    flex: 1 1 0%;
    min-height: 0; /* Critical: allows flex child to shrink and scroll */
    padding: 1rem 1rem 0.5rem 1rem;

    display: flex;
    flex-direction: column;
    overflow: auto;
}


.list-header,
.list-row {
    /* Sets the consistent grid layout for list headers and rows */
    display: grid;
    grid-template-columns: 2rem 2.5rem minmax(8rem, 40rem) 4rem 7rem;
    gap: 2px;
    align-items: center;
}


.list-header {
    position: sticky;          /* Defines the "floating" behavior relative to its parent scrollbox */
    top: 0px;                  /* Stick to the top of the container (below the parent padding) */
    z-index: 2;
    margin-bottom: 0.3rem;     /* Keep Slight Distance from the File List below it */
    padding: 0.3rem 0.75rem 0.3rem 0.5rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);

    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary-light);
    letter-spacing: 0.05rem;
    text-align: left;
}

.list-header > div,
.list-row > div {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.sort-icon {
    font-size: 15px;
    margin-left: 0.2rem;
}

.list-icon {
    text-align: center;
    justify-content: center;
}
.list-name {
    padding-left: 0.5rem;
    text-overflow: ellipsis;

    display: flex;
    position: relative;
}

.new-item-name {
    padding: 0 4px;
    width: 90%;
    max-width: 12rem;
}

.file-list-box ul {
    padding: 0;
    margin: 0;
    list-style: none; /* Removes default implicit semantics */
}

.list-row {
    position: relative;
    margin-top: 2px;
    padding: 0.3rem 0.5rem 0.3rem 0.5rem;
    border-radius: var(--radius);

    font-size: 0.75rem;
    font-weight: 400;
    color: var(--primary-light);
    text-align: left;
    vertical-align: middle;
    transition: background 0.05s;
    background-image: linear-gradient(to right, transparent 2.75rem, var(--border-color-subtle) 2.75rem);
    background-size: 100% 1px;
    background-repeat: no-repeat;
    background-position: bottom;
}

.list-row .list-name{
    color: var(--primary-surface);
    font-size: 0.875rem;
    font-weight: 500;

    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-all;
    line-height: 1.3;
}

.list-row:hover {
    background-color: var(--bg-surface-highlight);
}
.list-row.selected {
    background-color: var(--bg-selected);
}

/* Suppress Chrome's default focus outline on focusable file items & containers */
.list-row:focus,
.grid-card:focus,
.file-list-box:focus,
.file-grid-box:focus {
    outline: none;
}

/* Cut-pending visual feedback for cut items */
.list-row.cut-pending,
.grid-card.cut-pending {
    opacity: 0.5;
}

.list-row:hover,
.list-row.selected,
.list-row:has(+ .list-row:hover),
.list-row:has(+ .list-row.selected) {
    background-image: none;
}

/* FILE GRID VIEW */

.file-grid-box {
    flex: 1 1 0%;
    min-height: 0; /* Critical: allows flex child to shrink and scroll */
    padding: 0.5rem 0.25rem 0.5rem 0.25rem;

    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    overflow: auto;
    align-items: flex-start;
    align-content: flex-start;
    gap: 0.75rem;
}

.grid-card {
    width: 10rem;
    height: 5rem;
    border-radius: var(--radius-sm);
    background-color: transparent;
    margin: 0;
    padding: 0.25rem 0.25rem 0.25rem 0.25rem;

    display: flex;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    gap: 0.25rem;
    cursor: pointer;
    border: 1px solid transparent;
}

.grid-card:hover {
    background-color: var(--bg-surface-highlight);
    box-shadow: 0 0 0 1px var(--primary-hover);
}


.grid-card .grid-info {
    display: flex;
    flex-direction: column;
    margin: 0 0.25rem 0 0.25rem;
}

.grid-card .grid-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--primary-surface);
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    max-width: 7rem;
    padding: 0.25rem 0 0.25rem 0;
}

.grid-card .grid-metadata {
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--primary-light);
    overflow: hidden;
    white-space: nowrap;
}

.grid-card .grid-icon {
    text-align: center;
    justify-content: center;
    padding: 0.2rem;
}



.grid-card.selected {
    border: 1px solid var(--primary-active);
}

/* THUMBNAIL IMAGE IN LIST AND GRID VIEWS */

.list-thumb-img {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 2px;
}

.grid-thumb-img {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border-radius: 2px;
}

/* FILE THUMB VIEW */

.file-thumb-box {
    flex: 1 1 0%;
    min-height: 0;
    padding: 0.5rem 0.25rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    overflow: auto;
    align-items: flex-start;
    align-content: flex-start;
    gap: 0.75rem;
}

.thumb-card {
    width: 14rem;
    height: 10rem;
    border-radius: var(--radius-sm);
    background-color: var(--bg-surface);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s;
}

.thumb-card:hover {
    box-shadow: 0 0 0 1px var(--primary-hover);
}

.thumb-card.selected {
    border: 2px solid var(--primary-active);
}

.thumb-card.cut-pending {
    opacity: 0.5;
}

.thumb-card:focus,
.file-thumb-box:focus {
    outline: none;
}

.thumb-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.thumb-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-image.thumb-icon-only {
    background-color: var(--bg-surface-highlight);
}

.thumb-name-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.25rem 0.5rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: #fff;
    font-size: 0.8rem;
    font-weight: 500;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.thumb-name-overlay .rename-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid #fff;
    color: #fff;
    font-size: 0.8rem;
    outline: none;
}

.thumb-name-overlay .new-item-name {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid #fff;
    color: #fff;
    font-size: 0.8rem;
    outline: none;
}


/* CHECKBOX STYLES FOR ITEM SELECTION */

.file-container .checkbox {
    --icon-fill: 0;
    color: var(--primary-muted);
    cursor: pointer;
    transition: color 0.15s;
    opacity: 0;
}

.list-checkbox {
    text-align: center;
    justify-content: center;
}

.list-row.selected .checkbox,
.list-header.selected .checkbox,
.grid-card.selected .checkbox {
    opacity: 1;
    --icon-fill: 1;
    color: var(--primary-active);
}

.list-header:hover .checkbox,
.list-row:hover .checkbox,
.grid-card:hover .checkbox {
    opacity: 1;
}

.file-container .checkbox:hover {
    color: var(--primary-hover);
}

.grid-card .checkbox {
    position: absolute;
    bottom: 0.3rem;
    left: 0.3rem;
    opacity: 0;
    transition: opacity 0.1s;
    cursor: pointer;
}

/* Drag and Drop Overlay */
.file-list-box.drag-over,
.file-grid-box.drag-over,
.file-thumb-box.drag-over {
    background: rgba(15, 108, 189, 0.08);
    border: 2px dashed var(--primary-hover);
    border-radius: var(--radius);
}

/* Pin Button for Favorite Items */

.file-container .pin-button {
    --icon-fill: 0;
    color: var(--primary-muted);
    opacity: 0;
    cursor: pointer;
    transition: color 0.15s, opacity 0.1s;
}

.list-name .pin-button {
    position: absolute;
    right: 0.8rem;
}

.grid-card .pin-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

.thumb-card .pin-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

.list-row:hover .pin-button,
.grid-card:hover .pin-button,
.thumb-card:hover .pin-button {
    opacity: 1;
}

.pin-button.pinned {
    --icon-fill: 1;
    color: #fbbf24;
}

.pin-button:hover {
    --icon-fill: 1;
}
.file-container .pin-button.pinned {
    opacity: 1;
}



/* ============================================
    TAB DOCK
    ============================================ */

.tab-dock {
    flex-shrink: 0;
    display: block;
}

.tab-dock-outline {
    display: flex;
    align-items: center;
    justify-content: left;
    gap: 0.5rem;

    padding: 0;
    margin: 1rem 1.5rem 1rem 2.5rem;
}

.tab-item {
    display: flex;
    align-items: center;
    position: relative;
    
    min-height: 1.5rem;
    padding: 0.3rem 0.25rem 0.3rem 0.25rem;
    width: 7rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--primary-light);
    transition: color 0.15s;
    cursor: pointer;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow);
}

.tab-item.active {
    color: var(--primary-active);
}

.tab-item::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-color-subtle);
}

.tab-item:hover {
    background-color: var(--bg-highlight);
}

.tab-item.active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-active);
}

/* The click area of the tab */
.tab-item .tab {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;        /* CRITICAL: allows the text inside to shrink */
    padding: 0 0.5rem 0 0.25rem;
    color: inherit;
    background: transparent;
    border: none;
    cursor: pointer;
}
.tab-item .tab-close {
    font-size: 16px;
    cursor: pointer;

    background: transparent;
    padding: 2px 2px;

    display: none;
}

.tab-item .tab .tab-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
    min-width: 0;
}

.tab-item:hover .tab-close {
    display: block;
    --icon-fill: 0;
    color: var(--primary-hover);
}

/* ============================================
    Popups and Toast Message Boxes
    ============================================ */
/* Use the popup-overlay class for any modal overlays */

/* Overlay backdrop */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.msg-card {
    background: var(--bg-surface);
    width: 20rem;
    padding: 0 0.5rem 0.5rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.msg-card button {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--primary);
    background: var(--bg-highlight);
    border-radius: 0;
    border: 1px solid var(--border-color);
}

.msg-content {
    font-size: 0.9rem;
    color: var(--primary);
    width: 100%;

    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
}

.toast-container {
    position: fixed;
    bottom: 6rem;
    right: 6rem;
    background-color: var(--bg-attention);

    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 1rem;
    z-index: 30;

    width: 15rem;
    max-width: 20rem;
}
.toast-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;

    background-color: transparent;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast-content {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    color: var(--primary-highlight);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.toast-upload {
    flex-wrap: wrap;
}

.toast-upload-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    min-width: 0;
}

.toast-upload .toast-message,
.toast-upload .toast-meta {
    color: var(--primary-highlight);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.toast-upload .toast-meta {
    font-size: 0.7rem;
}

.toast-progress {
    width: 100%;
    height: 3px;
    background-color: var(--primary-muted);
    border-radius: 2px;
    overflow: hidden;
}

.toast-progress-fill {
    width: 0%;
    height: 100%;
    background-color: #16a34a;
    border-radius: 2px;
    transition: width 0.3s ease;
}



/* Sidebar Account Footer */
.sidebar-account {
    gap: 0.5rem;
    margin-top: 0.25rem;
    position: relative;
    user-select: none;
}

.sidebar-account:hover {
    background-color: var(--bg-highlight);
}
.sidebar-account.active {
    background-color: var(--bg-selected);
}

.machine-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-account .expand-icon {
    margin-left: auto;
}

.account-menu {
    position: absolute;
    bottom: 110%;
    left: 0;
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.25rem;
    margin-bottom: 0.5rem;
    display: none; /* Toggled by JS */
    z-index: 15;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--primary);
}

.menu-item:hover {
    background-color: var(--bg-highlight);
    color: var(--primary-hover);
}

.menu-item .check {
    margin-left: auto;
    color: var(--primary-hover);
}

/* ============================================
    MEDIA / PDF VIEWER OVERLAY
    ============================================ */

/* ---- Shared overlay backdrop ---- */
.mv-overlay,
.pv-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Hidden state */
.mv-overlay.is-hidden,
.pv-overlay.is-hidden {
    display: none;
}

/* ---- Control bar (top) ---- */
.mv-control-bar,
.pv-control-bar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    flex-shrink: 0;
    z-index: 2;
}

.mv-filename,
.pv-filename {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 3rem);
}

.mv-close-btn,
.pv-close-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mv-close-btn:hover,
.pv-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ---- Media viewer content area ---- */
.mv-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
    min-height: 0;
}

.mv-media-area {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 90vw;
    max-height: 80vh;
}

.mv-image {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    display: block;
    will-change: transform;
    user-select: none;
}

.mv-video {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    display: block;
    background: #000;
}

.mv-audio {
    min-width: 320px;
    max-width: 90vw;
}

/* ---- Navigation buttons ---- */
.mv-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.45);
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 0.75rem 0.25rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    transition: background 0.15s;
}
.mv-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mv-nav-prev { left: 1rem; }
.mv-nav-next { right: 1rem; }

/* ---- PDF viewer content area ---- */
.pv-content {
    flex: 1;
    width: 100%;
    display: flex;
    min-height: 0;
}

.pv-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}

/* ============================================
    Settings Modal
    ============================================ */

/* Card container */
.settings-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 36rem;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color-subtle);
}

.settings-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
}

.settings-close {
    padding: 0.25rem;
    color: var(--primary-light);
    border: none;
    background: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.settings-close:hover {
    background: var(--bg-highlight);
    color: var(--primary);
}

/* Scrollable list area */
.settings-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Machine row: name + url stacked, delete on right */
.settings-item {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 0.125rem 0.5rem;
    align-items: center;
    padding: 0.375rem 0.75rem;
    background: var(--bg-highlight);
    border: 1px solid var(--border-color-subtle);
    border-radius: var(--radius);
    transition: border-color 0.15s;
}

.settings-item:hover {
    border-color: var(--border-color);
}

.settings-item .settings-input:first-child {
    grid-column: 1;
    grid-row: 1;
    font-weight: 500;
}

.settings-item .settings-input:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
    font-size: 0.8rem;
    color: var(--primary-light);
}

.settings-item .settings-delete {
    grid-column: 2;
    grid-row: 1 / 3;
}

/* Inline inputs */
.settings-input {
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--primary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.5rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.settings-input:focus,
.settings-input:not([readonly]) {
    cursor: text;
    background: var(--bg-surface);
    border-color: var(--border-color);
}

.settings-input::placeholder {
    color: var(--primary-light);
    opacity: 0.6;
}

/* Delete button in row */
.settings-item .settings-delete {
    padding: 0.25rem;
    color: var(--primary-light);
    background: none;
    border: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.settings-item .settings-delete:hover {
    color: var(--error, #ef4444);
    background: var(--bg-highlight);
}

/* Add machine button */
.settings-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    width: 100%;
    padding: 0.5rem;
    font-size: 0.875rem;
    color: var(--primary-light);
    background: none;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.settings-add-btn:hover {
    border-color: var(--primary-light);
    color: var(--primary);
}

/* Footer */
.settings-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-color-subtle);
}




