/**
 * SVG Floor Mapper - Frontend Styles
 *
 * @package SVG_Floor_Mapper
 * @since   1.0.0
 */

/* ==========================================================================
   Map Container
   ========================================================================== */

.sfm-floor-mapper {
    position: relative;
    max-width: 100%;
    font-family: inherit;
    line-height: 1.5;
}

.sfm-floor-mapper *,
.sfm-floor-mapper *::before,
.sfm-floor-mapper *::after {
    box-sizing: border-box;
}

.sfm-map-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
}

.sfm-bg-image {
    display: block;
    max-width: 100%;
    height: auto;
    user-select: none;
    -webkit-user-drag: none;
}

/* ==========================================================================
   SVG Zones
   ========================================================================== */

.sfm-overlay-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.sfm-overlay-svg .sfm-zone {
    cursor: pointer;
    pointer-events: all;
    transition: fill-opacity 0.25s ease, stroke-width 0.25s ease;
    outline: none;
}

.sfm-overlay-svg .sfm-zone:hover,
.sfm-overlay-svg .sfm-zone:focus-visible {
    fill: var(--sfm-hover-fill, inherit) !important;
    fill-opacity: 0.5 !important;
    stroke-width: 2;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.12));
}

.sfm-overlay-svg .sfm-zone-label {
    fill: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    text-anchor: middle;
    pointer-events: none;
    user-select: none;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sfm-overlay-svg .sfm-zone:hover + .sfm-zone-label {
    opacity: 1;
}

/* Static — zones invisible until hover, no animation needed */

/* ==========================================================================
   Tooltip / Popup
   ========================================================================== */

.sfm-tooltip {
    position: absolute;
    z-index: 999999;
    display: none;
    pointer-events: auto;
}

.sfm-tooltip.sfm-visible {
    display: block;
    animation: sfm-tooltip-in 0.2s ease;
}

@keyframes sfm-tooltip-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sfm-tooltip-inner {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.1);
    padding: 0;
    overflow: hidden;
    position: relative;
}

/* Status bar */
.sfm-tooltip-status-bar {
    height: 4px;
    width: 100%;
}

.sfm-tooltip-status-bar.sfm-status-laisvas {
    background: #27ae60;
}

.sfm-tooltip-status-bar.sfm-status-nuomojamas {
    background: #2980b9;
}

.sfm-tooltip-status-bar.sfm-status-isnuomotas {
    background: #e74c3c;
}

.sfm-tooltip-status-bar.sfm-status-rezervuotas {
    background: #f39c12;
}

.sfm-tooltip-header {
    padding: 16px 16px 8px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.sfm-tooltip-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.3;
}

.sfm-tooltip-floor-num {
    display: inline-block;
    background: #f0f0f1;
    color: #646970;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    margin-top: 2px;
}

.sfm-tooltip-close {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: #999;
    padding: 0 0 0 8px;
    flex-shrink: 0;
    transition: color 0.2s;
}

.sfm-tooltip-close:hover {
    color: #333;
}

/* Details grid */
.sfm-tooltip-details {
    padding: 0 16px 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.sfm-tooltip-detail-item {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 8px 10px;
}

.sfm-tooltip-detail-label {
    font-size: 11px;
    text-transform: uppercase;
    color: #888;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.sfm-tooltip-detail-value {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
}

.sfm-tooltip-detail-value.sfm-status-badge {
    font-size: 13px;
    font-weight: 600;
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
}

.sfm-tooltip-detail-value.sfm-free {
    background: #e8f5e9;
    color: #2e7d32;
}

.sfm-tooltip-detail-value.sfm-rental {
    background: #eaf2f8;
    color: #21618c;
}

.sfm-tooltip-detail-value.sfm-rented {
    background: #ffebee;
    color: #c0392b;
}

.sfm-tooltip-detail-value.sfm-reserved {
    background: #fff3e0;
    color: #e67e22;
}

.sfm-tooltip-detail-value.sfm-default {
    background: #f5f5f5;
    color: #666;
}

/* Description */
.sfm-tooltip-description {
    padding: 0 16px 8px;
    font-size: 13px;
    color: #666;
    line-height: 1.5;
}

/* CTA */
.sfm-tooltip-footer {
    padding: 8px 16px 16px;
}

.sfm-tooltip-link {
    display: block;
    text-align: center;
    padding: 10px 16px;
    background: #2271b1;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s, transform 0.1s;
}

.sfm-tooltip-link:hover {
    background: #135e96;
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
}

/* Floor plan image in tooltip */
.sfm-tooltip-floor-plan {
    padding: 0 16px 12px;
}

.sfm-tooltip-floor-plan img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    border: 1px solid #eee;
}

