* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 0;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header h1 {
    margin: 0;
    font-size: 2.5em;
    font-weight: 300;
    text-align: center;
}

.header p {
    text-align: center;
    margin: 10px 0 0;
    opacity: 0.9;
}

/* Controls */
.controls {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 15px rgba(0,0,0,0.05);
    margin-bottom: 25px;
}

/* Enhanced Controls */
.enhanced-controls {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

.control-group {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    gap: 10px;
    flex: 1;
    min-width: 300px;
}

.search-box input {
    flex: 1;
}

/* Bulk Actions */
.bulk-actions {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.bulk-info {
    color: #856404;
    font-size: 0.9em;
}

/* Checkbox cells */
.checkbox-cell {
    width: 40px;
    text-align: center;
    padding: 8px 4px !important;
}

.row-checkbox, #masterCheckbox {
    cursor: pointer;
    transform: scale(1.2);
}

/* Statistics Modal */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.stat-item {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.stat-number {
    font-size: 2em;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-label {
    color: #6c757d;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.columns-list {
    margin-top: 20px;
}

.columns-list ul {
    max-height: 200px;
    overflow-y: auto;
    padding-left: 20px;
}

.columns-list code {
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

/* Search Results */
.no-results {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.no-results h3 {
    color: #495057;
    margin-bottom: 10px;
}

.controls h3 {
    margin-top: 0;
    color: #495057;
    font-size: 1.2em;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    background: #667eea;
    color: white;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
}

.btn:hover {
    background: #5a67d8;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-danger {
    background: #e53e3e;
}

.btn-danger:hover {
    background: #c53030;
    box-shadow: 0 4px 15px rgba(229, 62, 62, 0.3);
}

.btn-success {
    background: #38a169;
}

.btn-success:hover {
    background: #2f855a;
    box-shadow: 0 4px 15px rgba(56, 161, 105, 0.3);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* Table Container */
.table-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 15px rgba(0,0,0,0.05);
    overflow: hidden;
}

.table-header {
    padding: 20px 25px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.table-title {
    font-size: 1.5em;
    font-weight: 600;
    color: #495057;
    margin: 0;
}

.table-info {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: #6c757d;
}

/* Filters */
.filters {
    padding: 20px 25px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    align-items: end;
}

.filter-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    background: #495057;
    color: white;
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: top;
    position: relative;
}

.data-table tr:hover {
    background-color: #f8f9fa;
}

.data-table tr:nth-child(even) {
    background-color: #fdfdfe;
}

.data-table tr:nth-child(even):hover {
    background-color: #f1f3f4;
}

/* Editable cells */
.editable-cell {
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 20px;
    padding: 8px;
    border-radius: 4px;
}

.editable-cell:hover {
    background-color: #e3f2fd;
    box-shadow: inset 0 0 0 2px #2196f3;
}

.editing {
    background-color: #fff3cd;
    box-shadow: inset 0 0 0 2px #ffc107;
}

.cell-input {
    width: 100%;
    border: none;
    background: transparent;
    font-size: inherit;
    font-family: inherit;
    padding: 4px;
    outline: none;
    resize: vertical;
}

.cell-input:focus {
    background: white;
    box-shadow: inset 0 0 0 2px #667eea;
    border-radius: 2px;
}

/* Cell states */
.saving {
    background-color: #fff3cd !important;
    opacity: 0.7;
}

.saving::after {
    content: "💾";
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 12px;
}

/* Cell types */
.cell-null {
    color: #6c757d;
    font-style: italic;
}

.cell-boolean {
    font-weight: 600;
}

.cell-boolean.true {
    color: #28a745;
}

.cell-boolean.false {
    color: #dc3545;
}

.cell-number {
    text-align: right;
    font-family: 'Courier New', monospace;
}

.cell-json {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-date {
    font-family: 'Courier New', monospace;
    color: #6f42c1;
}

/* Actions column */
.actions-cell {
    white-space: nowrap;
    width: 120px;
}

.action-btn {
    display: inline-block;
    padding: 4px 8px;
    margin: 0 2px;
    background: #6c757d;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.action-btn:hover {
    transform: translateY(-1px);
}

.action-btn.edit {
    background: #17a2b8;
}

.action-btn.delete {
    background: #dc3545;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 25px;
    background: white;
    border-top: 1px solid #e9ecef;
}

.pagination-info {
    color: #6c757d;
    font-size: 14px;
    margin-right: 20px;
}

.pagination .btn {
    padding: 8px 16px;
    font-size: 13px;
}

.pagination .btn:disabled {
    background: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading states */
.loading {
    text-align: center;
    padding: 50px;
    color: #6c757d;
}

.spinner {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error messages */
.alert {
    padding: 15px 20px;
    margin: 20px 0;
    border-radius: 8px;
    font-weight: 500;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-info {
    background-color: #cce7ff;
    color: #004085;
    border: 1px solid #b3d7ff;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e9ecef;
}

.modal-title {
    margin: 0;
    font-size: 1.5em;
    color: #495057;
}

.close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close:hover {
    background: #f8f9fa;
    color: #495057;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 2em;
    }
    
    .controls, .table-container {
        margin-bottom: 15px;
    }
    
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .filter-row {
        grid-template-columns: 1fr;
    }
    
    .data-table {
        font-size: 12px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 6px;
    }
    
    .pagination {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .pagination-info {
        width: 100%;
        text-align: center;
        margin: 0 0 10px 0;
    }
}

@media (max-width: 480px) {
    .data-table th,
    .data-table td {
        padding: 6px 4px;
        font-size: 11px;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .modal-content {
        padding: 20px;
        margin: 10px;
    }
}

/* Utility classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.hidden { display: none; }
.visible { display: block; }

/* Custom scrollbar */
.table-container {
    overflow-x: auto;
}

.table-container::-webkit-scrollbar {
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
