/**
 * Library Catalog Styles
 */

.supabase-library-catalog {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* Search Form Styles */
.library-search-form {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.library-search-form h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: #212529;
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: end;
}

@media (max-width: 768px) {
    .search-row {
        grid-template-columns: 1fr;
    }
}

.search-field {
    display: flex;
    flex-direction: column;
}

.search-field label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #495057;
    font-size: 0.9rem;
}

.search-input,
.search-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.search-input:focus,
.search-select:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 0.2rem rgba(34, 113, 177, 0.25);
}

.checkbox-field {
    display: flex;
    align-items: center;
}

.checkbox-field label {
    display: flex;
    align-items: center;
    margin-bottom: 0;
    cursor: pointer;
}

.checkbox-field input[type="checkbox"] {
    margin-right: 0.5rem;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.search-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    align-items: flex-end;
}

.search-actions .button {
    padding: 0.5rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}

.search-actions .button-primary {
    background-color: #2271b1;
    color: white;
}

.search-actions .button-primary:hover {
    background-color: #135e96;
}

.search-actions .button:not(.button-primary) {
    background-color: #f6f7f7;
    color: #2c3338;
    border: 1px solid #8c8f94;
}

.search-actions .button:not(.button-primary):hover {
    background-color: #f0f0f1;
}

/* Results Table Styles */
.library-results {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1.5rem;
}

#library-results-table {
    width: 100% !important;
}

#library-results-table thead th {
    background-color: #f8f9fa;
    color: #212529;
    font-weight: 600;
    padding: 12px 8px;
    border-bottom: 2px solid #dee2e6;
}

#library-results-table tbody td {
    padding: 10px 8px;
    vertical-align: middle;
}

#library-results-table tbody tr:hover {
    background-color: #f8f9fa;
}

.view-details-btn {
    padding: 0.375rem 0.75rem;
    background-color: #2271b1;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.15s ease-in-out;
}

.view-details-btn:hover {
    background-color: #135e96;
}

/* Modal Styles */
.library-modal {
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.library-modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 0;
    border: 1px solid #888;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.library-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #dee2e6;
    background-color: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.library-modal-close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.15s ease-in-out;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
}

.library-modal-close:hover,
.library-modal-close:focus {
    color: #000;
}

.print-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: #2271b1;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.15s ease-in-out;
}

.print-btn:hover {
    background-color: #135e96;
}

.print-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Item Detail Styles */
#item-detail-content {
    padding: 2rem;
}

#item-detail-content h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: #212529;
    font-size: 1.75rem;
    padding-right: 2rem;
}

.detail-field {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e9ecef;
}

.detail-field:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.detail-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    color: #212529;
    font-size: 1rem;
    line-height: 1.5;
}

.detail-value a {
    color: #2271b1;
    text-decoration: none;
}

.detail-value a:hover {
    text-decoration: underline;
}

.detail-value.empty {
    color: #6c757d;
    font-style: italic;
}

/* Notice Styles */
.supabase-notice {
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 4px;
    border-left: 4px solid;
}

.supabase-notice.supabase-error {
    background-color: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.supabase-notice.supabase-info {
    background-color: #d1ecf1;
    border-color: #0c5460;
    color: #0c5460;
}

/* DataTables Customization */
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 0.375rem 0.75rem;
    margin-left: 0.5rem;
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 0.375rem 2rem 0.375rem 0.75rem;
    margin: 0 0.5rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 4px;
    padding: 0.375rem 0.75rem;
    margin: 0 2px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #2271b1;
    border-color: #2271b1;
    color: white !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #135e96;
    border-color: #135e96;
    color: white !important;
}

/* Responsive */
@media (max-width: 768px) {
    .library-modal-content {
        margin: 10% auto;
        width: 95%;
        padding: 1.5rem;
    }

    .search-actions {
        justify-content: stretch;
    }

    .search-actions .button {
        flex: 1;
    }
}

/* Loading State */
.library-loading {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

.library-loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% {
        color: rgba(0,0,0,0);
        text-shadow:
            .25em 0 0 rgba(0,0,0,0),
            .5em 0 0 rgba(0,0,0,0);
    }
    40% {
        color: #6c757d;
        text-shadow:
            .25em 0 0 rgba(0,0,0,0),
            .5em 0 0 rgba(0,0,0,0);
    }
    60% {
        text-shadow:
            .25em 0 0 #6c757d,
            .5em 0 0 rgba(0,0,0,0);
    }
    80%, 100% {
        text-shadow:
            .25em 0 0 #6c757d,
            .5em 0 0 #6c757d;
    }
}

/* Print Styles */
@media print {
    /* Hide everything except the modal content */
    body * {
        visibility: hidden;
    }

    #item-detail-content,
    #item-detail-content * {
        visibility: visible;
    }

    #item-detail-content {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 1rem;
    }

    /* Hide modal overlay and buttons */
    .library-modal {
        background: none;
    }

    .library-modal-header,
    .print-btn,
    .library-modal-close {
        display: none !important;
    }

    .library-modal-content {
        margin: 0;
        padding: 0;
        border: none;
        box-shadow: none;
        max-height: none;
        width: 100%;
    }

    /* Optimize field display for print */
    .detail-field {
        page-break-inside: avoid;
        margin-bottom: 1rem;
        border-bottom: 1px solid #dee2e6;
        padding-bottom: 0.75rem;
    }

    .detail-label {
        font-weight: bold;
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
    }

    .detail-value {
        font-size: 0.95rem;
    }

    #item-detail-content h3 {
        margin-top: 0;
        margin-bottom: 1.5rem;
        padding-bottom: 0.5rem;
        border-bottom: 2px solid #212529;
    }
}
