/* LPB Property Table - Frontend Styles */

.lpb-property-table {
    --lpb-primary-color: #0073aa;
    --lpb-secondary-color: #f1f1f1;
    --lpb-text-color: #333333;
    --lpb-border-color: #ddd;
    --lpb-success-color: #4caf50;
    --lpb-warning-color: #ff9800;
    --lpb-danger-color: #f44336;
    
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    margin: 20px 0;
    color: var(--lpb-text-color);
}

/* Filtry */
.lpb-filters {
    background: var(--lpb-secondary-color);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.lpb-filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
}

.lpb-filter-group {
    display: flex;
    flex-direction: column;
    min-width: 120px;
    flex: 1;
}

.lpb-filter-group label {
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lpb-filter-group select,
.lpb-filter-group input {
    padding: 8px 12px;
    border: 2px solid var(--lpb-border-color);
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.lpb-filter-group select:focus,
.lpb-filter-group input:focus {
    outline: none;
    border-color: var(--lpb-primary-color);
    box-shadow: 0 0 0 2px rgba(0,115,170,0.1);
}

.lpb-filters-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Przyciski */
.lpb-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    line-height: 1;
}

.lpb-btn-primary {
    background-color: var(--lpb-primary-color);
    color: white;
}

.lpb-btn-primary:hover {
    background-color: color-mix(in srgb, var(--lpb-primary-color) 85%, black);
    transform: translateY(-1px);
}

.lpb-btn-secondary {
    background-color: transparent;
    color: var(--lpb-text-color);
    border: 2px solid var(--lpb-border-color);
}

.lpb-btn-secondary:hover {
    background-color: var(--lpb-secondary-color);
    border-color: var(--lpb-primary-color);
}

.lpb-btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* Przełącznik widoku */
#lpb-toggle-view .lpb-view-full,
.lpb-property-table[data-view="simple"] #lpb-toggle-view .lpb-view-simple {
    display: inline;
}

#lpb-toggle-view .lpb-view-simple,
.lpb-property-table[data-view="simple"] #lpb-toggle-view .lpb-view-full {
    display: none;
}

/* Loading */
.lpb-loading {
    text-align: center;
    padding: 40px;
}

.lpb-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--lpb-secondary-color);
    border-top: 4px solid var(--lpb-primary-color);
    border-radius: 50%;
    animation: lpb-spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes lpb-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Tabela */
.lpb-table-responsive {
    overflow-x: auto;
    margin: 20px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-radius: 8px;
}

.lpb-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

/* Column widths for simple view */
.lpb-simple-view .lpb-table th:nth-child(7), /* Cena lokalu */
.lpb-simple-view .lpb-table td:nth-child(7) {
    width: 120px;
    min-width: 120px;
}

.lpb-simple-view .lpb-table th:nth-child(9), /* Szczegóły */
.lpb-simple-view .lpb-table td:nth-child(9) {
    width: 80px;
    min-width: 80px;
}

.lpb-table thead th {
    background-color: var(--lpb-primary-color);
    color: white;
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.lpb-table tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--lpb-border-color);
    vertical-align: top;
}

.lpb-table tbody tr:hover {
    background-color: rgba(0,115,170,0.05);
}

.lpb-table tbody tr:last-child td {
    border-bottom: none;
}

/* Status */
.lpb-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lpb-status.available {
    background-color: var(--lpb-success-color);
    color: white;
}

.lpb-status.reserved {
    background-color: var(--lpb-warning-color);
    color: white;
}

.lpb-status.sold {
    background-color: var(--lpb-danger-color);
    color: white;
}

.lpb-property-row.available {
    border-left: 4px solid var(--lpb-success-color);
}

.lpb-property-row.reserved {
    border-left: 4px solid var(--lpb-warning-color);
    opacity: 0.85;
}

.lpb-property-row.sold {
    border-left: 4px solid var(--lpb-danger-color);
    opacity: 0.7;
}

/* Brak danych */
.lpb-not-available {
    color: #999;
    font-style: italic;
    font-size: 13px;
}

.lpb-no-results {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 16px;
    background: var(--lpb-secondary-color);
    border-radius: 8px;
}

