/**
 * HOA Management System — Property Details Overlay
 *
 * Visual-only adaptation for renderPropertyDetailsPage. Mirrors the design
 * language established by dashboard.css and shell.css.
 *
 * Strict rules:
 *   - Token-driven only (tokens.css).
 *   - Wrapper class .prop-shell is the ONLY new DOM hook required.
 *   - All existing IDs (#propDetailTabs, #propTab-*, #propTab-*-content),
 *     classes (.edit-btn, .view-soa-btn, .ps-prop-assign-btn), and event
 *     wiring are preserved untouched.
 *   - Dynamic inline styles emitted by JS for the behavior-analysis card
 *     (border-top color, badge colors, timeline dot colors) are kept as-is.
 *   - Dark mode comes for free via [data-theme="dark"] semantic tokens.
 *
 * Loaded after css/style.css and css/shell.css.
 */

/* ═══════════════════════════════════════════════════════════════════════════
   LOCAL TOKENS
═══════════════════════════════════════════════════════════════════════════ */
.prop-shell {
    --prop-radius-lg: 16px;
    --prop-radius-md: 12px;
    --prop-radius-sm: 10px;
    --prop-radius-pill: 999px;
    --prop-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --prop-transition: 0.2s var(--prop-ease);
    --prop-transition-slow: 0.3s var(--prop-ease);
    --prop-font: "Figtree", "Inter", -apple-system, BlinkMacSystemFont,
                 "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    font-family: var(--prop-font);
    color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   PAGE HEADER (title row)
═══════════════════════════════════════════════════════════════════════════ */
.prop-shell .prop-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--prop-radius-lg);
    box-shadow: var(--shadow-xs);
    padding: 18px 22px;
    margin-bottom: 16px;
    transition: box-shadow var(--prop-transition);
}
.prop-shell .prop-page-header:hover { box-shadow: var(--shadow-sm); }

.prop-shell .prop-page-header h1 {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0;
}
.prop-shell .prop-page-header small {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.prop-shell .prop-page-header .btn {
    border-radius: var(--prop-radius-sm);
    font-weight: 600;
    font-size: 0.82rem;
    padding: 7px 12px;
    transition: background var(--prop-transition),
                border-color var(--prop-transition),
                color var(--prop-transition),
                transform var(--prop-transition),
                box-shadow var(--prop-transition);
}
.prop-shell .prop-page-header .btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-xs); }

/* ═══════════════════════════════════════════════════════════════════════════
   QUICK ACTIONS BAR
═══════════════════════════════════════════════════════════════════════════ */
.prop-shell .prop-actions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--prop-radius-md);
    padding: 12px 14px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-xs);
}
.prop-shell .prop-actions-bar .btn {
    border-radius: var(--prop-radius-pill);
    font-weight: 600;
    font-size: 0.8rem;
    padding: 6px 14px;
    transition: background var(--prop-transition),
                border-color var(--prop-transition),
                color var(--prop-transition),
                transform var(--prop-transition),
                box-shadow var(--prop-transition);
}
.prop-shell .prop-actions-bar .btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.prop-shell .prop-actions-bar .btn:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

/* ═══════════════════════════════════════════════════════════════════════════
   DELINQUENCY ALERT
═══════════════════════════════════════════════════════════════════════════ */
.prop-shell > .alert-danger {
    background: var(--bg-danger) !important;
    border: 1px solid var(--color-red-400) !important;
    border-left: 4px solid var(--color-red-500) !important;
    border-radius: var(--prop-radius-md) !important;
    color: var(--text-primary) !important;
    padding: 14px 18px !important;
    margin-bottom: 16px !important;
    box-shadow: var(--shadow-xs);
}
.prop-shell > .alert-danger .alert-heading {
    color: var(--text-danger);
    font-weight: 700;
    font-size: 1rem;
}
.prop-shell > .alert-danger strong { color: var(--text-danger); }

