﻿/* ============================================================
   CONSISTENCY PATCHES
   Import last in index.css — intentional overrides.
   ============================================================ */

/* ── Unified border-radius scale ──
   sm  = 6px   inputs, badges, small buttons
   md  = 8px   cards, panels, dialogs
   lg  = 12px  cellar, region, wine cards
   pill= 999px tags, chips, count badges     */

.wine-card {
    border-radius: 12px;
}

/* ── Unified shadow scale — two levels only ── */
.cellar-card,
.wine-card,
.region-card,
.form-card,
.detail-card,
.friends-card,
.tasting-card,
.invites-banner,
.overview-section {
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
}

    .cellar-card-link:hover .cellar-card,
    .wine-card:hover,
    .region-card:hover,
    .tasting-card:hover {
        box-shadow: 0 4px 12px rgba(0,0,0,0.10), 0 8px 24px rgba(0,0,0,0.06);
    }

/* ── Page shell ── */
.page {
    min-height: 100vh;
}

/* ── page-header: compact single row, no description line eating space ── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center; /* vertically center title with buttons */
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

    /* Remove the page-title-section wrapper indirection — title sits directly */
    .page-header .page-title {
        margin: 0;
    }

/* ── Cellar detail header ── */
.cellar-detail-header {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.cellar-detail-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.cellar-detail-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.cellar-detail-header-title {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

    /* The title itself — slightly larger since it's the main landmark */
    .cellar-detail-header-title .page-title {
        font-size: 1.75rem;
        letter-spacing: -0.02em;
    }

    /* Description sits quietly below */
    .cellar-detail-header-title .page-description {
        font-size: 0.88rem;
        opacity: 0.5;
        margin: 0;
    }

.header-filter {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.4;
    border-radius: 4px;
    padding: 0.45rem 1rem;
    background-color: var(--color-secondary-button);
}

/* ── Loading / skeleton ── */
.loading-shell {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.5rem 0;
    animation: skeleton-pulse 1.6s ease-in-out infinite;
}

.skeleton-title {
    height: 1.4rem;
    width: 35%;
    background: rgba(0,0,0,0.07);
    border-radius: 6px;
}

.skeleton-list {
    height: 3.5rem;
    width: 100%;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
}

@keyframes skeleton-pulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.45;
    }
}

/* ── Status message (import feedback etc.) ── */
.cellar-detail-status {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin-bottom: 0.75rem;
}

/* ── Table: left-align text, center action columns ── */
.table td, .table th {
    text-align: left;
}

    .table td:last-child, .table th:last-child {
        text-align: center;
        width: 2.5rem;
    }

.quantity-width {
    min-width: 2rem;
    display: inline-block;
    text-align: right;
}

/* ── Expanded row in tables (Explore page add-to-cellar) ── */
.expanded-row {
    background: var(--color-primary-bg);
}

.expanded-row-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    flex-wrap: wrap;
    font-size: 0.88rem;
}

    .expanded-row-content label {
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        opacity: 0.55;
        letter-spacing: 0.04em;
    }

/* ── section-rule spacing ── */
.section-rule {
    border: none;
    border-top: 1px solid rgba(0,0,0,0.07);
}

/* ── Remove half-finished region page stubs ── */
.wine-filters {
    display: none;
}

/* ── Uniform action-button with btn-* siblings ── */
.action-button {
    border-radius: 6px;
    font-size: 0.88rem;
    padding: 0.45rem 1rem;
}

    .action-button.small {
        font-size: 0.8rem;
        padding: 0.3rem 0.65rem;
    }

