/* ================================================================
   Excel Viewer — Stylesheet
   ================================================================ */

/* Google Fonts: Calibri is not on Google Fonts, but we load a
   system-font stack that includes Calibri where available, and
   fall back to Carlito (a metric-equivalent open font). */
@import url('https://fonts.googleapis.com/css2?family=Carlito:ital,wght@0,400;0,700;1,400;1,700&display=swap');

/* ── Wrapper — full-bleed landscape ── */
.ev-wrap {
    --ev-accent:    #217346;   /* Excel green */
    --ev-border:    #d0d0d0;
    --ev-toolbar-bg:#f3f3f3;
    --ev-btn-bg:    #217346;
    --ev-btn-text:  #fff;
    --ev-radius:    6px;
    font-family: Calibri, Carlito, 'Calibri', sans-serif;
    font-size: 12pt;
    box-sizing: border-box;
    color: #222;

    /* Break out of the theme's content column and stretch to the viewport */
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left:  -50vw;
    margin-right: -50vw;
    padding-left:  16px;
    padding-right: 16px;
}

.ev-wrap *, .ev-wrap *::before, .ev-wrap *::after {
    box-sizing: inherit;
}

/* ── Upload / drop zone ── */
.ev-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 24px;
    border: 2px dashed var(--ev-border);
    border-radius: var(--ev-radius);
    background: #fafafa;
    text-align: center;
    transition: border-color .2s, background .2s;
    cursor: pointer;
}

.ev-upload-area.ev-drag-over {
    border-color: var(--ev-accent);
    background: #eaf4ee;
}

.ev-upload-icon {
    width: 48px;
    height: 48px;
    color: var(--ev-accent);
}

.ev-hint {
    font-size: 0.85em;
    color: #888;
    margin: 0;
}

/* ── Buttons ── */
.ev-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: var(--ev-btn-bg);
    color: var(--ev-btn-text);
    border: none;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9em;
    cursor: pointer;
    transition: background .15s;
    text-decoration: none;
    white-space: nowrap;
}
.ev-btn:hover { background: #1a5c38; }

.ev-btn-small {
    padding: 5px 12px;
    font-size: 0.82em;
}

.ev-btn-ghost {
    background: transparent;
    color: #555;
    border: 1px solid var(--ev-border);
}
.ev-btn-ghost:hover { background: #eee; }

/* ── Toolbar ── */
.ev-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    background: var(--ev-toolbar-bg);
    border: 1px solid var(--ev-border);
    border-bottom: none;
    border-radius: var(--ev-radius) var(--ev-radius) 0 0;
}

.ev-toolbar-left, .ev-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ev-filename {
    font-weight: 700;
    font-size: 0.9em;
    color: #333;
}

/* ── Sheet tabs ── */
.ev-sheet-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.ev-tab {
    padding: 3px 12px;
    border: 1px solid var(--ev-border);
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    background: #e8e8e8;
    cursor: pointer;
    font-size: 0.82em;
    color: #444;
    transition: background .15s;
    white-space: nowrap;
}

.ev-tab:hover { background: #d4d4d4; }

.ev-tab.ev-tab-active {
    background: #fff;
    color: var(--ev-accent);
    font-weight: 700;
    border-bottom-color: #fff;
}

/* ── Sheet scroll area ── */
.ev-sheet-container {
    border: 1px solid var(--ev-border);
    border-radius: 0 0 var(--ev-radius) var(--ev-radius);
    overflow: hidden;
    background: #fff;
}

.ev-sheet-scroll {
    width: 100%;
    height: 100%;
    overflow: auto;
    padding: 0;
    background: #fff;
}

/* ── The rendered table ── */
#ev-sheet-render {
    padding: 4px;
}

#ev-sheet-render table {
    border-collapse: collapse;
    table-layout: fixed;
    font-family: Calibri, Carlito, sans-serif;
    font-size: 12pt;
    empty-cells: show;
    /* Width set dynamically by JS */
}

#ev-sheet-render td,
#ev-sheet-render th {
    padding: 2px 4px;
    overflow: hidden;
    white-space: pre;          /* preserve spaces */
    vertical-align: bottom;
    min-width: 24px;
    position: relative;
    /* Individual cell styles injected via inline style by JS */
}

/* Editable cells */
#ev-sheet-render td[contenteditable="true"]:focus {
    outline: 2px solid var(--ev-accent);
    outline-offset: -2px;
    background: #f0f8f4 !important;
    z-index: 2;
    white-space: pre;
}

/* Row/col headers */
.ev-row-header, .ev-col-header {
    background: #f2f2f2 !important;
    color: #666;
    font-size: 10pt;
    font-weight: 400;
    text-align: center;
    user-select: none;
    border: 1px solid #d8d8d8 !important;
    min-width: 36px;
    width: 36px;
    position: sticky;
}
.ev-col-header { top: 0; z-index: 3; }
.ev-row-header { left: 0; z-index: 2; }
.ev-corner-header { top: 0; left: 0; z-index: 4; }

/* ── Status ── */
.ev-status {
    margin-top: 8px;
    font-size: 0.85em;
    min-height: 1.4em;
    color: #666;
}

.ev-status.ev-error { color: #c0392b; }
.ev-status.ev-ok    { color: var(--ev-accent); }

/* ── Loading spinner ── */
.ev-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid #ccc;
    border-top-color: var(--ev-accent);
    border-radius: 50%;
    animation: ev-spin .7s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

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