/* Tooltips */
.lpb-tooltip {
    cursor: help;
    position: relative;
}

.lpb-tooltip-content {
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    max-width: 200px;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.lpb-tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0,0,0,0.9);
}

/* Responsywność - Mobile First */
@media (max-width: 768px) {
    .lpb-filters-row {
        flex-direction: column;
    }
    
    .lpb-filter-group {
        min-width: auto;
    }
    
    .lpb-filters-actions {
        justify-content: center;
    }
    
    .lpb-btn {
        flex: 1;
        min-width: 120px;
    }
    
    /* Mobilna tabela */
    .lpb-table-responsive {
        box-shadow: none;
        border-radius: 0;
    }
    
    .lpb-table,
    .lpb-table thead,
    .lpb-table tbody,
    .lpb-table th,
    .lpb-table td,
    .lpb-table tr {
        display: block;
    }
    
    .lpb-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .lpb-table tr {
        background: white;
        border: 1px solid var(--lpb-border-color);
        border-radius: 8px;
        margin-bottom: 15px;
        padding: 15px;
        position: relative;
    }
    
    .lpb-table td {
        border: none;
        padding: 8px 0;
        position: relative;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
    }
    
    .lpb-table td:before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: var(--lpb-primary-color);
        font-size: 13px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-right: 10px;
        flex-shrink: 0;
    }
    
    .lpb-property-row.available::before {
        content: "DOSTĘPNE";
        position: absolute;
        top: -1px;
        right: -1px;
        background: var(--lpb-success-color);
        color: white;
        padding: 4px 8px;
        font-size: 10px;
        font-weight: 600;
        border-radius: 0 8px 0 8px;
    }
    
    .lpb-property-row.reserved::before {
        content: "REZ.";
        position: absolute;
        top: -1px;
        right: -1px;
        background: var(--lpb-warning-color);
        color: white;
        padding: 4px 8px;
        font-size: 10px;
        font-weight: 600;
        border-radius: 0 8px 0 8px;
    }
    
    .lpb-property-row.sold::before {
        content: "SPRZEDANE";
        position: absolute;
        top: -1px;
        right: -1px;
        background: var(--lpb-danger-color);
        color: white;
        padding: 4px 8px;
        font-size: 10px;
        font-weight: 600;
        border-radius: 0 8px 0 8px;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .lpb-filters-row {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .lpb-table {
        font-size: 14px;
    }
    
    .lpb-table thead th,
    .lpb-table tbody td {
        padding: 10px 8px;
    }
}

/* Desktop - ukrywanie kolumn w widoku uproszczonym */
@media (min-width: 769px) {
    .lpb-simple-view .lpb-table th:not(:nth-child(1)):not(:nth-child(2)):not(:nth-child(3)):not(:nth-child(4)):not(:nth-child(5)):not(:nth-child(6)):not(:nth-child(7)):not(:nth-child(8)):not(:nth-child(9)),
    .lpb-simple-view .lpb-table td:not(:nth-child(1)):not(:nth-child(2)):not(:nth-child(3)):not(:nth-child(4)):not(:nth-child(5)):not(:nth-child(6)):not(:nth-child(7)):not(:nth-child(8)):not(:nth-child(9)) {
        display: none;
    }
}

/* Animacje */
.lpb-property-table * {
    transition: all 0.3s ease;
}

.lpb-table tbody tr {
    animation: lpb-fadeIn 0.5s ease-in-out;
}

@keyframes lpb-fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dostępność */
.lpb-table:focus-within {
    outline: 2px solid var(--lpb-primary-color);
    outline-offset: 2px;
}

.lpb-btn:focus {
    outline: 2px solid var(--lpb-primary-color);
    outline-offset: 2px;
}

/* Paginacja */
.lpb-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 30px 0;
    padding: 20px;
    background: var(--lpb-secondary-color);
    border-radius: 8px;
    flex-wrap: wrap;
    gap: 15px;
}

.lpb-pagination-info {
    font-size: 14px;
    color: var(--lpb-text-color);
    font-weight: 500;
}

