/* ===================================
   Data Table & Controls
   =================================== */

/* Table Section */
.table-section {
    width: 100%;
    height: 100%;
    padding: 10px;
    overflow-y: auto;
}

.table-controls {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.search-box {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    min-width: 200px;
}

.summary-info {
    color: #666;
    font-size: 12px;
}

/* Compact Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 11px;
}

.data-table th,
.data-table td {
    padding: 5px 7px;
    text-align: left;
    border-bottom: 1px solid #ddd;
    vertical-align: top;
}

.data-table th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #002855;
    position: sticky;
    top: 0;
    cursor: pointer;
    user-select: none;
    font-size: 10px;
    text-transform: uppercase;
}

.data-table th:hover {
    background-color: #e9ecef;
}

.data-table tbody tr:hover {
    background-color: #f8faff;
    cursor: pointer;
}

.data-table tbody tr.selected {
    background-color: #e3f2fd !important;
}

.data-table tbody tr.selected td:first-child {
    border-left: 4px solid #3b82f6;
}

.field-name {
    font-family: 'Courier New', monospace;
    color: #666;
    font-size: 9px;
    margin-top: 2px;
}

.field-value {
    max-width: 180px;
    word-wrap: break-word;
    font-size: 11px;
    line-height: 1.2;
}

.clause-tag-mini {
    background: #3b82f6;
    color: white;
    padding: 1px 4px;
    border-radius: 6px;
    font-size: 8px;
    font-weight: 500;
}

/* Hide columns on smaller screens */
@media (max-width: 1000px) {
    .hide-on-small { display: none; }
}

/* Expanded Row */
.expanded-row {
    display: none;
    background-color: #f8fafc;
    border-left: 4px solid #3b82f6;
}

.expanded-row.show {
    display: table-row;
    animation: expandRow 0.3s ease-out;
}

.expanded-content {
    padding: 0;
}

.expanded-inner {
    background: #ffffff;
    margin: 8px 12px;
    border-radius: 8px;
    padding: 16px;
    border: 2px solid #e2e8f0;
}

.expanded-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 10px;
}

.expanded-header h4 {
    font-size: 16px;
    color: #0f172a;
    font-weight: 600;
}

.expanded-field-name {
    color: #64748b;
    font-size: 10px;
    font-family: 'Courier New', monospace;
    margin-top: 4px;
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
}

.expanded-close {
    background: #fef2f2;
    border: 2px solid #fecaca;
    color: #dc2626;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.expanded-close:hover {
    background: #fee2e2;
}

.expanded-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.expanded-field {
    background: #f8fafc;
    border-radius: 6px;
    padding: 10px;
}

.expanded-field-label {
    font-weight: 600;
    color: #3730a3;
    margin-bottom: 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.expanded-field-label:hover .edit-icon {
    opacity: 1;
}

.edit-icon {
    opacity: 0;
    font-size: 10px;
    color: #6b7280;
    transition: opacity 0.2s;
    cursor: pointer;
}

.edit-icon:hover {
    color: #3730a3;
}

.expanded-field-content {
    font-size: 12px;
    line-height: 1.4;
    color: #1e293b;
    word-wrap: break-word;
}

.expanded-field-content.editing {
    display: none;
}

.edit-container {
    display: none;
}

.edit-container.active {
    display: block;
}

.edit-textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px;
    border: 2px solid #3730a3;
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
    resize: vertical;
    outline: none;
}

.edit-controls {
    margin-top: 6px;
    display: flex;
    gap: 6px;
}

.edit-btn {
    padding: 4px 8px;
    border: none;
    border-radius: 3px;
    font-size: 10px;
    cursor: pointer;
    font-weight: 500;
}

.save-btn {
    background-color: #10b981;
    color: white;
}

.save-btn:hover {
    background-color: #059669;
}

.cancel-btn {
    background-color: #6b7280;
    color: white;
}

.cancel-btn:hover {
    background-color: #4b5563;
}

.expanded-field.full-width {
    grid-column: 1 / -1;
}

.clause-tag {
    background: #10b981;
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 500;
    margin-right: 4px;
    display: inline-block;
    margin-bottom: 2px;
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding: 10px 0;
    border-top: 1px solid #ddd;
}

.pagination-info {
    color: #666;
    font-size: 12px;
}

.pagination-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pagination-btn {
    background-color: #002855;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.pagination-btn:hover:not(:disabled) {
    background-color: #004080;
}

.pagination-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.page-number {
    padding: 6px 10px;
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

/* Sort indicators */
.data-table th[data-sort]::after {
    content: " ↕";
    opacity: 0.5;
    font-size: 10px;
}

.data-table th.sort-asc::after {
    content: " ↑";
    opacity: 1;
    color: #3b82f6;
}

.data-table th.sort-desc::after {
    content: " ↓";
    opacity: 1;
    color: #3b82f6;
}