/* Loader */
.sfm-tooltip-loader {
    padding: 32px 16px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

.sfm-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: sfm-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

.sfm-spinner-large {
    width: 36px;
    height: 36px;
    border-width: 3px;
}

@keyframes sfm-spin {
    to { transform: rotate(360deg); }
}

/* Preloader overlay */
.sfm-preloader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.sfm-empty-state {
    background: #f8f9fa;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    color: #888;
}

.sfm-empty-state p {
    margin-bottom: 16px;
    font-size: 15px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 600px) {
    .sfm-tooltip {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        max-width: calc(100vw - 32px);
        width: 320px;
    }

    .sfm-tooltip-details {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Floor Legend — vertical circles
   ========================================================================== */

.sfm-floor-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.sfm-legend-item {
    text-decoration: none;
    display: block;
}

.sfm-legend-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.sfm-legend-circle:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

/* ==========================================================================
   Floor Table — Black & White + #b78f65 accent
   ========================================================================== */

.sfm-floor-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Visual scroll hint: subtle right fade when content overflows */
    background:
        linear-gradient(to right, #fff 30%, rgba(255,255,255,0)),
        linear-gradient(to right, rgba(255,255,255,0), #fff 70%) 100% 0,
        linear-gradient(to right, rgba(0,0,0,0.08), rgba(255,255,255,0)),
        linear-gradient(to left, rgba(0,0,0,0.08), rgba(255,255,255,0)) 100% 0;
    background-repeat: no-repeat;
    background-color: #fff;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
}

/* ==========================================================================
   Table Structure
   ========================================================================== */

.sfm-floor-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 14px;
}

/* ==========================================================================
   Table Header
   ========================================================================== */

.sfm-floor-table thead th {
    text-align: left;
    padding: 8px 16px 14px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: #888;
    font-weight: 700;
    background: transparent;
    border-bottom: 2px solid #ddd;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.sfm-floor-table thead th:hover {
    color: #333;
}

.sfm-floor-table thead th.asc,
.sfm-floor-table thead th.desc {
    color: #b78f65;
}

.sfm-floor-table thead th.asc .sfm-sort-arrow,
.sfm-floor-table thead th.desc .sfm-sort-arrow {
    color: #b78f65;
}

.sfm-th-accent {
    width: 4px;
    min-width: 4px;
    padding: 0 !important;
    cursor: default !important;
    border-bottom: none !important;
}

/* ==========================================================================
   Table Body
   ========================================================================== */

.sfm-floor-table tbody tr.sfm-table-row {
    background: transparent;
    transition: background 0.2s ease;
}

.sfm-floor-table tbody tr.sfm-table-row:hover {
    background: rgba(0,0,0,0.02);
}

/* ==========================================================================
   Row Accent Line
   ========================================================================== */

.sfm-td-accent {
    width: 4px;
    min-width: 4px;
    padding: 0 !important;
    vertical-align: stretch;
    position: relative;
}

.sfm-accent-line {
    display: block;
    width: 3px;
    height: 100%;
    min-height: 56px;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    background: #b78f65;
}

/* ==========================================================================
   Table Cells
   ========================================================================== */

.sfm-floor-table tbody td {
    padding: 18px 16px;
    font-size: 14px;
    vertical-align: middle;
    border-bottom: 1px solid #eee;
}

.sfm-floor-table tbody tr:last-child td {
    border-bottom: 1px solid #eee;
}

/* ==========================================================================
   Floor Number Badge
   ========================================================================== */

.sfm-floor-num-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f5f5f5;
    color: #333;
    font-weight: 400;
    font-size: 14px;
    margin-right: 14px;
    vertical-align: middle;
}

/* ==========================================================================
   Floor Title
   ========================================================================== */

.sfm-floor-title {
    font-weight: 400;
    color: #111;
    font-size: 14px;
    vertical-align: middle;
}

/* ==========================================================================
   Area Column
   ========================================================================== */

.sfm-area-value {
    font-weight: 400;
    font-size: 14px;
    color: #111;
}

.sfm-area-available {
    display: block;
    font-size: 12px;
    color: #999;
    margin-top: 3px;
}

/* ==========================================================================
   Occupancy Column — % centered top, line below
   ========================================================================== */

.sfm-td-occupancy {
    min-width: 100px;
    text-align: center;
}

.sfm-occupancy-pct {
    display: inline-block;
    font-size: 12px;
    font-weight: 300;
    color: #999;
    line-height: 1;
    margin-bottom: 8px;
}

.sfm-occupancy-bar {
    display: block;
    width: 100%;
    max-width: 80px;
    height: 5px;
    background: #eee;
    border-radius: 10px;
    overflow: hidden;
    margin: 0 auto;
    position: relative;
}

.sfm-occupancy-bar::before {
    content: '';
    display: block;
    width: 100%;
    height: 1px;
    background: #ddd;
    position: absolute;
    top: -5px;
    left: 0;
}

.sfm-occupancy-fill {
    height: 100%;
    border-radius: 10px;
    background: #b78f65;
}

/* ==========================================================================
   Status Badge
   ========================================================================== */

.sfm-status-badge {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 400;
    color: #666;
    background: #f5f5f5;
    letter-spacing: 0.3px;
}

/* ==========================================================================
   Action Button
   ========================================================================== */

.sfm-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 18px;
    background: #b78f65;
    color: #fff !important;
    text-decoration: none;
    border: 0;
    border-radius: 0;
    font-size: 15px;
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    transition: background 0.2s ease, transform 0.15s ease;
}

.sfm-view-btn:hover {
    background: #a07852;
    color: #fff;
    transform: translateY(-1px);
}

.sfm-btn-arrow {
    transition: transform 0.2s ease;
}

.sfm-view-btn:hover .sfm-btn-arrow {
    transform: translateX(3px);
}

/* ==========================================================================
   Responsive Table
   ========================================================================== */

@media (max-width: 768px) {
    .sfm-floor-table {
        border-spacing: 0 10px;
    }

    .sfm-floor-table thead th {
        padding: 8px 10px 12px;
        font-size: 9px;
        letter-spacing: 0.6px;
    }

    .sfm-floor-table tbody td {
        padding: 14px 10px;
        font-size: 13px;
    }

    .sfm-floor-num-badge {
        width: 30px;
        height: 30px;
        font-size: 13px;
        margin-right: 8px;
    }

    .sfm-floor-title {
        font-size: 13px;
    }

    .sfm-area-value {
        font-size: 13px;
    }

    .sfm-occupancy-pct {
        font-size: 11px;
    }

    .sfm-occupancy-bar {
        max-width: 50px;
    }

    .sfm-view-btn {
        padding: 6px 12px;
        font-size: 11px;
    }
}

/* ==========================================================================
   Mobile Card Layout — converts table rows into cards
   Activated at 600px and below so all columns fit without horizontal scroll.
   ========================================================================== */

@media (max-width: 600px) {

    /* --- Remove horizontal scroll, disable table layout --- */
    .sfm-floor-table-wrap {
        overflow-x: visible;
    }

    .sfm-floor-table,
    .sfm-floor-table thead,
    .sfm-floor-table tbody,
    .sfm-floor-table th,
    .sfm-floor-table td,
    .sfm-floor-table tr {
        display: block;
    }

    /* --- Hide table header on card view --- */
    .sfm-floor-table thead {
        display: none;
    }

    /* --- Each row becomes a card --- */
    .sfm-floor-table tbody tr.sfm-table-row {
        background: #fff;
        border: 1px solid #eee;
        border-radius: 10px;
        margin-bottom: 14px;
        padding: 0;
        box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    }

    .sfm-floor-table tbody tr.sfm-table-row:last-child {
        margin-bottom: 0;
    }

    .sfm-floor-table tbody tr.sfm-table-row:hover {
        background: #fff;
    }

    /* --- Cells become flex rows with label on the left --- */
    .sfm-floor-table tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        border-bottom: 1px solid #f5f5f5;
        font-size: 14px;
        text-align: left;
        position: relative;
    }

    .sfm-floor-table tbody td:last-child {
        border-bottom: none;
        padding-top: 14px;
        padding-bottom: 16px;
    }

    /* --- CSS-only label: uses data-label attribute --- */
    .sfm-floor-table tbody td::before {
        content: attr(data-label);
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: #999;
        font-weight: 600;
        flex-shrink: 0;
        margin-right: 12px;
        white-space: nowrap;
    }

    /* Hide empty labels (accent, action columns) */
    .sfm-floor-table tbody td[data-label=""]::before {
        display: none;
    }

    /* --- Accent line — turn into a top colored bar on the card --- */
    .sfm-td-accent {
        padding: 0 !important;
        border-bottom: none !important;
        height: 4px;
        min-height: 4px;
    }

    .sfm-accent-line {
        width: 100%;
        height: 4px;
        min-height: 4px;
        position: static;
        border-radius: 10px 10px 0 0;
    }

    /* --- Floor number — first row, no top border --- */
    .sfm-td-num {
        padding-top: 16px !important;
    }

    .sfm-floor-num-badge {
        width: 32px;
        height: 32px;
        font-size: 14px;
        margin-right: 10px;
    }

    .sfm-floor-title {
        font-size: 15px;
        font-weight: 600;
    }

    /* --- Area — keep values right-aligned --- */
    .sfm-td-area .sfm-area-value {
        text-align: right;
    }

    .sfm-area-available {
        margin-left: 6px;
        display: inline;
        font-size: 12px;
    }

    /* --- Occupancy — bar full width below the label --- */
    .sfm-td-occupancy {
        flex-wrap: wrap;
    }

    .sfm-td-occupancy::before {
        width: 100%;
        margin-bottom: 8px;
    }

    .sfm-occupancy-pct {
        font-size: 13px;
        margin-bottom: 6px;
    }

    .sfm-occupancy-bar {
        max-width: 100%;
    }

    /* --- Status badge --- */
    .sfm-td-status .sfm-status-badge {
        font-size: 13px;
        padding: 4px 12px;
    }

    /* --- Action button — full width --- */
    .sfm-td-action {
        justify-content: center !important;
    }

    .sfm-view-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        padding: 10px 20px;
        font-size: 13px;
        text-align: center;
    }
}
