/**
 * Google Sheet Widget CSS
 * 
 * Handles styling for the Google Sheet widget, including the table,
 * controls, pagination, and responsive behavior.
 */

/* Main container for the widget */
.unlockafe-google-sheet-container {
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
}

/* Table container to allow for horizontal scrolling on small screens */
.unlockafe-google-sheet-table-container {
    overflow-x: auto;
    width: 100%;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    background-color: #fff;
}

/* Core table styling */
.unlockafe-google-sheet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

/* Table header cells */
.unlockafe-google-sheet-table thead th {
    background-color: #f5f5f5;
    border-bottom: 2px solid #ddd;
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: #333;
    position: sticky;
    /* Keep header visible on scroll */
    top: 0;
    z-index: 0;
}

/* Table body rows */
.unlockafe-google-sheet-table tbody tr {
    border-bottom: 1px solid #e0e0e0;
    transition: background-color 0.2s ease;
}

.unlockafe-google-sheet-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.unlockafe-google-sheet-table tbody tr:hover {
    background-color: #f1f1f1;
}

/* All table cells (th and td) */
.unlockafe-google-sheet-table th,
.unlockafe-google-sheet-table td {
    padding: 10px 15px;
    border-right: 1px solid #e0e0e0;
    vertical-align: middle;
}

.unlockafe-google-sheet-table th:last-child,
.unlockafe-google-sheet-table td:last-child {
    border-right: none;
}

/* Sorting indicators */
.unlockafe-google-sheet-table thead th.sortable-header {
    cursor: pointer;
}

.unlockafe-google-sheet-table thead th.sortable-header:hover {
    background-color: #e0e0e0;
}

.unlockafe-google-sheet-table thead th.asc::after,
.unlockafe-google-sheet-table thead th.desc::after {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
}

.unlockafe-google-sheet-table thead th.asc::after {
    content: '▲';
}

.unlockafe-google-sheet-table thead th.desc::after {
    content: '▼';
}

/* Controls container */
.unlockafe-table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    /* Allows controls to wrap on smaller screens */
    gap: 15px;
    /* Adds space between items when they wrap */
}

/* Styling for individual control groups (entries and search) */
.unlockafe-entries-container label select {}


.unlockafe-entries-container,
.unlockafe-search-container {
    display: flex;
    align-items: center;
}

/* Label styling */
.unlockafe-entries-container label,
.unlockafe-search-container label {
    font-size: 14px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 8px;
    /* Space between label text and input/select */
}

/* Input and select styling */
.unlockafe-entries-select,
.unlockafe-search-input {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.unlockafe-search-input {
    min-width: 250px;
    /* Give search input a decent width */
}

/* Bottom controls container (info and pagination) */
.unlockafe-table-bottom-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: #f9f9f9;
    border-top: 1px solid #e0e0e0;
    font-size: 14px;
    color: #555;
}

/* Table info text */
.unlockafe-table-info {
    flex-grow: 1;
}

/* Pagination buttons */
.unlockafe-table-pagination .paginate_button {
    background-color: #fff;
    border: 1px solid #ccc;
    padding: 6px 12px;
    margin-left: 5px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

.unlockafe-table-pagination .paginate_button:hover {
    background-color: #f0f0f0;
}

.unlockafe-table-pagination .paginate_button.current {
    background-color: #1f2937;
    color: #fff;
    border-color: #1f2937;
    font-weight: bold;
}

.unlockafe-table-pagination .paginate_button:hover.current {
    background-color: #1f2937;
    color: #fff;
    border-color: #1f2937;
    font-weight: bold;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .unlockafe-table-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .unlockafe-search-input {
        width: 100%;
    }

    .unlockafe-table-bottom-controls {
        flex-direction: column;
        gap: 10px;
    }
}

/* Top and bottom control bars */
.unlockafe-table-top-controls,
.unlockafe-table-bottom-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    flex-wrap: wrap;
    /* Allow controls to wrap on smaller screens */
    gap: 15px;
}

