/**
 * DataTables Theme Integration
 * Integrates DataTables with the EyeLink IoT theme system
 */

/* DataTables Container */
.dataTables_wrapper {
    font-family: inherit;
    color: var(--text);
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
}

/* DataTables Length Menu */
.dataTables_length {
    float: left;
    padding: 10px 0;
    color: var(--text);
    font-size: 14px;
}

.dataTables_length select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    margin: 0 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dataTables_length select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* DataTables Filter/Search */
.dataTables_filter {
    float: right;
    padding: 10px 0;
    color: var(--text);
    font-size: 14px;
}

.dataTables_filter input {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    margin-left: 8px;
    transition: all 0.2s ease;
}

.dataTables_filter input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* DataTables Info */
.dataTables_info {
    float: left;
    padding: 10px 0;
    color: var(--text-secondary);
    font-size: 13px;
}

/* DataTables Pagination */
.dataTables_paginate {
    float: right;
    padding: 10px 0;
    text-align: right;
}

.dataTables_paginate .paginate_button {
    display: inline-block;
    min-width: 32px;
    height: 32px;
    padding: 4px 10px;
    margin: 0 2px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.dataTables_paginate .paginate_button:hover {
    background: var(--surface-light);
    border-color: var(--primary);
    color: var(--primary);
}

.dataTables_paginate .paginate_button.current {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.dataTables_paginate .paginate_button.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.dataTables_paginate .paginate_button.disabled:hover {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

/* DataTables Table */
table.dataTable {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    margin-top: 16px;
}

table.dataTable thead th {
    background: var(--surface-light);
    padding: 10px 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    border-bottom: 2px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
}

table.dataTable thead th.sorting {
    cursor: pointer;
    padding-right: 30px;
}

table.dataTable thead th.sorting::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--text-secondary);
    opacity: 0.5;
}

table.dataTable thead th.sorting_asc::after {
    border-top: none;
    border-bottom: 5px solid var(--primary);
    opacity: 1;
}

table.dataTable thead th.sorting_desc::after {
    border-top: 5px solid var(--primary);
    border-bottom: none;
    opacity: 1;
}

table.dataTable tbody td {
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    transition: background 0.2s ease;
}

table.dataTable tbody tr:hover {
    background: var(--surface-light);
}

table.dataTable tbody tr.selected {
    background: rgba(0, 212, 255, 0.1);
}

table.dataTable tbody tr.selected td {
    color: var(--primary);
}

/* Center alignment for specific columns */
table.dataTable tbody td.dt-center {
    text-align: center;
}

table.dataTable thead th.dt-center {
    text-align: center;
}

/* DataTables Processing */
.dataTables_processing {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px 40px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    color: var(--text);
    font-size: 14px;
    z-index: 1000;
}

/* DataTables Clear Fix */
.dataTables_wrapper::after {
    content: '';
    display: block;
    clear: both;
}

/* Top and bottom containers */
.dataTables_wrapper .top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.dataTables_wrapper .bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {
    .dataTables_wrapper {
        padding: 12px;
    }

    .dataTables_length,
    .dataTables_filter {
        float: none;
        text-align: center;
        padding: 10px 0;
    }

    .dataTables_filter input {
        margin-left: 0;
        margin-top: 8px;
    }

    .dataTables_info,
    .dataTables_paginate {
        float: none;
        text-align: center;
        padding: 10px 0;
    }

    .dataTables_paginate {
        margin-top: 8px;
    }

    .dataTables_wrapper .top,
    .dataTables_wrapper .bottom {
        flex-direction: column;
    }

    table.dataTable thead th,
    table.dataTable tbody td {
        padding: 8px 10px;
        font-size: 12px;
    }
}

/* Dark theme specific adjustments */
[data-theme*="dark"] table.dataTable thead th {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme*="dark"] table.dataTable tbody tr:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Light theme specific adjustments */
[data-theme*="light"] table.dataTable thead th {
    background: rgba(0, 0, 0, 0.03);
}

[data-theme*="light"] table.dataTable tbody tr:hover {
    background: rgba(0, 0, 0, 0.03);
}

/* Status badges in DataTables */
.dataTables_wrapper .status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
}

.dataTables_wrapper .status-badge.online {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
}

.dataTables_wrapper .status-badge.offline {
    background: rgba(244, 67, 54, 0.2);
    color: #F44336;
}

.dataTables_wrapper .status-badge.scanning {
    background: rgba(255, 193, 7, 0.2);
    color: #FFC107;
}

/* Empty state */
.dataTables_empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Row selection checkbox */
.dataTables_wrapper input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* Custom scrollbar for DataTables */
.dataTables_wrapper .dataTables_scrollBody::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.dataTables_wrapper .dataTables_scrollBody::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: 4px;
}

.dataTables_wrapper .dataTables_scrollBody::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.dataTables_wrapper .dataTables_scrollBody::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* WiFi signal display in DataTables */
.dataTables_wrapper .wifi-signal-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dataTables_wrapper .wifi-signal-icon {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 16px;
}

.dataTables_wrapper .wifi-signal-bar {
    width: 4px;
    border-radius: 1px;
    transition: all 0.2s ease;
}

.dataTables_wrapper .wifi-signal-bar.wifi-signal-bar-excellent {
    background: #4CAF50;
}

.dataTables_wrapper .wifi-signal-bar.wifi-signal-bar-good {
    background: #8BC34A;
}

.dataTables_wrapper .wifi-signal-bar.wifi-signal-bar-fair {
    background: #FFC107;
}

.dataTables_wrapper .wifi-signal-bar.wifi-signal-bar-poor {
    background: #FF9800;
}

.dataTables_wrapper .wifi-signal-bar.wifi-signal-bar-very-poor {
    background: #F44336;
}

.dataTables_wrapper .wifi-signal-bar.wifi-signal-bar-empty {
    background: var(--border);
    opacity: 0.3;
}

.dataTables_wrapper .wifi-signal-value {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Entity count in DataTables */
.dataTables_wrapper .entity-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.dataTables_wrapper .entity-count:hover {
    background: rgba(0, 212, 255, 0.1);
    transform: scale(1.05);
}

/* Device actions in DataTables */
.dataTables_wrapper .device-actions {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.dataTables_wrapper .device-actions .btn {
    padding: 4px 8px;
    font-size: 12px;
    min-width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* No results row */
.dataTables_wrapper .no-results {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-style: italic;
}
