/* Resources List Frontend Styles - Clean structure for blocks and shortcodes */

/* Container classes */
.resources-list-block,
.ujc-shortcode-resources-list {
    margin: var(--container-margin, 20px 0) !important;
    box-sizing: border-box;
}

/* Base table structure */
.resources-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    min-width: var(--table-min-width, 600px);
}

.resources-table th,
.resources-table td {
    padding: var(--table-padding, 12px 15px) !important;
    text-align: left;
}

/* Table styling with CSS variables */
.resources-table th {
    background-color: var(--header-bg-color, #f9f9f9);
    color: var(--header-text-color, #333333) !important;
    font-family: var(--header-font-family, inherit);
}

/* Ensure header text color works with sortable headers and overrides WordPress styles */
.resources-list-block .resources-table th,
.ujc-shortcode-resources-list .resources-table th,
.resources-table th.sortable-header {
    color: var(--header-text-color, #333333) !important;
}

.resources-table td {
    color: var(--text-color, #333333);
    font-family: var(--content-font-family, inherit);
}

.resources-table tbody tr:hover {
    background-color: var(--hover-bg-color, #f5f5f5);
}

/* Common Button Styles */
.ujc-historia-btn,
.ujc-karta-btn {
    border: var(--button-border-width, 0) solid var(--button-border-color, transparent);
    padding: var(--button-padding, 6px 12px);
    border-radius: var(--button-border-radius, 4px);
    cursor: pointer;
    font-size: var(--button-font-size, 0.875em);
    font-weight: var(--button-font-weight, normal);
    transition: var(--button-transition, all 0.2s ease);
}

/* Historia Button */
.ujc-historia-btn {
    background-color: var(--historia-btn-bg-color, #007cba);
    color: var(--historia-btn-text-color, #ffffff);
}

.ujc-historia-btn:hover {
    opacity: 0.8;
    transform: var(--button-hover-transform, none);
    box-shadow: var(--button-hover-box-shadow, none);
}

.ujc-historia-btn:focus {
    outline: var(--focus-outline-width, 2px) solid var(--focus-outline-color, #007cba);
    outline-offset: var(--focus-outline-offset, 2px);
}

/* Karta Button */
.ujc-karta-btn,
.download-floorplan-btn {
    background-color: var(--karta-btn-bg-color, #007cba);
    color: var(--karta-btn-text-color, #ffffff);
}

.ujc-karta-btn:hover,
.download-floorplan-btn:hover {
    opacity: 0.8;
    transform: var(--button-hover-transform, none);
    box-shadow: var(--button-hover-box-shadow, none);
}

/* Status Styles */
.resources-list-block [class*="ujc-status-"],
.ujc-shortcode-resources-list [class*="ujc-status-"] {
    padding: var(--status-padding, 4px 8px);
    border-radius: var(--status-border-radius, 4px);
    font-size: var(--status-font-size, 0.875em);
    font-weight: var(--status-font-weight, normal);
}

.ujc-status-available {
    background-color: var(--status-available-bg, #28a745);
    color: var(--status-available-color, #ffffff);
}

.ujc-status-sold {
    background-color: var(--status-sold-bg, #dc3545);
    color: var(--status-sold-color, #ffffff);
}

.ujc-status-reserved {
    background-color: var(--status-reserved-bg, #ffc107);
    color: var(--status-reserved-color, #000000);
}

/* Modal Styles */
.price-history-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-overlay-color, rgba(0, 0, 0, 0.5));
    z-index: var(--modal-z-index, 10000);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn var(--modal-animation-duration, 0.3s) ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--modal-background-color, white);
    border-radius: var(--modal-border-radius, 8px);
    max-width: var(--modal-max-width, 600px);
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--modal-box-shadow, 0 10px 30px rgba(0,0,0,0.3));
    animation: modalSlideIn var(--modal-animation-duration, 0.3s) ease;
}

@keyframes modalSlideIn {
    from { transform: scale(0.8) translateY(-20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
    padding: var(--modal-padding, 20px);
    border-bottom: 1px solid var(--modal-header-border-color, #dee2e6);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--modal-close-btn-color, #666666);
    transition: color 0.2s ease;
}

.modal-close:hover {
    border-radius: 50%;
    color: var(--modal-close-btn-hover-color, #000000);
    background-color: rgba(0,0,0,0.1);
}

.modal-close:focus {
    outline: var(--focus-outline-width, 2px) solid var(--focus-outline-color, #007cba);
    outline-offset: var(--focus-outline-offset, 2px);
}

.modal-body {
    padding: var(--modal-padding, 20px);
}

#history-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.history-entry {
    border-bottom: 1px solid #eee;
    padding: 15px 0;
}

.history-entry:last-child {
    border-bottom: none;
}

.history-date {
    font-weight: bold;
    color: #333;
    margin-bottom: 8px;
}

.history-change {
    margin: 5px 0;
    padding: 5px 0;
}

.history-change-type {
    font-weight: 500;
    color: #666;
}

.price-change {
    margin-left: 10px;
}

.price-old {
    text-decoration: line-through;
    color: #999;
}

.price-new {
    color: #007cba;
    font-weight: 500;
}

/* Status Display Style Variations */
/* Badge style (default) */
.resources-list-block [class*="ujc-status-"].ujc-status-style-badge,
.ujc-shortcode-resources-list [class*="ujc-status-"].ujc-status-style-badge {
    border: 1px solid rgba(0,0,0,0.1);
}

/* Pill style */
.resources-list-block [class*="ujc-status-"].ujc-status-style-pill,
.ujc-shortcode-resources-list [class*="ujc-status-"].ujc-status-style-pill {
    border-radius: 50px !important;
    border: none;
}

/* Highlight style */
.resources-list-block [class*="ujc-status-"].ujc-status-style-highlight,
.ujc-shortcode-resources-list [class*="ujc-status-"].ujc-status-style-highlight {
    opacity: 0.9;
    font-weight: bold;
}

/* Underline style */
.resources-list-block [class*="ujc-status-"].ujc-status-style-underline,
.ujc-shortcode-resources-list [class*="ujc-status-"].ujc-status-style-underline {
    background-color: transparent !important;
    border-bottom: 2px solid currentColor;
    border-radius: 0 !important;
    padding-top: 2px;
    padding-bottom: 2px;
}

/* Plain style */
.resources-list-block [class*="ujc-status-"].ujc-status-style-plain,
.ujc-shortcode-resources-list [class*="ujc-status-"].ujc-status-style-plain {
    background-color: transparent !important;
    border: none;
    border-radius: 0 !important;
    padding: 0;
}

/* Responsive design */
@media (max-width: 768px) {
    .resources-table {
        font-size: 0.875em;
    }

    .resources-table th,
    .resources-table td {
        padding: var(--table-padding, 12px 15px) !important;
    }

    .resources-table th:nth-child(2),
    .resources-table td:nth-child(2) {
        display: none;
    }
}

@media (max-width: 480px) {
    .resources-table th,
    .resources-table td {
        padding: var(--table-padding, 12px 15px) !important;
        font-size: 0.8em;
    }

    .resources-table th:nth-child(4),
    .resources-table td:nth-child(4) {
        display: none;
    }
}

/* Gutenberg Block Editor - Drag & Drop Styles */
.components-panel__body .column-item {
    transition: all 0.2s ease;
    user-select: none;
}

.components-panel__body .column-item:hover {
    border-color: #007cba !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.components-panel__body .column-item.dragging {
    opacity: 0.6;
    transform: rotate(2deg);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

.components-panel__body .column-item.drag-over {
    border-color: #00a32a !important;
    background-color: #e7f7e3 !important;
    border-style: dashed;
}

/* Drag handle hover effect */
.components-panel__body .column-item span[style*="cursor: grab"]:hover {
    color: #007cba !important;
}

.components-panel__body .column-item span[style*="cursor: grab"]:active {
    cursor: grabbing !important;
    color: #005a87 !important;
}

/* Remove button hover effect */
.components-panel__body .column-item button[title="Usuń kolumnę"]:hover {
    background-color: #b32d2e !important;
    transform: scale(1.1);
}

/* Input focus styling */
.components-panel__body .column-item input:focus {
    border-color: #007cba !important;
    box-shadow: 0 0 0 1px #007cba;
    outline: none;
}

/* Add column buttons styling */
.components-panel__body button[title="Dodaj kolumnę"]:hover {
    background-color: #007cba !important;
    color: white !important;
    border-color: #005a87 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.components-panel__body button[title="Dodaj kolumnę"]:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Block preview enhancements */
.resources-list-block-placeholder {
    transition: all 0.3s ease;
}

.resources-list-block-placeholder:hover {
    border-color: #007cba !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Empty state styling */
.components-panel__body p[style*="fontStyle: italic"] {
    padding: 12px;
    background-color: #f0f0f1;
    border-radius: 4px;
    border-left: 3px solid #ddd;
}

/* Grid layout improvements */
.components-panel__body div[style*="grid-template-columns"] button {
    transition: all 0.2s ease;
}

/* Frontend Table Sorting Styles */
.sortable-header {
    position: relative;
    user-select: none;
    transition: background-color 0.2s ease;
}

.sortable-header:hover {
    background-color: color-mix(in srgb, var(--header-bg-color, #f9f9f9) 85%, black 15%) !important;
}

.sort-indicator {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 10px;
    opacity: 0.4;
    transition: opacity 0.2s ease, color 0.2s ease;
    line-height: 1;
    color: var(--header-text-color, #333333);
}

.sortable-header:hover .sort-indicator {
    opacity: 0.7;
}

.sort-indicator.active {
    opacity: 1;
    color: var(--apply-btn-bg-color, #007cba);
}

/* Accessibility for sortable headers */
.sortable-header:focus {
    outline: 2px solid var(--apply-btn-bg-color, #007cba);
    outline-offset: 2px;
}

/* Loading state (when attributes are being saved) */
.components-panel__body.is-saving {
    pointer-events: none;
    opacity: 0.7;
}

.components-panel__body.is-saving::after {
    content: "Zapisywanie...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    color: #666;
}