/* ═══════════════════════════════════════════════════════════════════════════
   ACCOUNT SUMMARY STRIP (4 KPI cards)
═══════════════════════════════════════════════════════════════════════════ */
.prop-shell > .row.g-3.mb-4 .card,
.prop-shell .prop-summary .card {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-default) !important;
    border-radius: var(--prop-radius-md) !important;
    box-shadow: var(--shadow-xs) !important;
    padding: 16px !important;
    transition: transform var(--prop-transition),
                box-shadow var(--prop-transition),
                border-color var(--prop-transition);
}
.prop-shell > .row.g-3.mb-4 .card:hover,
.prop-shell .prop-summary .card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md) !important;
    border-color: var(--brand-primary-border) !important;
}
.prop-shell > .row.g-3.mb-4 .card .text-muted.small,
.prop-shell .prop-summary .text-muted.small {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    font-size: 0.7rem !important;
    color: var(--text-secondary) !important;
    margin-bottom: 6px;
}
.prop-shell > .row.g-3.mb-4 .card .fs-4 {
    font-size: 1.4rem !important;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.prop-shell > .row.g-3.mb-4 .card.border-success {
    border-color: var(--color-green-300) !important;
    border-top: 3px solid var(--brand-primary) !important;
}
.prop-shell > .row.g-3.mb-4 .card.border-danger {
    border-color: var(--color-red-400) !important;
    border-top: 3px solid var(--color-red-500) !important;
}

/* Standing badge in summary strip */
.prop-shell > .row.g-3.mb-4 .badge {
    border-radius: var(--prop-radius-pill);
    padding: 5px 12px;
    font-weight: 700;
    font-size: 0.75rem !important;
    letter-spacing: 0.02em;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TABS — modern underline style (replaces Bootstrap nav-tabs default)
═══════════════════════════════════════════════════════════════════════════ */
.prop-shell #propDetailTabs {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default) !important;
    border-radius: var(--prop-radius-md) var(--prop-radius-md) 0 0;
    border-bottom: none !important;
    padding: 6px 8px 0;
    margin: 0 !important;
    box-shadow: var(--shadow-xs);
    /* Override the inline border-bottom:2px solid #e2e8f0; rule on the element */
    border-bottom-width: 0 !important;
}

.prop-shell #propDetailTabs .nav-item { margin: 0; }

.prop-shell #propDetailTabs .nav-link {
    background: transparent !important;
    border: none !important;
    border-radius: var(--prop-radius-sm) var(--prop-radius-sm) 0 0 !important;
    color: var(--text-secondary) !important;
    font-size: 0.85rem;
    font-weight: 600 !important;
    padding: 10px 14px !important;
    margin: 0;
    position: relative;
    transition: color var(--prop-transition),
                background var(--prop-transition);
}
.prop-shell #propDetailTabs .nav-link i {
    color: var(--text-muted);
    transition: color var(--prop-transition),
                transform var(--prop-transition);
}
.prop-shell #propDetailTabs .nav-link:hover {
    color: var(--text-primary) !important;
    background: var(--bg-hover) !important;
}
.prop-shell #propDetailTabs .nav-link:hover i { color: var(--text-primary); transform: scale(1.04); }
.prop-shell #propDetailTabs .nav-link:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
    z-index: 1;
}

.prop-shell #propDetailTabs .nav-link.active {
    color: var(--brand-primary) !important;
    background: var(--brand-primary-subtle) !important;
}
.prop-shell #propDetailTabs .nav-link.active i { color: var(--brand-primary); }
.prop-shell #propDetailTabs .nav-link.active::after {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: -1px;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--brand-primary);
}

/* Tab content panel — visually attaches to the tab strip */
.prop-shell .tab-content {
    background: transparent;
    margin-top: 0 !important;
    padding-top: 18px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CARDS (within tab panes)
═══════════════════════════════════════════════════════════════════════════ */
.prop-shell .tab-content .card {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-default) !important;
    border-radius: var(--prop-radius-md) !important;
    box-shadow: var(--shadow-xs) !important;
    transition: box-shadow var(--prop-transition),
                border-color var(--prop-transition),
                transform var(--prop-transition);
    overflow: hidden;
}
.prop-shell .tab-content .card:hover {
    box-shadow: var(--shadow-sm) !important;
    border-color: var(--brand-primary-border) !important;
}
/* Behavior analysis card already has dynamic border-top inline — preserve it,
   just keep the rest of the card consistent. */

