/* Viking House - Apartments Table v4.0 */

.apartments-table-wrap {
    width: 100%;
}

.apartments-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.apartments-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
    table-layout: auto;
}

.apartments-table thead th {
    font-family: inherit;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--color-dark, #2B2B2B);
    padding: 14px 6px;
    border-bottom: 1px solid var(--color-dark, #2B2B2B);
    white-space: nowrap;
    position: relative;
}

.apartments-table thead th:first-child,
.apartments-table tbody td:first-child {
    padding-left: 12px;
}

.apartments-table thead th:last-child,
.apartments-table tbody td:last-child {
    padding-right: 0;
}

.apartments-table tbody td {
    font-family: inherit;
    font-size: 13px;
    font-weight: 400;
    color: var(--color-dark, #2B2B2B);
    padding: 12px 6px;
    white-space: nowrap;
}

.apartments-table tbody tr:nth-child(even) {
    background: #E1E0D9;
    border-radius: 6px;
}

.apartments-table tbody tr:nth-child(even) td:first-child {
    border-radius: 6px 0 0 6px;
}

.apartments-table tbody tr:nth-child(even) td:last-child {
    border-radius: 0 6px 6px 0;
}

/* Status badges */
.badge-available {
    display: inline-block;
    padding: 5px 14px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: #d4edda;
    color: #155724;
    border-radius: 20px;
    white-space: nowrap;
}

.badge-reserved {
    display: inline-block;
    padding: 5px 14px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: #fff3cd;
    color: #856404;
    border-radius: 20px;
    white-space: nowrap;
}

.badge-contract {
    display: inline-block;
    padding: 5px 14px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: #b69b86;
    color: #fff;
    border-radius: 20px;
    white-space: nowrap;
}

.badge-sold {
    display: inline-block;
    padding: 5px 14px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: var(--color-dark, #2B2B2B);
    color: #fff;
    border-radius: 20px;
    white-space: nowrap;
}

/* Dimming for unavailable rows */
.apartments-table tbody tr.row-sold td,
.apartments-table tbody tr.row-reserved td,
.apartments-table tbody tr.row-contract td {
    opacity: 0.55;
}

.apartments-table tbody tr.row-sold .badge-sold,
.apartments-table tbody tr.row-reserved .badge-reserved,
.apartments-table tbody tr.row-contract .badge-contract {
    opacity: 1;
}

.btn-table {
    display: inline-block;
    padding: 6px 16px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--color-dark, #2B2B2B);
    border: 1px solid var(--color-dark, #2B2B2B);
    border-radius: 50px;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-table:hover {
    background: var(--color-dark, #2B2B2B);
    color: #fff;
}

/* Tooltip on info icon */
.th-info {
    display: inline-flex;
    align-items: center;
    margin-left: 3px;
    cursor: pointer;
    color: var(--color-dark, #2B2B2B);
    opacity: 0.5;
    position: relative;
    vertical-align: middle;
}

.th-info svg {
    width: 12px;
    height: 12px;
}

.th-info:hover {
    opacity: 1;
}

.th-info::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #E8E7E2;
    color: var(--color-dark, #2B2B2B);
    font-size: 12px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.5;
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    white-space: normal;
    width: 220px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 10;
    pointer-events: none;
}

.th-info:hover::after {
    opacity: 1;
    visibility: visible;
}

/* History popover button */
.td-history {
    position: relative;
}

.btn-history {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--color-dark, #2B2B2B);
    border-radius: 50%;
    background: transparent;
    color: var(--color-dark, #2B2B2B);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-history:hover {
    background: var(--color-dark, #2B2B2B);
    color: #fff;
}

.btn-history svg {
    width: 14px;
    height: 14px;
}

/* History popover */
.history-popover {
    display: none;
    position: fixed;
    z-index: 9999;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    padding: 16px 20px;
    max-width: 90vw;
    white-space: normal;
}

.history-popover.open {
    display: block;
}

.history-popover-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-dark, #2B2B2B);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #E1E0D9;
}

.history-popover-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.history-popover-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.history-popover-table thead th {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.2px;
    color: #888;
    padding: 4px 8px 8px;
    text-align: left;
    border: none;
    white-space: normal;
    min-width: 70px;
    max-width: 130px;
    line-height: 1.35;
    vertical-align: bottom;
}

.history-popover-table tbody td {
    font-size: 12px;
    color: var(--color-dark, #2B2B2B);
    padding: 6px 8px;
    border-top: 1px solid #f0efea;
    white-space: nowrap;
}

.history-popover-table tbody td.td-comment {
    white-space: normal;
    max-width: 200px;
    font-style: italic;
    color: #666;
}

.history-popover-table tbody td strong {
    font-weight: 700;
}

/* Prospekt button below table */
.apartments-prospekt {
    margin-top: 24px;
    text-align: left;
    padding-left: 12px;
}

.btn-prospekt {
    padding: 10px 28px;
    font-size: 11px;
}

/* Mobile: disable CSS tooltips, use JS floating approach */
@media (max-width: 1199px) {
    .th-info::after {
        display: none !important;
    }

    .apartments-table {
        min-width: 900px;
    }
}

@media (max-width: 480px) {
    .apartments-table thead th,
    .apartments-table tbody td {
        padding: 10px 6px;
        font-size: 11px;
    }

    .history-popover {
        max-width: 95vw;
        padding: 12px;
    }
}
