/* =============================================
   Mieszkania Availability – Public Styles
   ============================================= */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

.ma-wrapper {
    font-family: 'DM Sans', sans-serif;
    margin: 28px 0;
}

.ma-table-title {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 10px;
}

/* Legend */
.ma-legend {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 13px;
    color: #4a5568;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.ma-legend-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
}
.ma-legend-dot.ma-available { background: #38a169; }
.ma-legend-dot.ma-reserved  { background: #d69e2e; }
.ma-legend-dot.ma-sold      { background: #e53e3e; }

/* Grid */
.ma-grid {
    display: grid;
    grid-template-columns: repeat(var(--ma-cols, 5), 1fr);
    gap: 8px;
}

/* Cells */
.ma-cell {
    position: relative;
    aspect-ratio: 1;
    min-height: 56px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
.ma-cell:hover,
.ma-cell:focus-visible {
    transform: scale(1.07);
    z-index: 10;
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
}

.ma-cell.ma-available { background: linear-gradient(135deg, #48bb78, #276749); }
.ma-cell.ma-reserved  { background: linear-gradient(135deg, #ecc94b, #b7791f); }
.ma-cell.ma-sold      { background: linear-gradient(135deg, #fc8181, #9b2c2c); }

.ma-cell-num {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    opacity: .95;
    pointer-events: none;
}

/* Tooltip */
.ma-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(.92);
    background: #1a202c;
    color: #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
    width: 180px;
    font-size: 13px;
    line-height: 1.5;
    pointer-events: none;
    opacity: 0;
    transition: opacity .18s ease, transform .18s ease;
    z-index: 100;
    box-shadow: 0 8px 30px rgba(0,0,0,.35);
    white-space: nowrap;
}
.ma-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1a202c;
}

/* Show tooltip on hover (desktop) */
.ma-cell:hover .ma-tooltip,
.ma-cell:focus-visible .ma-tooltip {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* Show tooltip on tap (mobile) */
.ma-cell.ma-tapped .ma-tooltip {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.ma-tooltip-row { margin-bottom: 4px; }
.ma-tooltip-row:last-child { margin-bottom: 0; }
.ma-tooltip-label {
    font-weight: 600;
    color: #a0aec0;
    margin-right: 4px;
    display: inline-block;
}

/* Status text colours inside tooltip */
.ma-available-text { color: #68d391; font-weight: 700; }
.ma-reserved-text  { color: #f6e05e; font-weight: 700; }
.ma-sold-text      { color: #fc8181; font-weight: 700; }

/* Error */
.ma-error {
    background: #fff5f5;
    border: 1px solid #fc8181;
    border-radius: 8px;
    padding: 12px 16px;
    color: #c53030;
    font-size: 14px;
}

/* Responsive: smaller cells on phones */
@media (max-width: 480px) {
    .ma-cell { min-height: 44px; border-radius: 7px; }
    .ma-cell-num { font-size: 12px; }
    .ma-tooltip { font-size: 12px; width: 160px; }
}

/* =============================================
   RESPONSYWNOŚĆ — skalowanie na mobile
   ============================================= */

/*
  Strategia: używamy CSS container queries + font-size fluid trick.
  Komórki mają aspect-ratio:1 i min-height w rem.
  Na wąskim ekranie zmniejszamy --ma-cell-size tak,
  aby cała siatka mieściła się w szerokości ekranu.
*/

.ma-grid {
    /* Obliczamy rozmiar komórki: (100% - gap*(cols-1)) / cols
       Używamy CSS custom property żeby ograniczyć max */
    --ma-gap: clamp(4px, 1.2vw, 8px);
    gap: var(--ma-gap);
    width: 100%;
    box-sizing: border-box;
    overflow: visible;
}

/* Komórka bez sztywnej wysokości — ratio 1:1 zapewnia kwadrat */
.ma-cell {
    /* aspect-ratio: 1 powoduje że wysokość = szerokość (kolumna gridu) */
    aspect-ratio: 1;
    min-height: unset;          /* usuń poprzedni min-height */
    min-width: 0;               /* pozwól na kurczenie w gridzie */
    border-radius: clamp(6px, 1.5vw, 10px);
}

.ma-cell-num {
    font-size: clamp(10px, 2.5vw, 14px);
}

/* Tooltip: na mobile zawsze od dołu i wyśrodkowany w viewport */
@media (max-width: 600px) {
    .ma-tooltip {
        position: fixed;
        bottom: 24px;
        left: 50%;
        top: auto;
        transform: translateX(-50%);
        width: 220px;
        font-size: 13px;
        z-index: 9999;
        border-radius: 12px;
    }
    .ma-tooltip::after {
        display: none;   /* chowamy strzałkę przy fixed tooltipie */
    }
    /* Tooltip zawsze widoczny przy tapnięciu */
    .ma-cell.ma-tapped .ma-tooltip {
        transform: translateX(-50%);
    }
}

/* Dla bardzo wąskich ekranów (< 360px) zmniejsz gap */
@media (max-width: 360px) {
    .ma-grid {
        --ma-gap: 3px;
    }
}
