/* Spreadsheet Modal Styles */

.spreadsheet-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.3s ease-in-out;
}

.spreadsheet-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.spreadsheet-container {
    background: white;
    border-radius: 8px;
    width: 90vw;
    height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.3s ease-out;
}

.spreadsheet-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f5f5f5;
    border-radius: 8px 8px 0 0;
}

.spreadsheet-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
}

.spreadsheet-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 5px 10px;
    transition: color 0.2s;
}

.spreadsheet-close:hover {
    color: #333;
}

.spreadsheet-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    margin: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.spreadsheet-table-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: auto;
}

.spreadsheet-table {
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
    min-width: 100%;
    font-size: 0.875rem;
    position: relative;
}

.spreadsheet-table thead th {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 8px 12px;
    font-weight: 600;
    color: #495057;
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
    user-select: none;
}

.spreadsheet-table thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 11;
    background: #e9ecef;
    box-shadow: 2px 0 4px rgba(0,0,0,0.1);
}

.spreadsheet-table tbody td {
    border: 1px solid #dee2e6;
    padding: 6px 12px;
    background: white;
    min-width: 100px;
    height: 32px;
}

.spreadsheet-table tbody td:first-child {
    position: sticky;
    left: 0;
    background: #f8f9fa;
    font-weight: 500;
    z-index: 9;
    min-width: 120px;
    white-space: nowrap;
    box-shadow: 2px 0 4px rgba(0,0,0,0.1);
}

.spreadsheet-table tbody tr:hover td {
    background-color: #f0f8ff;
}

.spreadsheet-table tbody tr:hover td:first-child {
    background-color: #e1f0ff;
}

/* Totals row styling */
.spreadsheet-totals {
    background-color: #f0f0f0;
    border-top: 2px solid #999;
}

.spreadsheet-totals td {
    background-color: #f0f0f0 !important;
    font-weight: 600;
    border-top: 2px solid #999;
}

.spreadsheet-totals td:first-child {
    background-color: #e0e0e0 !important;
}

.spreadsheet-totals:hover td {
    background-color: #e8e8e8 !important;
}

.spreadsheet-totals:hover td:first-child {
    background-color: #d8d8d8 !important;
}

/* Loading state */
.spreadsheet-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    font-size: 1.1rem;
    color: #666;
}

.spreadsheet-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-left: 10px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Cell selection styles */
.spreadsheet-table tbody td.selectable-cell {
    cursor: pointer;
    user-select: none;
}

.spreadsheet-table tbody td.selected {
    background-color: #b3d9ff !important;
    border: 2px solid #0066cc;
}

.spreadsheet-table tbody td.selected:first-child {
    background-color: #99ccff !important;
}

/* Sum display */
.spreadsheet-sum-display {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 102, 204, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 100;
    pointer-events: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .spreadsheet-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }

    .spreadsheet-header {
        border-radius: 0;
    }

    .spreadsheet-wrapper {
        margin: 10px;
    }
}