.prop-shell .tab-content .card-header {
    background: var(--bg-sunken) !important;
    border-bottom: 1px solid var(--border-default) !important;
    padding: 12px 16px !important;
    color: var(--text-primary);
    font-size: 0.9rem;
}
.prop-shell .tab-content .card-header strong {
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.prop-shell .tab-content .card-header i {
    color: var(--brand-primary);
    opacity: 0.9;
}

.prop-shell .tab-content .card-body { padding: 16px !important; color: var(--text-primary); }

.prop-shell .tab-content .card-footer {
    background: var(--bg-sunken) !important;
    border-top: 1px solid var(--border-default) !important;
    padding: 12px 16px !important;
}

.prop-shell .tab-content .card-body p { margin-bottom: 0.55rem; font-size: 0.88rem; line-height: 1.55; }
.prop-shell .tab-content .card-body p strong { color: var(--text-primary); font-weight: 600; }
.prop-shell .tab-content .card-body p:has(strong) { color: var(--text-secondary); }

.prop-shell .tab-content hr {
    border: 0;
    border-top: 1px solid var(--border-default);
    opacity: 1;
    margin: 12px 0;
}

/* Subtitle (e.g. "Total Arrears") */
.prop-shell .tab-content .card-subtitle {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    font-size: 0.7rem !important;
    color: var(--text-secondary) !important;
}

.prop-shell .tab-content .fs-2 {
    font-size: 1.85rem !important;
    font-weight: 700;
    letter-spacing: -0.025em;
}

/* h6 inside card-body (e.g. "Arrears / Dues Ledger") */
.prop-shell .tab-content .card-body h6 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    font-weight: 700;
    margin-bottom: 10px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TABLES (arrears ledger, payment history)
═══════════════════════════════════════════════════════════════════════════ */
.prop-shell .tab-content .table {
    margin-bottom: 0;
    color: var(--text-primary);
    border-color: var(--border-default);
}
.prop-shell .tab-content .table thead th {
    background: var(--bg-sunken);
    border-bottom: 1px solid var(--border-default);
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 10px 12px;
    position: sticky;
    top: 0;
    z-index: 1;
}
.prop-shell .tab-content .table tbody td {
    border-color: var(--border-default);
    padding: 11px 12px;
    font-size: 0.86rem;
    vertical-align: middle;
}
.prop-shell .tab-content .table.table-hover tbody tr {
    transition: background var(--prop-transition);
}
.prop-shell .tab-content .table.table-hover tbody tr:hover {
    background: var(--bg-hover);
}
.prop-shell .tab-content .table tbody tr:last-child td { border-bottom: none; }
.prop-shell .tab-content .table-responsive {
    border-radius: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border-default) transparent;
}
.prop-shell .tab-content .table-responsive::-webkit-scrollbar { width: 6px; height: 6px; }
.prop-shell .tab-content .table-responsive::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 3px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BADGES (status, fines, AR/OR receipt type, etc.)
═══════════════════════════════════════════════════════════════════════════ */
.prop-shell .tab-content .badge,
.prop-shell .alert .badge {
    border-radius: var(--prop-radius-pill);
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 4px 9px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PROPERTY TIMELINE / HISTORY LIST GROUP
═══════════════════════════════════════════════════════════════════════════ */
.prop-shell .tab-content .list-group-flush .list-group-item {
    border-color: var(--border-default);
    background: transparent;
    padding: 12px 16px;
    transition: background var(--prop-transition);
}
.prop-shell .tab-content .list-group-flush .list-group-item:hover {
    background: var(--bg-hover);
}
.prop-shell .tab-content .list-group-flush .list-group-item p.fw-bold {
    font-size: 0.88rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.prop-shell .tab-content .list-group-flush .list-group-item small {
    color: var(--text-muted);
    font-size: 0.75rem;
}
.prop-shell .tab-content .list-group-flush .list-group-item p:not(.fw-bold) {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 4px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ALERTS (info / warning inside tab panes)
═══════════════════════════════════════════════════════════════════════════ */
.prop-shell .tab-content .alert,
.prop-shell .card-body .alert {
    border-radius: var(--prop-radius-sm);
    padding: 10px 14px !important;
    font-size: 0.85rem;
    border-width: 1px;
    border-left-width: 3px;
}
.prop-shell .alert-info {
    background: var(--bg-info) !important;
    border-color: var(--color-blue-400) !important;
    color: var(--text-primary) !important;
}
.prop-shell .alert-warning {
    background: var(--bg-warning) !important;
    border-color: var(--color-amber-400) !important;
    color: var(--text-primary) !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PAYMENT BEHAVIOR ANALYSIS — polish without overriding dynamic colors
═══════════════════════════════════════════════════════════════════════════ */
.prop-shell .tab-content .card[style*="border-top"] .card-header .badge {
    /* Behavior badge already has inline color/bg — keep it, just round it */
    border-radius: var(--prop-radius-pill);
    padding: 5px 12px !important;
    font-weight: 700;
    box-shadow: var(--shadow-xs);
}

/* The 4-stat row inside behavior card */
.prop-shell .tab-content .card-body .row.g-3.mb-3 .col-6 .fw-bold.fs-5 {
    font-size: 1.5rem !important;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.prop-shell .tab-content .card-body .row.g-3.mb-3 .col-6 .text-muted.small {
    font-size: 0.7rem !important;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-top: 2px;
}

/* Timeline dot grid — give the boxes a soft hover lift */
.prop-shell .tab-content .d-flex.flex-wrap.gap-0 > div {
    transition: transform var(--prop-transition),
                box-shadow var(--prop-transition);
}
.prop-shell .tab-content .d-flex.flex-wrap.gap-0 > div:hover {
    transform: scale(1.35);
    box-shadow: var(--shadow-sm);
    z-index: 2;
    position: relative;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOADING / EMPTY STATES (muted-text idiom — matches dashboard.css)
═══════════════════════════════════════════════════════════════════════════ */
.prop-shell .prop-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 32px 16px;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    text-align: center;
    background: transparent;
}
.prop-shell .prop-state.prop-state-empty { color: var(--text-muted); }
.prop-shell .prop-state .prop-state-hint {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 400;
}
/* Suppress any inline spinners that legacy lazy-loaders may inject */
.prop-shell .prop-state .spinner-border { display: none !important; }

/* Inside tab panes: suppress legacy spinner-loading state in lazy children
   if they still emit a Bootstrap spinner-border + "Loading..." block */
.prop-shell .tab-content .text-center.py-4 > .spinner-border {
    display: none;
}
.prop-shell .tab-content .text-center.py-4:has(> .spinner-border) {
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    padding: 32px 16px !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   AI INSIGHTS PANEL (if rendered into #propdetails-ai-panel)
═══════════════════════════════════════════════════════════════════════════ */
.prop-shell #propdetails-ai-panel:not(:empty) {
    background: linear-gradient(135deg,
        var(--brand-primary-subtle) 0%,
        var(--bg-sunken) 100%);
    border: 1px solid var(--brand-primary-border);
    border-radius: var(--prop-radius-md);
    padding: 14px 16px;
    margin-top: 16px;
    box-shadow: var(--shadow-xs);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS GENERIC (edit, save, etc. inside cards)
═══════════════════════════════════════════════════════════════════════════ */
.prop-shell .card-footer .btn {
    border-radius: var(--prop-radius-sm);
    font-weight: 600;
    font-size: 0.86rem;
    padding: 9px 14px;
    transition: background var(--prop-transition),
                border-color var(--prop-transition),
                transform var(--prop-transition),
                box-shadow var(--prop-transition);
}
.prop-shell .card-footer .btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.prop-shell .card-footer .btn-secondary {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: var(--brand-on-primary);
}
.prop-shell .card-footer .btn-secondary:hover {
    background: var(--brand-primary-hover);
    border-color: var(--brand-primary-hover);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .prop-shell .prop-page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .prop-shell #propDetailTabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    .prop-shell #propDetailTabs .nav-link {
        white-space: nowrap;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   REDUCED MOTION
═══════════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    .prop-shell .prop-page-header,
    .prop-shell .prop-actions-bar .btn,
    .prop-shell > .row.g-3.mb-4 .card,
    .prop-shell .tab-content .card,
    .prop-shell .tab-content .card-footer .btn,
    .prop-shell #propDetailTabs .nav-link,
    .prop-shell .tab-content .table.table-hover tbody tr,
    .prop-shell .tab-content .list-group-flush .list-group-item,
    .prop-shell .tab-content .d-flex.flex-wrap.gap-0 > div {
        transition: none !important;
        animation: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRINT
═══════════════════════════════════════════════════════════════════════════ */
@media print {
    .prop-shell .prop-actions-bar,
    .prop-shell #propDetailTabs { display: none !important; }
    .prop-shell .tab-content .tab-pane { display: block !important; opacity: 1 !important; }
    .prop-shell .tab-content .card { box-shadow: none !important; border: 1px solid #ccc !important; }
}