.lpb-pagination-links {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.lpb-pagination-btn {
    padding: 8px 12px;
    border: 2px solid var(--lpb-border-color);
    background: white;
    color: var(--lpb-text-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    min-width: 40px;
}

.lpb-pagination-btn:hover:not(:disabled) {
    background: var(--lpb-primary-color);
    color: white;
    border-color: var(--lpb-primary-color);
    transform: translateY(-1px);
}

.lpb-pagination-btn.current,
.lpb-pagination-btn:disabled {
    background: var(--lpb-primary-color);
    color: white;
    border-color: var(--lpb-primary-color);
    cursor: not-allowed;
}

.lpb-pagination-btn.current {
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0,115,170,0.3);
}

/* Responsywność paginacji */
@media (max-width: 768px) {
    .lpb-pagination {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .lpb-pagination-info {
        order: 2;
        font-size: 13px;
    }
    
    .lpb-pagination-links {
        order: 1;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .lpb-pagination-btn {
        padding: 10px 14px;
        min-width: 44px;
        font-size: 16px;
    }
}

/* Print styles */
@media print {
    .lpb-filters,
    .lpb-loading,
    .lpb-pagination {
        display: none !important;
    }
    
    .lpb-table {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .lpb-table thead th {
        background: #000 !important;
        color: #fff !important;
    }
}

/* Modal popup dla szczegółów */
.lpb-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lpb-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    cursor: pointer;
}

.lpb-modal-content {
    position: relative;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 90vh;
    width: 800px;
    overflow: hidden;
    z-index: 10000;
}

.lpb-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: var(--lpb-primary-color, #0073aa);
    color: white;
    border-bottom: 1px solid #ddd;
}

.lpb-modal-header h2 {
    margin: 0;
    font-size: 1.4em;
    font-weight: 600;
}

.lpb-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    transition: opacity 0.2s;
}

.lpb-modal-close:hover {
    opacity: 0.7;
}

.lpb-modal-body {
    padding: 30px;
    max-height: calc(90vh - 100px);
    overflow-y: auto;
}

.lpb-loading-modal {
    text-align: center;
    padding: 40px;
}

.lpb-loading-modal .lpb-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 20px;
}

/* Szczegóły nieruchomości */
.lpb-property-details {
    font-size: 14px;
}

.lpb-detail-row {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.lpb-detail-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.lpb-detail-row h3 {
    margin: 0 0 15px 0;
    font-size: 1.2em;
    color: var(--lpb-primary-color, #0073aa);
    font-weight: 600;
}

.lpb-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.lpb-detail-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.lpb-detail-item strong {
    color: #333;
    font-weight: 600;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lpb-detail-item span {
    font-size: 1.1em;
    color: #666;
}

.lpb-detail-item .lpb-highlight {
    font-weight: 600;
    color: var(--lpb-primary-color, #0073aa);
    font-size: 1.2em;
}

.lpb-detail-item .lpb-price {
    font-weight: 600;
    color: #2e7d32;
}

.lpb-detail-item .lpb-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
    width: fit-content;
}

.lpb-detail-item .lpb-status.available {
    background: #e8f5e8;
    color: #2e7d32;
}

.lpb-detail-item .lpb-status.reserved {
    background: #fff3e0;
    color: #f57c00;
}

.lpb-detail-item .lpb-status.sold {
    background: #ffeaea;
    color: #d32f2f;
}

.lpb-detail-text {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 5px;
    border-left: 4px solid var(--lpb-primary-color, #0073aa);
    font-style: italic;
    color: #555;
}

.lpb-detail-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.lpb-detail-actions .lpb-btn {
    padding: 12px 20px;
    text-decoration: none;
    border-radius: 5px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.lpb-detail-actions .lpb-btn-primary {
    background: var(--lpb-primary-color, #0073aa);
    color: white;
}

.lpb-detail-actions .lpb-btn-primary:hover {
    background: var(--lpb-primary-color-dark, #005a8b);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.lpb-detail-actions .lpb-btn-secondary {
    background: #6c757d;
    color: white;
}

.lpb-detail-actions .lpb-btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.lpb-not-available {
    color: #999;
    font-style: italic;
}

/* Przycisk szczegółów w tabeli */
.lpb-btn-details {
    background: transparent !important;
    color: var(--lpb-primary-color, #0073aa) !important;
    border: 1px solid var(--lpb-primary-color, #0073aa);
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
}

.lpb-btn-details:hover {
    background: var(--lpb-primary-color, #0073aa) !important;
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.3);
}

/* Desktop - tylko lupka */
@media (min-width: 769px) {
    .lpb-btn-details {
        width: 36px;
        height: 36px;
        padding: 8px;
        justify-content: center;
        border-radius: 50%;
        background: var(--lpb-primary-color, #0073aa) !important;
        color: white !important;
        border: none;
    }
    
    .lpb-btn-details .lpb-details-text {
        display: none;
    }
    
    .lpb-btn-details .lpb-details-icon {
        font-size: 1.1em;
    }
    
    .lpb-btn-details:hover {
        background: var(--lpb-primary-color-dark, #005a8b) !important;
    }
}

/* Mobile - tylko tekst */
@media (max-width: 768px) {
    .lpb-btn-details {
        background: transparent !important;
        color: var(--lpb-primary-color, #0073aa) !important;
        border: none;
        padding: 8px 4px;
        text-decoration: underline;
        font-weight: 500;
    }
    
    .lpb-btn-details .lpb-details-icon {
        display: none;
    }
    
    .lpb-btn-details:hover {
        background: transparent !important;
        color: var(--lpb-primary-color-dark, #005a8b) !important;
        transform: none;
        box-shadow: none;
    }
}

/* Historia cen */
.lpb-price-history {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
}

.lpb-price-entry {
    background: white;
    padding: 15px;
    border-radius: 5px;
    border-left: 4px solid var(--lpb-primary-color, #0073aa);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.lpb-price-date {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.lpb-price-date strong {
    color: var(--lpb-primary-color, #0073aa);
    font-size: 0.95em;
}

.lpb-price-date small {
    color: #666;
    font-size: 0.85em;
}

.lpb-price-changes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 10px;
}

.lpb-price-change {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.lpb-price-label {
    font-size: 0.85em;
    color: #333;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lpb-price-value {
    color: #333;
    font-weight: 600;
    font-size: 1.05em;
}

.lpb-price-note {
    background: #f0f8ff;
    padding: 8px 12px;
    border-radius: 3px;
    border-left: 3px solid #0073aa;
    font-size: 0.9em;
    color: #555;
    margin-top: 8px;
}

.lpb-price-note em {
    font-style: italic;
}


/* Responsywność dla modal */
@media (max-width: 768px) {
    .lpb-modal-content {
        width: 95vw;
        max-height: 95vh;
        margin: 20px;
    }
    
    .lpb-modal-header {
        padding: 15px 20px;
    }
    
    .lpb-modal-header h2 {
        font-size: 1.2em;
    }
    
    .lpb-modal-body {
        padding: 20px;
    }
    
    .lpb-detail-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .lpb-detail-actions {
        flex-direction: column;
    }
    
    .lpb-detail-actions .lpb-btn {
        text-align: center;
        justify-content: center;
    }
    
    /* Historia cen na mobile */
    .lpb-price-changes {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .lpb-price-date {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

/* Historia cen - paginacja */
.lpb-history-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.lpb-history-info {
    color: #6c757d;
    font-size: 0.9em;
    font-weight: 500;
}

.lpb-history-prev,
.lpb-history-next {
    background: var(--lpb-primary-color, #0073aa) !important;
    color: white !important;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s;
    text-decoration: none;
}

.lpb-history-prev:hover,
.lpb-history-next:hover {
    background: var(--lpb-primary-color-dark, #005a8b) !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.3);
}

@media (max-width: 768px) {
    .lpb-history-pagination {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .lpb-history-info {
        order: 2;
    }
    
    .lpb-history-prev,
    .lpb-history-next {
        min-width: 120px;
    }
}

/* Opcje niedostępne w szczegółach */
.lpb-detail-item span:contains("opcja niedostępna"),
.lpb-detail-item span[data-unavailable="true"] {
    color: #999;
    font-style: italic;
    opacity: 0.7;
}
