/* ═══════════════════════════════════════════════════════════
   Frontend Spreadsheet – Read-only viewer
   ═══════════════════════════════════════════════════════════ */

/* ── Folder spreadsheet button (inside folder header) ───── */
.scp-client-portal .scp-fe-spreadsheet-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    min-width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 6px;
    background: rgba(255,255,255,0.6);
    color: #667085;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    margin: 0;
    /* Attention pulse on page load */
    -webkit-animation: scp-pulse-hint 1.8s ease-in-out 3;
    animation: scp-pulse-hint 1.8s ease-in-out 3;
    -webkit-animation-delay: 0.6s;
    animation-delay: 0.6s;
}
@-webkit-keyframes scp-pulse-hint {
    0%   { box-shadow: 0 0 0 0 rgba(var(--scp-primary-rgb, 0,115,170), 0.7); transform: scale(1); }
    50%  { box-shadow: 0 0 4px 10px rgba(var(--scp-primary-rgb, 0,115,170), 0); transform: scale(1.15); }
    100% { box-shadow: 0 0 0 0 rgba(var(--scp-primary-rgb, 0,115,170), 0); transform: scale(1); }
}
@keyframes scp-pulse-hint {
    0%   { box-shadow: 0 0 0 0 rgba(var(--scp-primary-rgb, 0,115,170), 0.7); transform: scale(1); }
    50%  { box-shadow: 0 0 4px 10px rgba(var(--scp-primary-rgb, 0,115,170), 0); transform: scale(1.15); }
    100% { box-shadow: 0 0 0 0 rgba(var(--scp-primary-rgb, 0,115,170), 0); transform: scale(1); }
}
.scp-client-portal .scp-fe-spreadsheet-btn:hover {
    background: var(--scp-primary-light);
    border-color: var(--scp-primary);
    color: var(--scp-primary);
    -webkit-animation: none;
    animation: none;
}
/* Invisible spacer for root folder alignment */
.scp-client-portal .scp-fe-spacer { visibility: hidden; pointer-events: none; -webkit-animation: none; animation: none; }

/* ── Overlay ──────────────────────────────────────────── */
.scp-fe-ss-overlay {
    position: fixed !important;
    inset: 0 !important;
    z-index: 100001 !important;
    background: rgba(16, 24, 40, 0.55) !important;
    backdrop-filter: blur(4px) !important;
    align-items: stretch !important;
    justify-content: center !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Only apply flex display when modal is visible (not display:none) */
.scp-fe-ss-overlay:not([style*="display: none"]):not([style*="display:none"]) {
    display: flex !important;
}

/* ── Container ────────────────────────────────────────── */
.scp-fe-ss-container {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    background: #fff !important;
    border-radius: 0 !important;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2) !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif !important;
    font-style: normal !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}
.scp-fe-ss-container *,
.scp-fe-ss-container *::before,
.scp-fe-ss-container *::after {
    font-family: inherit !important;
    font-style: normal !important;
    text-transform: none !important;
}

/* ── Top bar ──────────────────────────────────────────── */
.scp-fe-ss-topbar {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 14px 24px !important;
    border-bottom: 1px solid #e4e7ec !important;
    background: #eef4fb !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    gap: 2px !important;
}
.scp-fe-ss-topbar-top {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    gap: 12px !important;
}
.scp-fe-ss-topbar-left {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex: 1 !important;
    min-width: 0 !important;
}
.scp-fe-ss-topbar-right {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex: 0 0 auto !important;
}
.scp-fe-ss-topbar-icon { color: var(--scp-primary); flex-shrink: 0; }
.scp-fe-ss-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
    line-height: 1.3;
}
.scp-fe-ss-folder-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 500;
    color: #344054;
    background: #eef2f7;
    border-radius: 20px;
}
.scp-fe-ss-topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Buttons ──────────────────────────────────────────── */
.scp-fe-ss-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    padding: 8px 16px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    border-radius: 8px !important;
    border: 1px solid transparent !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    line-height: 1 !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0) !important;
}
.scp-fe-ss-btn--ghost {
    background: transparent !important;
    color: #667085 !important;
    border-color: #d0d5dd !important;
    padding: 6px !important;
    min-width: 32px !important;
    min-height: 32px !important;
}
.scp-fe-ss-btn--ghost:hover { 
    background: #f2f4f7 !important; 
    color: #344054 !important;
    border-color: #d0d5dd !important;
}
#scp-fe-ss-close-btn { 
    background: #fef3f2 !important; 
    color: #b42318 !important; 
    border-color: #fecdca !important; 
}
#scp-fe-ss-close-btn:hover { 
    background: #fee4e2 !important; 
    border-color: #fda29b !important; 
}
.scp-fe-ss-last-edited {
    font-size: 11px;
    color: #8c8f94;
    width: 100% !important;
    padding-left: 30px !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    margin-top: 2px !important;
}

