/* =============================================================================
   Sheets Panel — scoped under .sheets-app
   Microsoft Backstage-inspired: File tab → slide-out, thin title bar in editor
   ============================================================================= */

.sheets-app {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--color-text-primary, #c8c8c8);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    font-size: 13px;
}

.sheets-app .sh-shell {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    position: relative;
}

/* =============================================================================
   Title Bar (thin bar above editor — always visible)
   ============================================================================= */

.sheets-app .sh-titlebar {
    display: flex;
    align-items: center;
    height: 36px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--color-border-dim, rgba(255,255,255,0.06));
    background: var(--color-bg-secondary, #21252b);
    z-index: 10;
}

/* File tab — the green accent button */
.sheets-app .sh-file-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 0 16px;
    background: #217346;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: background 0.15s;
    flex-shrink: 0;
}

.sheets-app .sh-file-tab:hover {
    background: #1a5c38;
}

.sheets-app .sh-file-tab.sh-active {
    background: #185a34;
}

/* Title area — filename + dirty state */
.sheets-app .sh-title-center {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    min-width: 0;
}

.sheets-app .sh-title-filename {
    font-size: 13px;
    color: var(--color-text-primary, #c8c8c8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.sheets-app .sh-title-nofile {
    font-size: 12px;
    color: var(--color-text-muted, rgba(255,255,255,0.35));
    font-style: italic;
}

.sheets-app .sh-dirty-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f59e0b;
    flex-shrink: 0;
}

/* Quick-action icon buttons in title bar */
.sheets-app .sh-title-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    padding-right: 8px;
    flex-shrink: 0;
}

.sheets-app .sh-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 28px;
    background: none;
    border: none;
    border-radius: 3px;
    color: var(--color-text-secondary, rgba(255,255,255,0.5));
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    font-family: inherit;
    padding: 0;
}

.sheets-app .sh-icon-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--color-text-primary, #c8c8c8);
}

.sheets-app .sh-icon-btn.sh-save-dirty {
    color: #4ade80;
}

.sheets-app .sh-icon-btn.sh-save-dirty:hover {
    background: rgba(74, 222, 128, 0.12);
    color: #4ade80;
}

.sheets-app .sh-icon-btn svg {
    width: 16px;
    height: 16px;
}

.sheets-app .sh-icon-sep {
    width: 1px;
    height: 18px;
    background: var(--color-border-dim, rgba(255,255,255,0.08));
    margin: 0 4px;
    flex-shrink: 0;
}

/* Save flash */
.sheets-app .sh-save-flash {
    font-size: 11px;
    color: #4ade80;
    padding-right: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}

.sheets-app .sh-save-flash.sh-visible {
    opacity: 1;
}

/* =============================================================================
   Backstage Panel — slides over the body from the left
   ============================================================================= */

.sheets-app .sh-backstage {
    position: absolute;
    top: 36px;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    background: var(--color-bg-primary, #282c34);
    z-index: 20;
    transform: translateX(-100%);
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
    pointer-events: none;
}

.sheets-app .sh-backstage.sh-open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

/* Backstage sidebar — action list */
.sheets-app .sh-bs-sidebar {
    width: 210px;
    flex-shrink: 0;
    background: var(--color-bg-secondary, #21252b);
    border-right: 1px solid var(--color-border-dim, rgba(255,255,255,0.06));
    display: flex;
    flex-direction: column;
    padding: 6px 0;
}

.sheets-app .sh-bs-action {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 22px;
    color: var(--color-text-secondary, rgba(255,255,255,0.6));
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    background: none;
    border: none;
    border-left: 3px solid transparent;
    text-align: left;
    width: 100%;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.sheets-app .sh-bs-action:hover {
    background: rgba(255,255,255,0.05);
    color: var(--color-text-primary, #c8c8c8);
}

.sheets-app .sh-bs-action.sh-active {
    background: rgba(33, 115, 70, 0.12);
    color: #fff;
    border-left-color: #217346;
}

.sheets-app .sh-bs-action.sh-disabled {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.sheets-app .sh-bs-action svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.6;
}

.sheets-app .sh-bs-action:hover svg,
.sheets-app .sh-bs-action.sh-active svg {
    opacity: 1;
}

.sheets-app .sh-bs-sep {
    height: 1px;
    background: var(--color-border-dim, rgba(255,255,255,0.06));
    margin: 4px 18px;
}

.sheets-app .sh-bs-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-muted, rgba(255,255,255,0.25));
    padding: 10px 22px 6px;
}

/* Backstage content area */
.sheets-app .sh-bs-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Backstage content body (scrollable area — both axes) */
.sheets-app .sh-bs-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

/* Backstage header (breadcrumbs in file browser) */
.sheets-app .sh-bs-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--color-border-dim, rgba(255,255,255,0.06));
    flex-shrink: 0;
    min-height: 44px;
}

.sheets-app .sh-bs-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: none;
    border: 1px solid var(--color-border-dim, rgba(255,255,255,0.1));
    border-radius: 4px;
    color: var(--color-text-secondary, rgba(255,255,255,0.5));
    cursor: pointer;
    font-size: 14px;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
    padding: 0;
}

.sheets-app .sh-bs-back-btn:hover {
    background: rgba(255,255,255,0.07);
    color: var(--color-text-primary, #c8c8c8);
}

.sheets-app .sh-bs-header-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary, #c8c8c8);
}

