/**
 * SpreadsheetGrid Component Styles
 */

.sg-wrapper {
    background: var(--ma-card, #fff);
    border: 1px solid var(--ma-border, #e2e8f0);
    border-radius: var(--ma-radius, 8px);
    box-shadow: var(--ma-shadow, 0 1px 3px rgba(0,0,0,0.08));
    overflow: hidden;
}

.sg-title {
    padding: 0.75rem 1rem;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--ma-text, #1e293b);
    border-bottom: 1px solid var(--ma-border, #e2e8f0);
    background: var(--ma-border-light, #f1f5f9);
}

.sg-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.75rem;
    background: var(--ma-border-light, #f1f5f9);
    border-bottom: 1px solid var(--ma-border, #e2e8f0);
    gap: 8px;
}

.sg-btn {
    padding: 3px 10px;
    border: 1px solid var(--ma-border, #e2e8f0);
    border-radius: 4px;
    background: var(--ma-card, #fff);
    color: var(--ma-text-secondary, #64748b);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.sg-btn:hover {
    background: var(--ma-primary-bg, #eff6ff);
    border-color: var(--ma-primary-light, #3b82f6);
    color: var(--ma-primary, #1e40af);
}

.sg-btn-add { color: var(--ma-success, #10b981); }

/* Table */
.sg-table-container {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 600px;
}

.sg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    table-layout: fixed;
}

.sg-th {
    padding: 0.5rem 0.6rem;
    text-align: left;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--ma-text-secondary, #64748b);
    background: var(--ma-border-light, #f1f5f9);
    border-bottom: 2px solid var(--ma-border, #e2e8f0);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}

.sg-th-unit {
    font-weight: 500;
    font-size: 10px;
    color: var(--ma-text-muted, #94a3b8);
    text-transform: none;
}

.sg-row-num {
    width: 36px;
    min-width: 36px;
    text-align: center;
    color: var(--ma-text-muted, #94a3b8);
    font-size: 10px;
    background: var(--ma-border-light, #f1f5f9);
}

.sg-td {
    padding: 0.35rem 0.6rem;
    border-bottom: 1px solid var(--ma-border-light, #f1f5f9);
    color: var(--ma-text, #1e293b);
    font-variant-numeric: tabular-nums;
    position: relative;
    height: 30px;
    vertical-align: middle;
}

.sg-bold .sg-cell-display { font-weight: 700; }

.sg-frozen {
    position: sticky;
    left: 0;
    z-index: 1;
    background: inherit;
}

.sg-action-col {
    width: 32px;
    min-width: 32px;
    text-align: center;
}

/* Row Styles */
.sg-row:hover { background: var(--ma-primary-bg, #eff6ff); }

.sg-row-header {
    background: var(--ma-border-light, #f1f5f9);
}

.sg-row-header:hover { background: #e8edf3; }

.sg-row-subtotal {
    background: #fafbfd;
    border-top: 1px solid var(--ma-border, #e2e8f0);
}

.sg-row-total {
    background: var(--ma-border-light, #f1f5f9);
    border-top: 2px solid var(--ma-border, #e2e8f0);
}

.sg-row-total .sg-td {
    border-bottom: 2px solid var(--ma-border, #e2e8f0);
    font-weight: 700;
}

.sg-row-formula .sg-td {
    color: var(--ma-primary, #1e40af);
    font-style: italic;
}

/* Highlight */
.sg-highlight-green .sg-td { background: rgba(16, 185, 129, 0.05); }
.sg-highlight-red .sg-td { background: rgba(239, 68, 68, 0.05); }
.sg-highlight-blue .sg-td { background: rgba(59, 130, 246, 0.05); }
.sg-highlight-yellow .sg-td { background: rgba(245, 158, 11, 0.05); }

/* Editable Cell */
.sg-editable {
    cursor: text;
}

.sg-editable:hover {
    background: rgba(59, 130, 246, 0.06);
}

.sg-cell-input {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border: 2px solid var(--ma-primary-light, #3b82f6);
    border-radius: 0;
    padding: 0.3rem 0.5rem;
    font-size: 12px;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    background: #fff;
    color: var(--ma-text, #1e293b);
    box-sizing: border-box;
    outline: none;
    z-index: 3;
}

.sg-editing .sg-cell-display { visibility: hidden; }
.sg-editing .sg-cell-input { display: block; }

.sg-empty {
    color: var(--ma-text-muted, #94a3b8);
}

/* Delete button */
.sg-btn-del {
    background: none;
    border: none;
    color: var(--ma-text-muted, #94a3b8);
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.sg-row:hover .sg-btn-del { opacity: 1; }
.sg-btn-del:hover { color: var(--ma-danger, #ef4444); }

/* Responsive */
@media (max-width: 768px) {
    .sg-table { font-size: 11px; }
    .sg-th, .sg-td { padding: 0.25rem 0.4rem; }
}