/* ── Table wrapper ────────────────────────────────────── */
.scp-fe-ss-table-wrap {
    flex: 1;
    overflow: auto;
    position: relative;
    background: #f9fafb;
    padding: 0 16px;
}

/* ── Loading state ────────────────────────────────────── */
.scp-fe-ss-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    color: #667085;
    font-size: 14px;
}
.scp-fe-ss-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e4e7ec;
    border-top-color: var(--scp-primary);
    border-radius: 50%;
    animation: scp-fe-ss-spin 0.7s linear infinite;
}
@keyframes scp-fe-ss-spin { to { transform: rotate(360deg); } }

/* ── Table ────────────────────────────────────────────── */
.scp-fe-ss-table,
.scp-fe-ss-table * {
    box-sizing: border-box !important;
}
.scp-fe-ss-table {
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    table-layout: fixed !important;
    width: max-content !important;
}
.scp-fe-ss-table-wrap--auto .scp-fe-ss-table {
    table-layout: auto !important;
    width: max-content !important;
    min-width: 100% !important;
}
.scp-fe-ss-table-wrap--auto .scp-fe-ss-cell,
.scp-fe-ss-table-wrap--auto .scp-fe-ss-col-name {
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    width: max-content !important;
}
.scp-fe-ss-table th,
.scp-fe-ss-table td {
    border: 1px solid #e4e7ec !important;
    padding: 0 !important;
    vertical-align: middle;
    position: relative;
    min-width: 50px;
}
.scp-fe-ss-table td:not(.scp-fe-ss-rownum) {
    background: #fff !important;
}
.scp-fe-ss-table th.scp-fe-ss-rownum,
.scp-fe-ss-table td.scp-fe-ss-rownum { min-width: auto; }

/* Row number column */
.scp-fe-ss-table .scp-fe-ss-rownum {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: #98a2b3;
    background: #f2f4f7;
    user-select: none;
    cursor: default;
    padding: 1px 4px !important;
    line-height: 16px !important;
}

/* Column headers */
.scp-fe-ss-table thead th {
    background: #eef4fb;
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 8px solid #f9fafb !important;
}
.scp-fe-ss-col-name {
    display: block;
    width: 100%;
    font-size: 12px;
    font-weight: 600;
    color: #344054;
    padding: 1px 10px !important;
    min-height: 16px !important;
    line-height: 16px !important;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Data cells */
.scp-fe-ss-cell {
    display: block;
    width: 100%;
    font-size: 12px;
    color: #1d2327;
    padding: 1px 10px !important;
    min-height: 16px !important;
    line-height: 16px !important;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #fff;
}
.scp-fe-ss-link {
    color: #1570ef !important;
    text-decoration: underline !important;
}
.scp-fe-ss-link:hover {
    color: #175cd3 !important;
}

/* Hover row highlight */
.scp-fe-ss-table tbody tr:hover td:not(.scp-fe-ss-rownum) {
    background: var(--scp-primary-light);
}

/* ── Tab bar (bottom) ─────────────────────────────────── */
.scp-fe-ss-tabs-bar {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0 24px;
    border-top: 1px solid #e4e7ec;
    background: #f9fafb;
    flex-shrink: 0;
    height: 42px;
    overflow-x: auto;
}
.scp-fe-ss-tabs {
    display: flex;
    align-items: stretch;
    gap: 0;
    height: 100%;
}
.scp-fe-ss-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    font-size: 12px;
    font-weight: 500;
    color: #667085;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    height: 100%;
    position: relative;
}
.scp-fe-ss-tab:hover { color: #344054; background: #f2f4f7; }
.scp-fe-ss-tab.active {
    color: var(--scp-primary);
    background: #fff;
    font-weight: 600;
    border-bottom: 2px solid var(--scp-primary);
}
.scp-fe-ss-tab.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--scp-primary);
    border-radius: 3px 3px 0 0;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 1024px) {
    .scp-fe-ss-overlay { 
        padding: 0 !important; 
    }
    .scp-fe-ss-container { 
        border-radius: 0 !important; 
        width: 100vw !important; 
        height: 100vh !important; 
        height: 100dvh !important;
        max-width: none !important;
    }
    .scp-fe-ss-topbar { padding: 10px 14px; flex-wrap: nowrap; gap: 8px; justify-content: space-between; }
    .scp-fe-ss-tabs-bar { padding: 0 14px; }

    /* Title and buttons on same line */
    .scp-fe-ss-topbar-left { 
        flex: 1; 
        min-width: 0; 
    }
    .scp-fe-ss-topbar-right {
        flex: 0 0 auto;
        gap: 6px;
    }

    /* Compact cells */
    body .scp-fe-ss-table {
        width: max-content !important;
        table-layout: fixed !important;
        border-collapse: collapse !important;
        border-spacing: 0 !important;
    }
    body .scp-fe-ss-table tr,
    body .scp-fe-ss-table th,
    body .scp-fe-ss-table td {
        height: 24px !important;
        min-height: 0 !important;
        padding: 0 !important;
    }
    body .scp-fe-ss-table th,
    body .scp-fe-ss-table td {
        min-width: 50px !important;
        width: 130px !important;
    }
    body .scp-fe-ss-col-name,
    body .scp-fe-ss-cell {
        padding: 0 4px !important;
        font-size: 11px !important;
        height: 24px !important;
        min-height: 0 !important;
        line-height: 24px !important;
        margin: 0 !important;
        border: none !important;
        box-sizing: border-box !important;
        outline: none !important;
        background: transparent !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }
    body .scp-fe-ss-table .scp-fe-ss-rownum {
        width: 28px !important;
        min-width: 28px !important;
        max-width: 28px !important;
        padding: 0 !important;
        font-size: 10px !important;
        height: 24px !important;
        min-height: 0 !important;
        line-height: 24px !important;
    }
}

