/**
 * Resource Cards CSS
 * Styles for card/tile view of resources list
 * Uses CSS variables for dynamic styling from admin settings
 */

/* Grid Layout */
.resource-cards-grid {
    display: grid;
    gap: var(--card-gap, 20px);
    margin: var(--container-margin, 20px 0);
    width: 100%;
}

/* Grid columns based on cardsPerRow setting */
.cards-per-row-2 {
    grid-template-columns: repeat(2, 1fr);
}

.cards-per-row-3 {
    grid-template-columns: repeat(3, 1fr);
}

.cards-per-row-4 {
    grid-template-columns: repeat(4, 1fr);
}

.cards-per-row-6 {
    grid-template-columns: repeat(6, 1fr);
}

/* Individual Card Styling */
.resource-card {
    background: var(--card-bg-color, #ffffff);
    border: 1px solid var(--card-border-color, #e1e5e9);
    border-radius: var(--card-border-radius, 8px);
    padding: var(--card-padding, 16px);
    box-shadow: var(--card-shadow, 0 2px 4px rgba(0,0,0,0.1));
    font-family: var(--content-font-family, inherit);
    color: var(--text-color, #333);
    position: relative;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

.resource-card:hover {
    box-shadow: var(--card-hover-shadow, 0 4px 12px rgba(0,0,0,0.15));
    transform: translateY(-2px);
}

/* Clickable cards */
.resource-card.clickable-card {
    cursor: pointer;
}

.resource-card.clickable-card:hover {
    transform: translateY(-3px);
}

/* Card Header */
.card-header {
    margin-bottom: 16px;
    position: relative;
    min-height: 50px;
}

.card-title-area {
    padding-right: 100px; /* Space for fixed status badge */
}

.card-title {
    margin: 0;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-color, #333);
    font-family: var(--content-font-family, inherit);
    line-height: 1.3;
    word-break: break-word;
}

/* Status Badge - Fixed Position (Right Top Corner) */
.status-badge-fixed {
    position: absolute;
    top: 0;
    right: 0;
}

/* Status Styles for Cards */
.resource-cards-grid [class*="ujc-status-"] {
    display: inline-block;
    font-size: var(--status-font-size, 0.875em);
    padding: var(--status-padding, 4px 8px);
    border-radius: var(--status-border-radius, 4px);
    font-weight: var(--status-font-weight, normal);
    text-transform: capitalize;
    white-space: nowrap;
}

/* Status Colors - Using CSS Variables from admin settings */
.resource-cards-grid .ujc-status-available {
    background-color: var(--status-available-bg, #28a745);
    color: var(--status-available-color, #ffffff);
}

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

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

/* Status Display Style Variations for Cards */
.resource-cards-grid [class*="ujc-status-"].ujc-status-style-badge {
    border: 1px solid rgba(0,0,0,0.1);
}

.resource-cards-grid [class*="ujc-status-"].ujc-status-style-pill {
    border-radius: 50px !important;
    border: none;
}

.resource-cards-grid [class*="ujc-status-"].ujc-status-style-highlight {
    opacity: 0.9;
    font-weight: bold;
}

.resource-cards-grid [class*="ujc-status-"].ujc-status-style-underline {
    background-color: transparent !important;
    border-bottom: 2px solid currentColor;
    border-radius: 0 !important;
    padding-bottom: 2px;
}

.resource-cards-grid [class*="ujc-status-"].ujc-status-style-plain {
    background-color: transparent !important;
    border: none;
    border-radius: 0 !important;
    padding: 0;
}

/* Card Body */
.card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.card-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9em;
}

.card-field:last-child {
    border-bottom: none;
}

.field-label {
    font-weight: 500;
    color: #666;
    flex-shrink: 0;
    margin-right: 12px;
}

.field-value {
    font-weight: 600;
    color: var(--text-color, #333);
    text-align: right;
    word-break: break-word;
}

/* Special styling for price fields - using semantic classes */
.card-field.price-field .field-value {
    font-weight: 700;
}

/* Special styling for area fields */
.card-field.area-field .field-value {
    font-weight: 600;
}

/* Action Fields (buttons) */
.card-field.card-action {
    justify-content: center;
    border-bottom: none;
    padding-top: 12px;
}

/* Historia Button in Cards */
.card-field.card-action .ujc-historia-btn {
    background: var(--historia-btn-bg-color, #007cba);
    color: var(--historia-btn-text-color, #ffffff);
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    display: inline-block;
    text-align: center;
    min-width: 120px;
}

.card-field.card-action .ujc-historia-btn:hover {
    background: color-mix(in srgb, var(--historia-btn-bg-color, #007cba) 85%, black);
    transform: translateY(-1px);
}

/* Floor Plan Button in Cards */
.card-field.card-action .ujc-karta-btn,
.card-field.card-action .download-floorplan-btn {
    background: var(--karta-btn-bg-color, #007cba);
    color: var(--karta-btn-text-color, #ffffff);
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    display: inline-block;
    text-align: center;
    min-width: 120px;
}

.card-field.card-action .ujc-karta-btn:hover,
.card-field.card-action .download-floorplan-btn:hover {
    background: color-mix(in srgb, var(--karta-btn-bg-color, #007cba) 85%, black);
    transform: translateY(-1px);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .cards-per-row-4 {
        grid-template-columns: repeat(3, 1fr);
    }

    .cards-per-row-6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .resource-cards-grid {
        grid-template-columns: 1fr !important;
        gap: calc(var(--card-gap, 20px) * 0.8);
    }

    .card-title-area {
        padding-right: 80px;
    }

    .card-title {
        font-size: 1em;
    }

    .card-field {
        font-size: 0.85em;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .field-value {
        text-align: left;
        font-weight: 700;
    }
}

@media (max-width: 480px) {
    .resource-card {
        padding: calc(var(--card-padding, 16px) * 0.8);
    }

    .card-title {
        font-size: 0.95em;
    }

    .status-badge {
        font-size: 0.75em;
        padding: 3px 6px;
    }

    .card-field.card-action button,
    .card-field.card-action a {
        padding: 6px 12px;
        font-size: 0.8em;
        min-width: 100px;
    }
}

/* Loading State */
.resource-cards-grid.loading {
    opacity: 0.6;
    pointer-events: none;
}

.resource-cards-grid.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--historia-btn-bg-color, #007cba);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Price History Modal - Shared with Table View */
.price-history-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: var(--modal-z-index, 10000);
    display: flex;
    align-items: center;
    justify-content: center;
}

.price-history-modal .modal-content {
    background: var(--modal-background-color, #ffffff);
    border-radius: var(--modal-border-radius, 8px);
    max-width: var(--modal-max-width, 600px);
    width: 90%;
    padding: var(--modal-padding, 20px);
    box-shadow: var(--modal-box-shadow, 0 10px 30px rgba(0,0,0,0.3));
    max-height: 80vh;
    overflow-y: auto;
}

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

.price-history-modal .modal-header h3 {
    margin: 0;
    color: var(--text-color, #333);
}

.price-history-modal .close {
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: var(--modal-close-btn-color, #666666);
    transition: color 0.2s ease;
}

.price-history-modal .close:hover {
    color: var(--modal-close-btn-hover-color, #000000);
}