/**
 * Price Reporting Frontend Styles
 * Clean, Tailwind-inspired table styling
 */

/* ==========================================================================
   Table Container
   ========================================================================== */

.pr-table-wrapper {
    overflow-x: auto;
    margin: 24px 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
    scrollbar-color: var(--pr-header-bg, #667eea) #f0f0f0;
    scrollbar-width: thin;
}

.pr-table-wrapper::-webkit-scrollbar {
    height: 6px;
}

.pr-table-wrapper::-webkit-scrollbar-track {
    background: #f0f0f0;
}

.pr-table-wrapper::-webkit-scrollbar-thumb {
    background: var(--pr-header-bg, #667eea);
    border-radius: 3px;
}

/* ==========================================================================
   Main Table
   ========================================================================== */

.pr-units-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #374151;
}

/* ==========================================================================
   Table Header
   ========================================================================== */

.pr-units-table thead {
    background-color: var(--pr-header-bg, #4f46e5);
}

.pr-units-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: background-color 0.15s ease;
}

.pr-units-table th:first-child {
    border-top-left-radius: 8px;
}

.pr-units-table th:last-child {
    border-top-right-radius: 8px;
}

.pr-units-table th:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.pr-units-table th.pr-actions-header {
    text-align: center;
    width: 90px;
}

/* ==========================================================================
   Table Body
   ========================================================================== */

.pr-units-table tbody tr {
    transition: background-color 0.15s ease;
}

/* Alternating row colors - very subtle */
.pr-units-table tbody tr:nth-child(even) {
    background-color: #f9fafb;
}

.pr-units-table tbody tr:nth-child(odd) {
    background-color: #ffffff;
}

.pr-units-table tbody tr:hover {
    background-color: #f3f4f6;
}

.pr-units-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: middle;
}

.pr-units-table tbody tr:last-child td {
    border-bottom: none;
}

.pr-units-table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 8px;
}

.pr-units-table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 8px;
}

/* Unit number styling */
.pr-units-table td[data-field="unit_number"] {
    font-weight: 600;
    color: #111827;
}

/* Price styling - same as other text */
.pr-units-table td[data-field="price"],
.pr-units-table td[data-field="price_per_sqm"] {
    font-family: 'SF Mono', Monaco, monospace;
    white-space: nowrap;
}

/* Actions cell */
.pr-actions-cell {
    text-align: center;
    white-space: nowrap;
}

/* ==========================================================================
   Icons
   ========================================================================== */

.pr-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin: 0 3px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: transparent;
    border: none;
    padding: 0;
    color: #6b7280;
}

.pr-icon:hover {
    background: #f3f4f6;
    color: #4f46e5;
}

.pr-icon:active {
    transform: scale(0.95);
}

.pr-icon.disabled {
    color: #d1d5db;
    cursor: not-allowed;
}

.pr-icon.disabled:hover {
    background: transparent;
    transform: none;
}

.pr-icon svg {
    width: 18px;
    height: 18px;
}

/* ==========================================================================
   Modal
   ========================================================================== */

.pr-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.pr-modal-content {
    background: #fff;
    border-radius: 12px;
    width: 95%;
    max-width: 800px;
    height: 85vh;
    max-height: 600px;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: pr-modal-slide-in 0.2s ease-out;
    display: flex;
    flex-direction: column;
}

@keyframes pr-modal-slide-in {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.pr-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    background-color: var(--pr-header-bg, #4f46e5);
    color: #fff;
    flex-shrink: 0;
}

.pr-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.pr-modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background-color 0.15s ease;
}

.pr-modal-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.pr-modal-body {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ==========================================================================
   History Table (in modal)
   ========================================================================== */

.pr-history-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.pr-history-table th,
.pr-history-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.pr-history-table th {
    font-weight: 600;
    color: #374151;
    background: #f9fafb;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pr-history-table tbody tr:nth-child(even) {
    background-color: #f9fafb;
}

.pr-history-table tbody tr:hover {
    background-color: #f3f4f6;
}

.pr-history-loading,
.pr-history-empty {
    text-align: center;
    padding: 48px 20px;
    color: #6b7280;
    font-size: 15px;
}

/* ==========================================================================
   Messages
   ========================================================================== */

.pr-error {
    padding: 16px 20px;
    background: #fef2f2;
    border-left: 4px solid #ef4444;
    color: #991b1b;
    border-radius: 6px;
    margin: 20px 0;
    font-size: 14px;
}

.pr-no-units,
.pr-no-config {
    padding: 48px 24px;
    text-align: center;
    color: #6b7280;
    background: #f9fafb;
    border-radius: 8px;
    margin: 20px 0;
    font-size: 15px;
}

/* ==========================================================================
   Sort Indicators
   ========================================================================== */

.pr-units-table th.sortable::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 8px;
    vertical-align: middle;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid rgba(255, 255, 255, 0.5);
    transition: all 0.15s ease;
}

