/**
 * Excel Simulator Styles
 * 
 * Provides styling for the Excel-like interface
 */

.excel-simulator-wrapper {
    width: 100%;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Toolbar */
.excel-toolbar {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    gap: 8px;
}

.excel-btn {
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.excel-btn:hover {
    background: #e9e9e9;
    border-color: #999;
}

.excel-btn:active {
    transform: translateY(1px);
}

.excel-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.excel-status {
    margin-left: auto;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 3px;
}

.excel-status.info {
    color: #0073aa;
}

.excel-status.success {
    color: #46b450;
    background: #ecf7ed;
}

.excel-status.error {
    color: #dc3232;
    background: #fbeaea;
}

/* Formula Bar */
.excel-formula-container {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: #fafafa;
    border-bottom: 1px solid #ddd;
    gap: 12px;
}

.cell-reference {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #555;
    min-width: 50px;
    text-align: center;
    padding: 4px 8px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.formula-bar {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.formula-bar:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
}

/* Grid Container */
.excel-grid-container {
    overflow: auto;
    max-height: 500px;
    position: relative;
}

/* Grid Table */
.excel-grid {
    border-collapse: collapse;
    font-family: Arial, sans-serif;
    font-size: 13px;
    width: 100%;
    table-layout: fixed;
}

.excel-grid th,
.excel-grid td {
    border: 1px solid #d0d0d0;
    padding: 0;
    position: relative;
}

/* Headers */
.excel-grid .col-header,
.excel-grid .row-header {
    background: #f0f0f0;
    font-weight: normal;
    text-align: center;
    user-select: none;
    color: #666;
    font-size: 12px;
    padding: 6px 8px;
}

.excel-grid .col-header {
    min-width: 80px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.excel-grid .row-header {
    width: 40px;
    position: sticky;
    left: 0;
    z-index: 10;
    background: #f0f0f0;
}

.excel-grid thead tr th:first-child {
    position: sticky;
    left: 0;
    z-index: 11;
}

/* Cells */
.excel-cell {
    padding: 4px 6px;
    min-height: 24px;
    background: #fff;
    cursor: cell;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    outline: none;
}

.excel-cell:hover {
    background: #f5f5f5;
}

.excel-cell.selected {
    outline: 2px solid #0073aa;
    outline-offset: -1px;
    background: #f0f8ff;
}

.excel-cell.has-error {
    color: #dc3232;
    background: #fbeaea;
}

.excel-cell[data-type="formula"] {
    color: #0073aa;
}

.excel-cell[data-type="number"] {
    text-align: right;
}

.excel-cell[data-type="label"] {
    font-weight: 500;
}

/* Cell Editor */
.cell-editor {
    width: 100%;
    height: 100%;
    border: none;
    padding: 4px 6px;
    font-family: inherit;
    font-size: inherit;
    background: #fff;
    outline: 2px solid #0073aa;
    outline-offset: -1px;
}

/* Fallback Mode */
.excel-fallback {
    padding: 20px;
    text-align: center;
}

.excel-fallback p {
    margin: 10px 0;
    color: #666;
}

.excel-fallback-input {
    width: 100%;
    max-width: 500px;
    margin: 15px auto;
    display: block;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

.excel-fallback-submit {
    margin-top: 10px;
}

/* Responsive */
@media (max-width: 768px) {
    .excel-grid-container {
        max-height: 300px;
    }
    
    .excel-grid {
        font-size: 12px;
    }
    
    .excel-cell {
        padding: 2px 4px;
        min-height: 20px;
    }
    
    .excel-grid .col-header {
        min-width: 60px;
        padding: 4px 6px;
    }
    
    .excel-toolbar {
        flex-wrap: wrap;
    }
}

/* Print Styles */
@media print {
    .excel-toolbar,
    .excel-formula-container {
        display: none;
    }
    
    .excel-grid {
        border: 1px solid #000;
    }
    
    .excel-cell.selected {
        outline: none;
        background: #fff;
    }
}

/* Loading State */
.excel-simulator-wrapper.loading {
    opacity: 0.6;
    pointer-events: none;
}

.excel-simulator-wrapper.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: excel-spin 1s linear infinite;
}

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

/* Accessibility */
.excel-cell:focus {
    outline: 2px solid #0073aa;
    outline-offset: -1px;
}

.excel-cell:focus:not(.selected) {
    background: #fffbf0;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .excel-grid th,
    .excel-grid td {
        border: 2px solid;
    }
    
    .excel-cell.selected {
        outline-width: 3px;
    }
}