/* Breadcrumbs */
.sheets-app .sh-breadcrumb {
    font-size: 12px;
    color: var(--color-text-muted, rgba(255,255,255,0.4));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.sheets-app .sh-breadcrumb-link {
    cursor: pointer;
    color: var(--color-text-secondary, rgba(255,255,255,0.55));
    transition: color 0.12s;
}

.sheets-app .sh-breadcrumb-link:hover {
    color: #4a9eff;
}

.sheets-app .sh-breadcrumb-sep {
    color: var(--color-text-muted, rgba(255,255,255,0.25));
    margin: 0 4px;
}

/* =============================================================================
   File Browser (inside backstage content)
   ============================================================================= */

.sheets-app .sh-file-view {
    min-height: 0;
}

.sheets-app .sh-file-list {
    padding: 4px 0;
    width: max-content;
    min-width: 100%;
}

.sheets-app .sh-file-item {
    display: flex;
    align-items: center;
    padding: 10px 24px;
    gap: 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border-dim, rgba(255,255,255,0.03));
    transition: background 0.1s;
}

.sheets-app .sh-file-item:hover {
    background: rgba(255,255,255,0.04);
}

.sheets-app .sh-file-icon {
    flex-shrink: 0;
    color: var(--color-text-muted, rgba(255,255,255,0.4));
    display: flex;
    align-items: center;
}

.sheets-app .sh-file-info {
    flex: 0 0 auto;
}

.sheets-app .sh-file-name {
    font-size: 13px;
    color: var(--color-text-primary, #c8c8c8);
    white-space: nowrap;
}

.sheets-app .sh-file-detail {
    font-size: 11px;
    color: var(--color-text-muted, rgba(255,255,255,0.35));
    margin-top: 2px;
}

/* =============================================================================
   Body (editor iframe, behind backstage)
   ============================================================================= */

.sheets-app .sh-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

.sheets-app .sh-editor-frame {
    flex: 1;
    min-height: 0;
    border: none;
    width: 100%;
}

/* =============================================================================
   Loading / Empty
   ============================================================================= */

.sheets-app .sh-loading,
.sheets-app .sh-empty {
    padding: 3rem 2rem;
    text-align: center;
    color: var(--color-text-muted, rgba(255,255,255,0.4));
    font-size: 13px;
}

/* Loading overlay (shown while Univer editor initializes) */
.sheets-app .sh-loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: var(--color-bg-primary, #1e1e1e);
    z-index: 5;
}

.sheets-app .sh-loading-spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--color-border-dim, rgba(255,255,255,0.1));
    border-top-color: #217346;
    border-radius: 50%;
    animation: sh-spin 0.8s linear infinite;
}

@keyframes sh-spin {
    to { transform: rotate(360deg); }
}

.sheets-app .sh-loading-text {
    color: var(--color-text-muted, rgba(255,255,255,0.4));
    font-size: 13px;
}

.sheets-app .sh-loading-dots::after {
    content: '';
    animation: sh-dots 1.5s steps(4, end) infinite;
}

@keyframes sh-dots {
    0%  { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

.sheets-app .sh-muted {
    color: var(--color-text-muted, rgba(255,255,255,0.3));
    font-size: 12px;
}

/* =============================================================================
   Welcome / No file open (shown in body when no file loaded)
   ============================================================================= */

.sheets-app .sh-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--color-text-muted, rgba(255,255,255,0.3));
}

.sheets-app .sh-welcome svg {
    opacity: 0.15;
}

.sheets-app .sh-welcome-text {
    font-size: 13px;
}

.sheets-app .sh-welcome-hint {
    font-size: 12px;
    color: var(--color-text-muted, rgba(255,255,255,0.2));
}

/* =============================================================================
   Upload area inside backstage
   ============================================================================= */

.sheets-app .sh-upload-area {
    margin: 24px;
    padding: 48px 24px;
    border: 2px dashed rgba(255,255,255,0.15);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.sheets-app .sh-upload-area:hover {
    border-color: rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.03);
}

.sheets-app .sh-upload-area.sh-dragover {
    border-color: #217346;
    background: rgba(33, 115, 70, 0.1);
}

.sheets-app .sh-upload-icon {
    color: var(--color-text-muted, rgba(255,255,255,0.3));
    margin-bottom: 10px;
}

.sheets-app .sh-upload-text {
    font-size: 13px;
    color: var(--color-text-secondary, rgba(255,255,255,0.55));
}

.sheets-app .sh-upload-hint {
    font-size: 11px;
    color: var(--color-text-muted, rgba(255,255,255,0.3));
    margin-top: 6px;
}

/* Hidden file input */
.sheets-app .sh-upload-input {
    display: none;
}

/* =============================================================================
   Mobile: backstage sidebar → horizontal scrollable strip
   ============================================================================= */

@media (max-width: 600px) {
    /* Slim sidebar: icons only */
    .sheets-app .sh-bs-sidebar {
        width: 44px;
        padding: 4px 0;
    }

    .sheets-app .sh-bs-label {
        display: none;
    }

    .sheets-app .sh-bs-action {
        justify-content: center;
        padding: 10px 0;
        gap: 0;
    }

    .sheets-app .sh-bs-action span {
        display: none;
    }

    .sheets-app .sh-bs-action svg {
        width: 18px;
        height: 18px;
    }

    .sheets-app .sh-bs-sep {
        margin: 2px 8px;
    }

    /* File items: tighter padding */
    .sheets-app .sh-file-item {
        padding: 10px 14px;
    }

    /* Header: tighter */
    .sheets-app .sh-bs-header {
        padding: 10px 14px;
        min-height: 36px;
    }

    /* Upload area: less margin */
    .sheets-app .sh-upload-area {
        margin: 14px;
        padding: 28px 14px;
    }

    /* Content area scrolls horizontally if needed */
    .sheets-app .sh-bs-content {
        min-width: 0;
    }

    .sheets-app .sh-file-name {
        font-size: 13px;
    }
}
