/**
 * Table Widget Styles
 * 
 * @package Avifauna_Elementor_Extended
 */


/* Error Handling Styles */

.avifauna-widget-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 15px;
    border-radius: 4px;
    margin: 10px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.avifauna-widget-error p {
    margin: 0;
    font-size: 14px;
}


/* Table Widget CSS */


/* Base table styles */

.avifauna-table-wrapper {
    width: 100%;
    overflow: hidden;
}

.avifauna-table-container {
    width: 100%;
    overflow-x: auto;
    position: relative;
}

.avifauna-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    font-family: inherit;
}


/* Caption styles */

.avifauna-table-caption {
    text-align: center;
    font-weight: 600;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    transition: opacity 0.2s ease;
}


/* Header styles */

.avifauna-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    border: 1px solid #e5e7eb;
    background-color: #f9fafb;
    color: #374151;
    position: relative;
    vertical-align: middle;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.avifauna-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
}

.avifauna-table th.sortable:hover {
    background-color: #f3f4f6;
}


/* Sort indicator */

.sort-indicator {
    margin-left: 8px;
    font-size: 12px;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.sort-indicator::after {
    content: "↕";
}

.avifauna-table th.sortable.asc .sort-indicator::after {
    content: "↑";
    opacity: 1;
}

.avifauna-table th.sortable.desc .sort-indicator::after {
    content: "↓";
    opacity: 1;
}


/* Cell styles */

.avifauna-table td {
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    color: #374151;
    vertical-align: middle;
    transition: background-color 0.2s ease, color 0.2s ease;
}


/* Row styles */

.avifauna-table tbody tr {
    transition: background-color 0.2s ease;
}


/* Striped rows */

.avifauna-table.striped tbody tr:nth-child(even) {
    background-color: #f9fafb;
}


/* Hover effect */

.avifauna-table.hover tbody tr:hover {
    background-color: #f3f4f6;
}


/* Featured rows */

.avifauna-table tbody tr.featured {
    background-color: #dbeafe;
    font-weight: 500;
}

.avifauna-table tbody tr.featured td {
    color: #1e40af;
}


/* Highlight rows */

.avifauna-table tbody tr.highlight {
    background-color: #fef3c7;
    font-weight: 500;
}

.avifauna-table tbody tr.highlight td {
    color: #92400e;
}


/* Search input */

.avifauna-table-search {
    margin-bottom: 1rem;
    text-align: right;
    transition: opacity 0.2s ease;
}

.avifauna-table-search input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    min-width: 250px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.avifauna-table-search input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.avifauna-table-search input::placeholder {
    color: #9ca3af;
}


/* No results message */

.avifauna-table-no-results {
    text-align: center;
    padding: 2rem;
    color: #6b7280;
    font-style: italic;
    display: none;
}


/* Loading state */

.avifauna-table-loading {
    text-align: center;
    padding: 2rem;
    color: #6b7280;
    display: none;
}


/* Animation Control */

.avifauna-table.no-animations,
.avifauna-table.no-animations *,
.avifauna-table.no-animations *::before,
.avifauna-table.no-animations *::after {
    transition: none !important;
    animation: none !important;
    transform: none !important;
}

.avifauna-table-wrapper.no-animations .avifauna-table-search,
.avifauna-table-wrapper.no-animations .avifauna-table-caption {
    transition: none !important;
}


/* Hidden Elements */

.avifauna-table-wrapper .hidden {
    display: none !important;
}


/* Feature Control Classes */

.avifauna-table-wrapper.no-header .avifauna-table thead {
    display: none !important;
}

.avifauna-table-wrapper.no-caption .avifauna-table-caption {
    display: none !important;
}

.avifauna-table-wrapper.no-search .avifauna-table-search {
    display: none !important;
}

.avifauna-table-wrapper.no-sorting .sort-indicator {
    display: none !important;
}

.avifauna-table-wrapper.no-sorting th.sortable {
    cursor: default !important;
    user-select: auto !important;
}


/* Responsive Modes */


/* Horizontal Scroll Mode */

.avifauna-table.responsive-scroll {
    min-width: 600px;
}

@media (max-width: 768px) {
    .avifauna-table.responsive-scroll .hidden-mobile {
        display: none;
    }
    .avifauna-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .avifauna-table.responsive-scroll {
        white-space: nowrap;
    }
    .avifauna-table.responsive-scroll th,
    .avifauna-table.responsive-scroll td {
        white-space: nowrap;
        min-width: 120px;
    }
}


/* Stack Columns Mode */

@media (max-width: 768px) {
    .avifauna-table.responsive-stack thead {
        display: none;
    }
    .avifauna-table.responsive-stack,
    .avifauna-table.responsive-stack tbody,
    .avifauna-table.responsive-stack tr,
    .avifauna-table.responsive-stack td {
        display: block;
        width: 100%;
    }
    .avifauna-table.responsive-stack tr {
        border: 1px solid #e5e7eb;
        margin-bottom: 1rem;
        border-radius: 8px;
        padding: 1rem;
        background-color: #fff;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    .avifauna-table.responsive-stack td {
        border: none;
        padding: 0.5rem 0;
        text-align: left;
        position: relative;
        padding-left: 40%;
    }
    .avifauna-table.responsive-stack td:before {
        content: attr(data-label) ": ";
        position: absolute;
        left: 0;
        width: 35%;
        padding-right: 10px;
        font-weight: 600;
        color: #374151;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .avifauna-table.responsive-stack td:last-child {
        border-bottom: none;
    }
}


/* Card Layout Mode */

@media (max-width: 768px) {
    .avifauna-table.responsive-card thead {
        display: none;
    }
    .avifauna-table.responsive-card,
    .avifauna-table.responsive-card tbody {
        display: block;
        width: 100%;
    }
    .avifauna-table.responsive-card tr {
        display: block;
        margin-bottom: 1.5rem;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        padding: 1.5rem;
        background-color: #fff;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    .avifauna-table.responsive-card tr:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    }
    .avifauna-table.responsive-card td {
        display: block;
        border: none;
        padding: 0.75rem 0;
        text-align: left;
        position: relative;
        border-bottom: 1px solid #f3f4f6;
    }
    .avifauna-table.responsive-card td:last-child {
        border-bottom: none;
    }
    .avifauna-table.responsive-card td:before {
        content: attr(data-label);
        display: block;
        font-weight: 600;
        color: #6b7280;
        font-size: 0.875rem;
        margin-bottom: 0.25rem;
        text-transform: uppercase;
        letter-spacing: 0.025em;
    }
    .avifauna-table.responsive-card .featured {
        border-color: #3b82f6;
        background-color: #eff6ff;
    }
    .avifauna-table.responsive-card .highlight {
        border-color: #f59e0b;
        background-color: #fffbeb;
    }
    /* Disable card hover animations when animations are disabled */
    .avifauna-table.responsive-card.no-animations tr {
        transition: none !important;
        transform: none !important;
    }
    .avifauna-table.responsive-card.no-animations tr:hover {
        transform: none !important;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
    }
}


/* Hidden elements */

.avifauna-table tr.hidden,
.avifauna-table td.hidden,
.avifauna-table th.hidden {
    display: none !important;
}


/* Animation for filtering */

.avifauna-table tbody tr {
    opacity: 1;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.avifauna-table tbody tr.filtered-out {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}


/* Disable filtering animations when animations are disabled */

.avifauna-table.no-animations tbody tr {
    transition: none !important;
}

.avifauna-table.no-animations tbody tr.filtered-out {
    transform: none !important;
    transition: none !important;
}


/* Custom breakpoint support */

@media (max-width: 480px) {
    .avifauna-table th,
    .avifauna-table td {
        padding: 8px 12px;
        font-size: 14px;
    }
    .avifauna-table-search input {
        min-width: 200px;
        width: 100%;
    }
    .avifauna-table-caption {
        font-size: 1.125rem;
        margin-bottom: 0.75rem;
    }
}


/* Dark mode support */

@media (prefers-color-scheme: dark) {
    .avifauna-table th {
        background-color: #374151;
        color: #f9fafb;
        border-color: #4b5563;
    }
    .avifauna-table td {
        color: #f9fafb;
        border-color: #4b5563;
    }
    .avifauna-table.striped tbody tr:nth-child(even) {
        background-color: #374151;
    }
    .avifauna-table.hover tbody tr:hover {
        background-color: #4b5563;
    }
    .avifauna-table-search input {
        background-color: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    .avifauna-table-search input::placeholder {
        color: #9ca3af;
    }
}


/* Print styles */

@media print {
    .avifauna-table-search {
        display: none;
    }
    .avifauna-table {
        font-size: 12px;
    }
    .avifauna-table th,
    .avifauna-table td {
        padding: 6px 8px;
    }
    .sort-indicator {
        display: none;
    }
    /* Disable all animations in print */
    .avifauna-table-wrapper *,
    .avifauna-table-wrapper *::before,
    .avifauna-table-wrapper *::after {
        animation-duration: 0s !important;
        animation-delay: 0s !important;
        transition-duration: 0s !important;
        transition-delay: 0s !important;
    }
}


/* Accessibility improvements */

.avifauna-table:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.avifauna-table th.sortable:focus {
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
}


/* Screen reader only content */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}