/* Search input and entries dropdown */
.unlockafe-search-input,
.unlockafe-entries-per-page {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Pagination controls */
/* .unlockafe-table-pagination .paginate_button {
    padding: 8px 12px;
    margin: 0 2px;
    border: 1px solid #ddd;
    background-color: #fff;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.unlockafe-table-pagination .paginate_button:hover {
    background-color: #f0f0f0;
}

.unlockafe-table-pagination .paginate_button.current {
    background-color: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

.unlockafe-table-pagination .paginate_button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
} */

/* Table info text (e.g., 'Showing 1 to 10 of 57 entries') */
.unlockafe-table-info {
    font-size: 0.9em;
    color: #555;
}

/* Loading and error states */
.unlockafe-google-sheet-loading,
.unlockafe-google-sheet-error {
    padding: 20px;
    text-align: center;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 20px;
}

.unlockafe-google-sheet-loading {
    background-color: #f9f9f9;
}

.unlockafe-google-sheet-error {
    background-color: #fff8f8;
    border-color: #ffdddd;
    color: #d32f2f;
}

.unlockafe-google-sheet-error strong {
    font-weight: 600;
}

.unlockafe-google-sheet-error ol {
    margin-top: 10px;
    margin-left: 20px;
    text-align: left;
    color: #555;
}


.unlockafe-google-sheet-table .sortable th.asc::after {
    content: '\25B2';
    /* Up arrow */
    color: #333;
}

.unlockafe-google-sheet-table .sortable th.desc::after {
    content: '\25BC';
    /* Down arrow */
    color: #333;
}

.unlockafe-google-sheet-table .sortable th {
    cursor: pointer;
    position: relative;
    padding-right: 20px;
}

.unlockafe-google-sheet-table .sortable th::after {
    content: '\2195';
    /* Up-down arrow */
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: #ccc;
}

/* --- Template System --- */

/* Template: Vibrant */
.unlockafe-gs-template-vibrant .unlockafe-google-sheet-table-container {
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.07);
    border: 1px solid #e5e7eb;
}

.unlockafe-gs-template-vibrant .unlockafe-google-sheet-table thead th {
    background-color: #6D28D9;
    color: #ffffff;
    border-bottom: none;
}

.unlockafe-gs-template-vibrant .unlockafe-google-sheet-table tbody tr {
    border-color: #e5e7eb;
}

.unlockafe-gs-template-vibrant .unlockafe-google-sheet-table tbody tr:nth-child(even) {
    background-color: transparent;
}

/* Template: Professional */
.unlockafe-gs-template-professional .unlockafe-google-sheet-table-container {
    border: 1px solid #e5e7eb;
    box-shadow: none;
}

.unlockafe-gs-template-professional .unlockafe-google-sheet-table thead th {
    background-color: #1f2937;
    color: #f9fafb;
    border-bottom: 1px solid #1f2937;
}

.unlockafe-gs-template-professional .unlockafe-google-sheet-table tbody tr:nth-child(even) {
    background-color: #f9fafb;
}

/* Template: Midnight */
.unlockafe-gs-template-midnight .unlockafe-google-sheet-table-container {
    background-color: #1f2937;
    border: 1px solid #374151;
    border-radius: 6px;
}

.unlockafe-gs-template-midnight .unlockafe-google-sheet-table {
    color: #d1d5db;
}

.unlockafe-gs-template-midnight .unlockafe-google-sheet-table thead th {
    background-color: #3b82f6;
    color: #ffffff;
    border-bottom: none;
}

.unlockafe-gs-template-midnight .unlockafe-google-sheet-table tbody tr {
    border-color: #374151;
}

.unlockafe-gs-template-midnight .unlockafe-google-sheet-table tbody tr:nth-child(even) {
    background-color: rgba(55, 65, 81, 0.5);
}

.unlockafe-gs-template-midnight .unlockafe-google-sheet-table tbody tr:hover {
    background-color: rgba(75, 85, 99, 0.5);
}

.unlockafe-gs-template-midnight .unlockafe-table-top-controls,
.unlockafe-gs-template-midnight .unlockafe-table-bottom-controls {
    color: #d1d5db;
}

.unlockafe-gs-template-midnight .unlockafe-search-input,
.unlockafe-gs-template-midnight .unlockafe-entries-per-page,
.unlockafe-gs-template-midnight .unlockafe-table-pagination button {
    background-color: #374151;
    color: #d1d5db;
    border-color: #4b5563;
}

.unlockafe-gs-template-midnight .unlockafe-table-pagination button.active {
    background-color: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
}

/* Template: Airy */
.unlockafe-gs-template-airy .unlockafe-google-sheet-table-container {
    border: none;
    box-shadow: none;
    background-color: transparent;
}

.unlockafe-gs-template-airy .unlockafe-google-sheet-table thead th {
    background-color: transparent;
    color: #6b7280;
    font-weight: 600;
    border-bottom: 1px solid #e5e7eb;
}

.unlockafe-gs-template-airy .unlockafe-google-sheet-table tbody tr {
    border-bottom: 1px solid #f3f4f6;
}

.unlockafe-gs-template-airy .unlockafe-google-sheet-table tbody tr:nth-child(even) {
    background-color: transparent;
}

.unlockafe-gs-template-airy .unlockafe-google-sheet-table th,
.unlockafe-gs-template-airy .unlockafe-google-sheet-table td {
    border-right: none;
}


/* Responsive styles */
@media screen and (max-width: 767px) {
    .unlockafe-google-sheet-table {
        font-size: 12px;
    }

    .unlockafe-google-sheet-table th,
    .unlockafe-google-sheet-table td {
        padding: 8px;
    }
}