/**
 * Spreadsheet Styles
 * Excel/Calc look for finance windows
 */

.spreadsheet {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #fff;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    font-size: 11px;
}

/* Toolbar with cell reference and formula bar */
.spreadsheet-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px;
    background: #f0f0f0;
    border-bottom: 1px solid #c0c0c0;
}

.spreadsheet-toolbar .cell-ref {
    background: #fff;
    border: 1px solid #808080;
    padding: 2px 6px;
    min-width: 40px;
    font-family: 'Consolas', monospace;
    font-size: 10px;
}

.spreadsheet-toolbar .formula-bar {
    flex: 1;
    background: #fff;
    border: 1px solid #808080;
    padding: 2px 6px;
    font-family: 'Consolas', monospace;
    font-size: 10px;
    color: #333;
}

/* Main Grid */
.spreadsheet-grid {
    flex: 1;
    overflow-y: auto;
    background: #fff;
}

/* Rows */
.spreadsheet-row {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
}

.spreadsheet-row.header {
    background: #f0f0f0;
    border-bottom: 1px solid #808080;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 1;
}

.spreadsheet-row.section-header {
    background: #e8e8e8;
    border-top: 1px solid #c0c0c0;
}

.spreadsheet-row.highlight {
    background: #ffffcc;
}

.spreadsheet-row.subtotal {
    background: #f8f8f8;
    border-top: 1px solid #c0c0c0;
}

.spreadsheet-row.total {
    border-top: 2px solid #808080;
    border-bottom: 2px solid #808080;
}

.spreadsheet-row.warning {
    background: #fff0f0;
}

/* Cells */
.cell {
    padding: 3px 6px;
    border-right: 1px solid #e0e0e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell.row-num {
    width: 28px;
    min-width: 28px;
    background: #f0f0f0;
    color: #808080;
    text-align: center;
    font-size: 10px;
    border-right: 1px solid #c0c0c0;
}

.cell.cell-header {
    text-align: center;
    color: #333;
    font-size: 10px;
}

.cell.col-a {
    width: 180px;
    min-width: 180px;
}

.cell.col-b {
    width: 100px;
    min-width: 100px;
}

.cell.col-c {
    flex: 1;
    min-width: 100px;
    text-align: right;
}

/* Cell Styles */
.cell.bold {
    font-weight: bold;
}

.cell.light {
    color: #808080;
}

.cell.indent {
    padding-left: 16px;
}

.cell.number {
    font-family: 'Consolas', 'Courier New', monospace;
    text-align: right;
}

.cell.positive {
    color: #008000;
}

.cell.negative {
    color: #cc0000;
}

.cell.large {
    font-size: 13px;
}

.cell.formula {
    font-family: 'Consolas', monospace;
    font-size: 9px;
    color: #0066cc;
    font-style: italic;
}

/* Sheet Tabs */
.spreadsheet-tabs {
    display: flex;
    background: #e0e0e0;
    border-top: 1px solid #808080;
    padding-top: 2px;
}

.spreadsheet-tabs .tab {
    padding: 4px 12px;
    background: #d0d0d0;
    border: 1px solid #808080;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    margin-left: 2px;
    cursor: pointer;
    font-size: 10px;
}

.spreadsheet-tabs .tab:hover:not(.disabled) {
    background: #e8e8e8;
}

.spreadsheet-tabs .tab.active {
    background: #fff;
    border-bottom: 1px solid #fff;
    margin-bottom: -1px;
    font-weight: bold;
}

.spreadsheet-tabs .tab.disabled {
    color: #a0a0a0;
    cursor: default;
}

/* Selection effect on hover */
.spreadsheet-row:not(.header):hover {
    background: #e6f3ff;
}

.spreadsheet-row.highlight:hover {
    background: #ffff99;
}

.spreadsheet-row.subtotal:hover {
    background: #f0f0f0;
}

.spreadsheet-row.total:hover {
    background: #ffff99;
}

/* Table-based spreadsheet (alternative to flex-based) */
table.spreadsheet {
    display: table;
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

table.spreadsheet th,
table.spreadsheet td {
    padding: 3px 4px;
    border-bottom: 1px solid #e0e0e0;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

table.spreadsheet thead th {
    background: #f0f0f0;
    border-bottom: 2px solid #808080;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 1;
}

table.spreadsheet tbody tr:hover {
    background: #e6f3ff;
}

table.spreadsheet tbody tr.selected {
    background: #cce5ff;
}

table.spreadsheet .sortable {
    cursor: pointer;
    user-select: none;
}

table.spreadsheet .sortable:hover {
    background: #e0e0e0;
}

table.spreadsheet .sort-asc::after {
    content: ' ▲';
    font-size: 9px;
}

table.spreadsheet .sort-desc::after {
    content: ' ▼';
    font-size: 9px;
}

/* Chart Bars */
.chart-bar {
    height: 14px;
    border-radius: 2px;
    min-width: 2px;
}

.chart-bar.positive {
    background: linear-gradient(to right, #4caf50, #81c784);
    border: 1px solid #388e3c;
}

.chart-bar.negative {
    background: linear-gradient(to right, #f44336, #e57373);
    border: 1px solid #d32f2f;
}

/* Trend Indicators */
.indicator {
    font-size: 10px;
}

.indicator.positive {
    color: #4caf50;
}

.indicator.neutral {
    color: #ff9800;
}

.indicator.negative {
    color: #f44336;
}