/* ── Privacy badge (replaces heavy toggle component in cellar detail) ── */
.privacy-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,0.12);
    background: var(--color-primary-bg);
    color: var(--color-dark-text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

    .privacy-badge:hover {
        background: var(--color-tertiary-button-hover);
        border-color: rgba(0,0,0,0.2);
    }

    .privacy-badge.private {
        background: #f1f5f9;
        border-color: #cbd5e1;
        color: #475569;
    }

    .privacy-badge.public {
        background: #f0fdf4;
        border-color: #bbf7d0;
        color: #15803d;
    }

/* ── Cellar detail title row: name + badge side by side ── */
.cellar-detail-title-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

    .cellar-detail-title-row .page-title {
        margin: 0;
    }

/* ── CellarOverview ── */
.overview-grid {
    display: grid;
    grid-template-columns: 0.8fr 1.2fr 1.6fr;
    gap: 1rem;
    align-items: stretch;
    margin-bottom: 0.5rem;
}

.overview-card {
    background: var(--color-card-bg);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* chart body fills remaining height so both charts align */
.overview-chart-body {
    flex: 1;
    display: flex;
    align-items: stretch;
}

    .overview-chart-body > * {
        width: 100%;
    }

.overview-card-header {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    opacity: 0.45;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.overview-card-body {
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

/* padding handled inside the card-body rule */

/* ── Stat rows ── */
.overview-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.2rem 0;
}

.overview-stat-label {
    font-size: 0.82rem;
    opacity: 0.55;
}

.overview-stat-value {
    font-size: 0.88rem;
    font-weight: 600;
    text-align: right;
}

.overview-stat-wine {
    font-size: 0.8rem;
    max-width: 120px;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.overview-stat-qty {
    font-style: normal;
    opacity: 0.45;
    font-weight: 400;
    margin-left: 0.25rem;
}

.overview-divider {
    border: none;
    border-top: 1px solid rgba(0,0,0,0.06);
    margin: 0.5rem 0;
}

/* ── Top regions / varietals ── */
.overview-top-row {
    display: flex;
    gap: 0.75rem;
}

.overview-top-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.overview-top-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.35;
    margin-bottom: 0.3rem;
}

.overview-top-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.25rem;
}

.overview-top-name {
    font-size: 0.78rem;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.overview-top-qty {
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0.45;
    flex-shrink: 0;
}

/* ── Region level switch (compact, lives in card header) ── */
.overview-level-switch {
    display: flex;
    border-radius: 6px;
    overflow: hidden;
}

    .overview-level-switch button {
        padding: 0.2rem 0.6rem;
        font-size: 0.72rem;
        font-weight: 600;
        border: none;
        cursor: pointer;
        background: var(--color-secondary-button);
        color: var(--color-dark-text);
        transition: background 0.15s, color 0.15s;
        letter-spacing: 0.02em;
    }

        .overview-level-switch button.first {
            border-radius: 6px 0 0 6px;
        }

        .overview-level-switch button.last {
            border-radius: 0 6px 6px 0;
        }

        .overview-level-switch button:hover {
            background: var(--color-secondary-button-hover);
        }

        .overview-level-switch button.active {
            background: var(--color-secondary-button-active);
            color: var(--color-light-text);
        }

/* ── User profile — cellar tabs ── */
.user-cellar-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.user-cellar-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.1);
    background: var(--color-card-bg);
    color: var(--color-dark-text);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s, background 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

    .user-cellar-tab:hover {
        border-color: rgba(0,0,0,0.2);
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    }

    .user-cellar-tab.active {
        background: var(--color-primary-button);
        color: var(--color-light-text);
        border-color: transparent;
        box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    }

.user-cellar-tab-name {
    font-weight: 600;
}

.user-cellar-tab-count {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: rgba(0,0,0,0.08);
    color: inherit;
}

.user-cellar-tab.active .user-cellar-tab-count {
    background: rgba(255,255,255,0.2);
}

.user-cellar-panel {
    margin-top: 0.25rem;
}

/* ── Pending wine badge ──────────────────────────────────────────────
   Shown in CellarDetail table and WineCard for wines awaiting admin
   approval. Wines are created with is_pending = true from the import
   flow and flipped to false manually by an admin in the database.
   ────────────────────────────────────────────────────────────────── */

.badge-pending {
    display: inline-flex;
    align-items: center;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    margin-left: 0.4rem;
    vertical-align: middle;
    line-height: 1.4;
}

/* Subtle row tint for pending wines in table view */
tr.row-pending td {
    opacity: 0.8;
}

/* ── Responsive breakpoints ── */
@media (max-width: 600px) {
    .tastings-grid {
        grid-template-columns: 1fr;
    }

    .detail-layout {
        grid-template-columns: 1fr;
    }

    .create-layout {
        grid-template-columns: 1fr;
    }

    .friends-layout {
        grid-template-columns: 1fr;
    }

    .cellar-overview-content {
        grid-template-columns: 1fr;
    }

    .cellar-detail-header-top {
        flex-wrap: wrap;
    }

    .cellar-detail-actions {
        flex-wrap: wrap;
    }
    .group-by-tabs {
        display: flex;
        gap: 0.35rem;
        flex-wrap: wrap;
    }

    .wine-group-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        background: transparent;
        border: none;
        border-bottom: 1px solid rgba(0,0,0,0.07);
        padding: 0.5rem 0;
        margin-bottom: 0.5rem;
        cursor: pointer;
        color: inherit;
        gap: 0.5rem;
    }

        .wine-group-header:hover .section-eyebrow {
            opacity: 1;
        }

    .collapse-chevron {
        opacity: 0.35;
        transition: transform 0.2s ease;
    }

        .collapse-chevron.collapsed {
            transform: rotate(-90deg);
        }
}


.filter-panel {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    z-index: 100;
    background: var(--color-card-bg);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 280px;
}

.filter-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99;
}