/* ── Elementor Compatibility ──────────────────────────── */
.elementor-widget-container .scp-fe-ss-btn,
.elementor .scp-fe-ss-btn {
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
}

.elementor-widget-container .scp-fe-ss-btn--ghost,
.elementor .scp-fe-ss-btn--ghost {
    min-width: 32px !important;
    min-height: 32px !important;
}

/* Ensure modal overlay works correctly in Elementor */
.elementor-widget-container .scp-fe-ss-overlay,
.elementor .scp-fe-ss-overlay {
    position: fixed !important;
    inset: 0 !important;
    z-index: 100001 !important;
    align-items: stretch !important;
    justify-content: center !important;
}

/* Only show when not hidden */
.elementor-widget-container .scp-fe-ss-overlay:not([style*="display: none"]):not([style*="display:none"]),
.elementor .scp-fe-ss-overlay:not([style*="display: none"]):not([style*="display:none"]) {
    display: flex !important;
}

.elementor-widget-container .scp-fe-ss-container,
.elementor .scp-fe-ss-container {
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
}

.elementor-widget-container .scp-fe-ss-topbar,
.elementor .scp-fe-ss-topbar,
body .scp-fe-ss-topbar {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    box-sizing: border-box !important;
    gap: 16px !important;
    padding: 14px 24px !important;
    margin: 0 !important;
    min-height: 0 !important;
    max-height: none !important;
    height: auto !important;
    border-bottom: 1px solid #e4e7ec !important;
    background: #eef4fb !important;
    flex-shrink: 0 !important;
}

/* Force children of the topbar to have no extra margins/padding from Elementor/theme */
.elementor-widget-container .scp-fe-ss-topbar > *,
.elementor .scp-fe-ss-topbar > *,
body .scp-fe-ss-topbar > * {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.elementor-widget-container .scp-fe-ss-topbar-left,
.elementor .scp-fe-ss-topbar-left,
.elementor-widget-container .scp-fe-ss-topbar-right,
.elementor .scp-fe-ss-topbar-right,
body .scp-fe-ss-topbar-left,
body .scp-fe-ss-topbar-right {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
}

/* Reset heading styles inside the datasheet modal - Hello Elementor adds margins to h3 */
.elementor-widget-container .scp-fe-ss-title,
.elementor .scp-fe-ss-title,
body .scp-fe-ss-title {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #1d2327 !important;
    line-height: 1.3 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    font-family: inherit !important;
}

.elementor-widget-container .scp-fe-ss-folder-badge,
.elementor .scp-fe-ss-folder-badge,
body .scp-fe-ss-folder-badge {
    display: inline-flex !important;
    align-items: center !important;
    padding: 3px 10px !important;
    margin: 0 !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    line-height: 1 !important;
    color: #344054 !important;
    background: #eef2f7 !important;
    border-radius: 20px !important;
}

/* Reset ghost buttons in the topbar */
.elementor-widget-container .scp-fe-ss-btn,
.elementor .scp-fe-ss-btn,
body .scp-fe-ss-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    margin: 0 !important;
    line-height: 1 !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    font-family: inherit !important;
    letter-spacing: normal !important;
    text-transform: none !important;
}

.elementor-widget-container .scp-fe-ss-btn--ghost,
.elementor .scp-fe-ss-btn--ghost,
body .scp-fe-ss-btn--ghost {
    padding: 6px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
    height: 32px !important;
    width: 32px !important;
    background: transparent !important;
    color: #667085 !important;
    border: 1px solid #d0d5dd !important;
    border-radius: 8px !important;
}