.pr-units-table th.sort-asc::after {
    border-top: none;
    border-bottom: 4px solid #fff;
}

.pr-units-table th.sort-desc::after {
    border-top: 4px solid #fff;
}

/* ==========================================================================
   Shortcode: Unit Count
   ========================================================================== */

.pr-count-number {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.pr-count-badge {
    display: inline-block;
    padding: 6px 14px;
    background: #4f46e5;
    color: #fff;
    border-radius: 9999px;
    font-size: 14px;
    font-weight: 500;
}

.pr-count-badge.pr-count-empty {
    background: #e5e7eb;
    color: #6b7280;
}

.pr-count-text {
    font-size: 15px;
    color: #374151;
}

.pr-count-text strong {
    color: #111827;
    font-weight: 600;
}

.pr-count-range {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 16px;
    font-weight: 500;
    color: #111827;
}

.pr-count-error {
    color: #ef4444;
}

.pr-count-empty {
    color: #9ca3af;
    font-style: italic;
}

/* ==========================================================================
   Shortcode: Unit List
   ========================================================================== */

.pr-shortcode-error {
    padding: 16px 20px;
    background: #fef2f2;
    border-left: 4px solid #ef4444;
    color: #991b1b;
    border-radius: 6px;
    margin: 20px 0;
}

.pr-shortcode-empty {
    padding: 32px;
    text-align: center;
    color: #6b7280;
    background: #f9fafb;
    border-radius: 8px;
    margin: 20px 0;
}

/* List Layout */
.pr-unit-list-wrapper {
    margin: 24px 0;
}

.pr-list-title,
.pr-grid-title {
    font-size: 20px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 16px;
}

.pr-unit-list {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.pr-unit-list-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    gap: 20px;
    transition: background-color 0.15s ease;
}

.pr-unit-list-item:last-child {
    border-bottom: none;
}

.pr-unit-list-item:hover {
    background-color: #f9fafb;
}

.pr-unit-list-item.pr-unit-unavailable {
    opacity: 0.6;
}

.pr-unit-main {
    min-width: 140px;
}

.pr-unit-number {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.pr-unit-type {
    display: block;
    font-size: 13px;
    color: #6b7280;
    margin-top: 2px;
}

.pr-unit-details {
    display: flex;
    gap: 16px;
    flex: 1;
    color: #4b5563;
    font-size: 14px;
}

.pr-unit-area,
.pr-unit-rooms,
.pr-unit-floor {
    white-space: nowrap;
}

.pr-unit-price {
    min-width: 160px;
    text-align: right;
}

.pr-price-value {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    font-family: 'SF Mono', Monaco, monospace;
}

.pr-price-per-sqm {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
    font-family: 'SF Mono', Monaco, monospace;
}

.pr-unit-status {
    min-width: 100px;
    text-align: right;
}

.pr-status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
}

/* Grid Layout */
.pr-unit-grid-wrapper {
    margin: 24px 0;
}

.pr-unit-grid {
    display: grid;
    gap: 20px;
}

.pr-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.pr-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.pr-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.pr-unit-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.15s ease;
}

.pr-unit-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border-color: #d1d5db;
}

.pr-unit-card.pr-unit-unavailable {
    opacity: 0.6;
}

.pr-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.pr-card-number {
    font-size: 20px;
    font-weight: 600;
    color: #111827;
}

.pr-card-status {
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 500;
    color: #fff;
}

.pr-card-body {
    margin-bottom: 16px;
}

.pr-card-detail {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
}

.pr-card-detail:last-child {
    border-bottom: none;
}

.pr-label {
    color: #6b7280;
    font-size: 13px;
}

.pr-value {
    color: #374151;
    font-size: 14px;
    font-weight: 500;
}

.pr-card-footer {
    padding-top: 16px;
    border-top: 2px solid #f3f4f6;
}

.pr-card-price {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    font-family: 'SF Mono', Monaco, monospace;
}

.pr-card-ppm {
    font-size: 13px;
    color: #6b7280;
    font-family: 'SF Mono', Monaco, monospace;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .pr-table-wrapper {
        margin: 16px 0;
        border-radius: 6px;
    }
    
    .pr-units-table {
        font-size: 13px;
    }
    
    .pr-units-table th,
    .pr-units-table td {
        padding: 12px 10px;
    }
    
    .pr-modal-content {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .pr-modal-header {
        padding: 16px 20px;
    }
    
    .pr-modal-body {
        padding: 16px;
    }
    
    .pr-history-table th,
    .pr-history-table td {
        padding: 12px;
    }
    
    .pr-icon {
        width: 36px;
        height: 36px;
    }
}