.filter-panel-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-panel-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    opacity: 0.4;
}

.filter-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.filter-chip {
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.12);
    background: var(--color-primary-bg);
    color: var(--color-dark-text);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}

    .filter-chip:hover {
        border-color: rgba(0,0,0,0.25);
        background: var(--color-tertiary-button-hover);
    }

    .filter-chip.active {
        background: var(--color-primary-button);
        border-color: transparent;
        color: #fff;
    }

/* ── Setup wizard ── */
.setup-steps {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 1.5rem;
}

.setup-step {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    font-weight: 600;
    opacity: 0.35;
}

    .setup-step.active {
        opacity: 1;
    }

    .setup-step.done {
        opacity: 0.6;
    }

.setup-step-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0,0,0,0.08);
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.setup-step.active .setup-step-dot {
    background: var(--color-primary-button);
    color: #fff;
}

.setup-step.done .setup-step-dot {
    background: #16a34a;
    color: #fff;
}

.setup-step-line {
    flex: 1;
    height: 1px;
    background: rgba(0,0,0,0.1);
    margin: 0 0.5rem;
    min-width: 2rem;
}

.setup-card {
    background: var(--color-card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    margin: 0 auto;
}

.setup-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.setup-card-hint {
    font-size: 0.85rem;
    opacity: 0.5;
    line-height: 1.55;
    margin-top: -0.5rem;
}

.setup-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(0,0,0,0.06);
    margin-top: 0.5rem;
}

/* ── Segment grid ── */
.segment-grid-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

.segment-grid {
    display: grid;
    gap: 0.75rem;
    width: 100%;
}

.segment-cell {
    border-radius: 10px;
    min-height: 100px;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.75rem;
}

.segment-cell-empty {
    border: 2px dashed rgba(0,0,0,0.12);
    background: var(--color-primary-bg);
    align-items: center;
    justify-content: center;
}

    .segment-cell-empty:hover {
        border-color: var(--color-primary-button);
        background: rgba(0,0,0,0.02);
    }

.segment-cell-add {
    font-size: 1.5rem;
    opacity: 0.25;
    font-weight: 300;
}

.segment-cell-filled {
    border: 1.5px solid rgba(0,0,0,0.08);
    background: var(--color-card-bg);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

    .segment-cell-filled:hover {
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    }

.segment-cell-editing {
    border-color: var(--color-primary-button);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.segment-cell-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.segment-cell-dims {
    font-size: 0.72rem;
    opacity: 0.4;
}

.segment-cell-drag-over {
    border-color: var(--color-primary-button) !important;
    background: rgba(99,102,241,0.06) !important;
    transform: scale(1.02);
}

.segment-mini-grid {
    display: grid;
    gap: 2px;
    margin-top: 0.25rem;
}

.segment-mini-slot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(0,0,0,0.1);
}

.segment-grid-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ── Segment editor ── */
.segment-editor {
    background: var(--color-primary-bg);
    border-radius: 10px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    border: 1px solid rgba(0,0,0,0.07);
}

.segment-editor-title {
    font-size: 0.88rem;
    font-weight: 600;
    opacity: 0.7;
}

.segment-editor-fields {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 0.75rem;
}

.segment-editor-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* ── Slot preview ── */
.segment-preview {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.segment-preview-label {
    font-size: 0.72rem;
    opacity: 0.4;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.segment-preview-grid {
    display: grid;
    gap: 3px;
}

.segment-preview-slot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0,0,0,0.08);
    border: 1px solid rgba(0,0,0,0.06);
}

.segment-preview-more {
    font-size: 0.72rem;
    opacity: 0.35;
    grid-column: 1 / -1;
    padding-top: 0.2rem;
}

/* ── Cellar map ── */
.map-legend {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    font-size: 0.8rem;
    opacity: 0.7;
}

.map-legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.map-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

    .map-legend-dot.empty {
        background: rgba(0,0,0,0.1);
        border: 1px solid rgba(0,0,0,0.15);
    }

    .map-legend-dot.filled.red {
        background: #8B0000;
    }

    .map-legend-dot.filled.white {
        background: #c8b97a;
    }

    .map-legend-dot.filled.rose {
        background: #F2A1B3;
    }

    .map-legend-dot.filled.sparkling {
        background: #D4AF37;
    }

    .map-legend-dot.filled.orange {
        background: #E67E22;
    }

.map-segment-grid {
    display: grid;
    gap: 2rem;
    align-items: start;
    justify-content: center;
    margin: 0 auto;
}

.map-segment {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    align-self: start;
}

.map-segment-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    opacity: 0.4;
}

.map-segment-grid-inner {
    display: grid;
    gap: 4px;
}

.layout-offset {
    overflow: visible;
}

/* ── Slots ── */
.map-slot {
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s, box-shadow 0.12s;
    position: relative;
    user-select: none;
}

    .map-slot.empty {
        background: rgba(0,0,0,0.07);
        border: 1.5px solid rgba(0,0,0,0.1);
    }

        .map-slot.empty:hover {
            background: rgba(0,0,0,0.12);
            transform: scale(1.1);
        }

    .map-slot.filled {
        box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    }

        .map-slot.filled:hover {
            transform: scale(1.15);
            box-shadow: 0 3px 8px rgba(0,0,0,0.25);
            z-index: 2;
        }

        .map-slot.filled.red {
            background: #8B0000;
        }

        .map-slot.filled.white {
            background: #c8b97a;
        }

        .map-slot.filled.rose {
            background: #F2A1B3;
        }

        .map-slot.filled.sparkling {
            background: #D4AF37;
        }

        .map-slot.filled.orange {
            background: #E67E22;
        }

    .map-slot.dragging {
        opacity: 0.35;
    }

    .map-slot.drag-over {
        transform: scale(1.2);
        box-shadow: 0 0 0 3px var(--color-primary-button);
    }

.map-slot-vintage {
    font-size: 0.5rem;
    font-weight: 700;
    color: rgba(255,255,255,0.75);
    pointer-events: none;
    letter-spacing: 0.02em;
}

.map-slot-dimmed {
    opacity: 0.15;
    pointer-events: none;
}

/* ── Slot panel ── */
.map-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(2px);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.map-panel {
    background: var(--color-card-bg);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    padding: 1.25rem;
    width: 400px;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.map-panel-title {
    font-size: 0.95rem;
    font-weight: 700;
}

.map-panel-wine {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem;
    background: var(--color-primary-bg);
    border-radius: 8px;
}

.map-panel-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.map-picker-list {
    display: flex;
    flex-direction: column;
    max-height: 280px;
    overflow-y: auto;
    gap: 0.25rem;
}

.map-picker-row {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.5rem 0.65rem;
    border-radius: 7px;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s;
    color: inherit;
}

    .map-picker-row:hover {
        background: var(--color-tertiary-button-hover);
    }