/**
 * Terrassenplaner v3.1 — Polished Styles
 *
 * Design: cream/off-white bg, dark green + gold accents, serif headings.
 * Improvements: better spacing, wood-color preview, board orientation toggle,
 * waste tag variants, refined card design, better responsive behavior.
 *
 * @package Naturholz
 * @version 3.1.0
 */

/* ==========================================================================
   SECTION WRAPPER
   ========================================================================== */

.tp {
    padding: var(--space-2xl) 0 var(--space-4xl);
    background: var(--color-cream);
}

.tp-section-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--color-charcoal);
    margin: var(--space-2xl) 0 var(--space-lg);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--color-sand);
    letter-spacing: -0.01em;
}

/* ==========================================================================
   DIMENSIONS CARD — Option C: preview left, controls right
   ========================================================================== */

.tp-dimensions {
    display: grid;
    grid-template-columns: 240px 1fr;
    background: #fff;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 6px 20px rgba(0,0,0,0.04);
    margin-bottom: var(--space-xl);
}

/* Right side: controls */
.tp-dimensions__controls {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    padding: var(--space-xl);
    justify-content: center;
}

/* Width × Length row */
.tp-dimensions__size {
    display: flex;
    align-items: flex-end;
    gap: var(--space-md);
}

.tp-dimensions__x {
    font-size: 1.3rem;
    color: var(--color-warm-gray);
    padding-bottom: 10px;
    line-height: 1;
}

/* --- Fields --- */

.tp-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 90px;
}

.tp-field label {
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-charcoal);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.tp-field__input {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1.5px solid var(--color-sand);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tp-field__input:focus-within {
    border-color: var(--color-secondary);
    box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.12);
}

.tp-field__input input {
    flex: 1;
    padding: 10px 12px;
    border: none;
    font-size: var(--text-base);
    font-family: var(--font-body);
    color: var(--color-charcoal);
    background: transparent;
    outline: none;
    width: 70px;
    -moz-appearance: textfield;
}

.tp-field__input input::-webkit-inner-spin-button,
.tp-field__input input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.tp-field__unit {
    padding: 10px 12px 10px 0;
    font-size: var(--text-sm);
    color: var(--color-warm-gray);
    font-weight: 600;
}

/* --- Board Orientation Toggle --- */

.tp-field--direction {
    min-width: 180px;
}

.tp-direction-toggle {
    display: flex;
    gap: 4px;
    background: var(--color-cream);
    border-radius: var(--radius-md);
    padding: 3px;
}

.tp-dir-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    font-size: 0.82rem;
    font-family: var(--font-body);
    font-weight: 500;
    color: var(--color-warm-gray);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tp-dir-btn:hover {
    color: var(--color-charcoal);
    background: rgba(255,255,255,0.6);
}

.tp-dir-btn.active {
    background: #fff;
    color: var(--color-secondary-dark);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    font-weight: 600;
}

.tp-dir-btn svg { flex-shrink: 0; }

/* --- Extra/Waste Selector --- */

.tp-field--extra {
    min-width: 240px;
}

.tp-extra-select {
    display: flex;
    gap: 3px;
    background: var(--color-cream);
    border-radius: var(--radius-md);
    padding: 3px;
}

.tp-extra-btn {
    padding: 7px 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    font-size: 0.78rem;
    font-family: var(--font-body);
    font-weight: 500;
    color: var(--color-warm-gray);
    cursor: pointer;
    transition: all 0.2s;
}

.tp-extra-btn:hover {
    color: var(--color-charcoal);
    background: rgba(255,255,255,0.6);
}

.tp-extra-btn.active {
    background: var(--color-secondary);
    color: #fff;
    font-weight: 600;
}

/* ==========================================================================
   SVG PREVIEW — left panel with gradient background
   ========================================================================== */

.tp-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    padding: var(--space-xl) var(--space-md);
    background: linear-gradient(135deg, var(--color-cream-dark) 0%, var(--color-cream) 100%);
    border-right: 1px solid var(--color-sand);
}

#tp-preview-svg {
    width: 210px;
    height: 170px;
}

.tp-preview__badge {
    display: flex;
    align-items: baseline;
    gap: 4px;
    padding: 5px 14px;
    background: var(--color-secondary-dark);
    color: #fff;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.tp-preview__unit {
    font-size: 0.7rem;
    font-weight: 500;
    opacity: 0.8;
}

/* ==========================================================================
   FILTERS — chip selectors
   ========================================================================== */

.tp-filters {
    display: flex;
    gap: var(--space-xl);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.tp-filter {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.tp-filter label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-charcoal);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tp-filter-chips {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.tp-chip {
    padding: 6px 14px;
    border: 1.5px solid var(--color-sand);
    border-radius: var(--radius-full);
    background: #fff;
    font-size: 0.82rem;
    font-family: var(--font-body);
    font-weight: 500;
    color: var(--color-charcoal);
    cursor: pointer;
    transition: all 0.2s;
}

.tp-chip:hover {
    border-color: var(--color-secondary);
    background: rgba(74, 103, 65, 0.05);
}

.tp-chip.active {
    border-color: var(--color-secondary);
    background: var(--color-secondary);
    color: #fff;
    font-weight: 600;
}

/* ==========================================================================
   BOARD CARDS — compact rows with better spacing
   ========================================================================== */

.tp-products {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tp-board {
    display: grid;
    grid-template-columns: 28px 52px 1fr auto;
    gap: var(--space-sm) var(--space-md);
    align-items: center;
    padding: 12px 16px;
    background: #fff;
    border: 1.5px solid var(--color-cream-dark);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.tp-board:hover {
    border-color: var(--color-secondary-light);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.tp-board--selected {
    border-color: var(--color-secondary);
    background: rgba(74, 103, 65, 0.04);
    box-shadow: 0 0 0 2px rgba(74, 103, 65, 0.15);
}

.tp-board--oos {
    opacity: 0.4;
    pointer-events: none;
    display: none;
}

/* Radio */
.tp-board__select {
    display: flex;
    align-items: center;
    justify-content: center;
}

.tp-board__select input[type="radio"] {
    display: none;
}

.tp-board__select label {
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-sand);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.tp-board__select input:checked + label {
    border-color: var(--color-secondary);
}

.tp-board__select input:checked + label::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 8px; height: 8px;
    background: var(--color-secondary);
    border-radius: 50%;
}

/* Image */
.tp-board__img {
    width: 52px;
    height: 38px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--color-cream);
    flex-shrink: 0;
}

.tp-board__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tp-board__placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-sand);
}

/* Info — name + meta */
.tp-board__info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.tp-board__name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--color-charcoal);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.tp-board__meta {
    font-size: 0.76rem;
    color: var(--color-warm-gray);
    display: flex;
    gap: 0;
    align-items: center;
    flex-wrap: wrap;
    line-height: 1.5;
}

.tp-board__stock {
    color: var(--color-success);
    font-weight: 500;
}

.tp-board__stock--low {
    color: var(--color-warning);
}

.tp-board__lfm {
    font-weight: 600;
    color: var(--color-charcoal);
}

.tp-board__boards {
    color: var(--color-warm-gray);
}

/* Waste — inline tag with severity variants */
.tp-board__waste-tag {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    margin-left: 4px;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.tp-board__waste-tag--medium {
    color: var(--color-warning);
    background: rgba(196, 148, 61, 0.1);
}

.tp-board__waste-tag--high {
    color: var(--color-error);
    background: rgba(181, 74, 74, 0.1);
}

/* Price — right-aligned */
.tp-board__price {
    text-align: right;
    min-width: 85px;
}

.tp-board__total {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--color-secondary-dark);
    white-space: nowrap;
}

/* No results */
.tp-no-results {
    text-align: center;
    padding: var(--space-xl);
    color: var(--color-warm-gray);
    font-style: italic;
}

/* ==========================================================================
   ACCESSORIES — refined group styling
   ========================================================================== */

.tp-accessories {
    margin-top: var(--space-xl);
}

.tp-acc-group {
    margin-bottom: var(--space-lg);
}

.tp-acc-group__header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px 16px;
    background: var(--color-cream-dark);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    border: 1px solid var(--color-sand);
    border-bottom: none;
}

.tp-acc-group__icon {
    color: var(--color-secondary);
    display: flex;
}

.tp-acc-group__title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-charcoal);
    margin: 0;
    flex: 1;
}

.tp-acc-group__need {
    font-size: 0.78rem;
    color: var(--color-warm-gray);
    font-weight: 500;
}

.tp-acc-group__products {
    border: 1px solid var(--color-sand);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    overflow: hidden;
}

.tp-acc-item {
    display: grid;
    grid-template-columns: 28px auto 1fr auto;
    gap: var(--space-md);
    align-items: center;
    padding: 10px 16px;
    background: #fff;
    cursor: pointer;
    transition: all 0.15s;
    border-bottom: 1px solid var(--color-cream-dark);
}

.tp-acc-item:last-child { border-bottom: none; }

.tp-acc-item:hover {
    background: rgba(74, 103, 65, 0.03);
}

/* Radio (same as boards) */
.tp-acc-item__select {
    display: flex;
    align-items: center;
}

.tp-acc-item__select input[type="radio"] { display: none; }

.tp-acc-item__select label {
    width: 18px; height: 18px;
    border: 2px solid var(--color-sand);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.tp-acc-item__select input:checked + label {
    border-color: var(--color-secondary);
}

.tp-acc-item__select input:checked + label::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 8px; height: 8px;
    background: var(--color-secondary);
    border-radius: 50%;
}

.tp-acc-item__img {
    width: 40px; height: 30px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.tp-acc-item__info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.tp-acc-item__name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-charcoal);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tp-acc-item__price {
    font-size: 0.78rem;
    color: var(--color-warm-gray);
}

.tp-acc-item__qty {
    display: flex;
    flex-direction: column;
    gap: 1px;
    text-align: right;
}

.tp-acc-item__qty-val {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--color-charcoal);
}

.tp-acc-item__qty-total {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--color-secondary-dark);
}

/* ==========================================================================
   SUMMARY + ADD TO CART — clean card
   ========================================================================== */

.tp-summary {
    margin-top: var(--space-2xl);
    padding: var(--space-xl);
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 6px 20px rgba(0,0,0,0.04);
    border: 2px solid var(--color-secondary-light);
}

.tp-summary__row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.9rem;
    color: var(--color-charcoal);
    border-bottom: 1px solid var(--color-cream-dark);
}

.tp-summary__total {
    display: flex;
    justify-content: space-between;
    padding: 14px 0 12px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-secondary-dark);
    font-family: var(--font-display);
}

.tp-cart-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    width: 100%;
    padding: 14px;
    margin-top: var(--space-md);
    border: none;
    border-radius: var(--radius-md);
    background: var(--color-secondary);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.2s;
}

.tp-cart-btn:hover {
    background: var(--color-secondary-dark);
    box-shadow: 0 4px 12px rgba(45, 90, 61, 0.25);
}

.tp-cart-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.tp-cart-feedback {
    margin-top: var(--space-md);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    text-align: center;
}

.tp-cart-feedback a {
    color: inherit;
    font-weight: 700;
    text-decoration: underline;
}

.tp-cart-feedback--success {
    background: rgba(74, 124, 92, 0.1);
    color: var(--color-success);
    border: 1px solid rgba(74, 124, 92, 0.2);
}

.tp-cart-feedback--error {
    background: rgba(181, 74, 74, 0.1);
    color: var(--color-error);
    border: 1px solid rgba(181, 74, 74, 0.2);
}

/* ==========================================================================
   INFO SECTION — bottom of planner
   ========================================================================== */

.planner-info {
    padding: var(--space-2xl) 0;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-xl);
}

.info-box {
    text-align: center;
    padding: var(--space-xl);
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.info-box__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--color-cream);
    color: var(--color-primary);
    border-radius: 50%;
    margin-bottom: var(--space-md);
    font-size: 1.5rem;
}

.info-box__icon svg {
    width: 26px;
    height: 26px;
}

.info-box h4 {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    margin-bottom: var(--space-sm);
}

.info-box p {
    font-size: var(--text-sm);
    color: var(--color-warm-gray);
    margin: 0;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 900px) {
    .tp-dimensions {
        grid-template-columns: 1fr;
    }

    .tp-preview {
        border-right: none;
        border-bottom: 1px solid var(--color-sand);
        padding: var(--space-lg);
    }

    #tp-preview-svg {
        width: 180px;
        height: 145px;
    }

    .tp-board {
        grid-template-columns: 24px 44px 1fr auto;
        gap: 6px 10px;
        padding: 10px 12px;
    }

    .tp-filters {
        flex-direction: column;
        gap: var(--space-md);
    }

    .info-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .tp-dimensions__size {
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    .tp-dimensions__x {
        display: none;
    }

    .tp-dimensions__controls {
        padding: var(--space-lg);
        gap: var(--space-md);
    }

    .tp-field--direction,
    .tp-field--extra {
        width: 100%;
        min-width: unset;
    }

    .tp-extra-select {
        flex-wrap: wrap;
    }

    .tp-direction-toggle {
        flex: 1;
    }

    .tp-dir-btn {
        flex: 1;
        justify-content: center;
    }

    .tp-preview {
        padding: var(--space-md);
    }

    #tp-preview-svg {
        width: 160px;
        height: 130px;
    }

    .tp-board {
        grid-template-columns: 24px 1fr auto;
    }

    .tp-board__img { display: none; }

    .tp-board__name {
        font-size: 0.8rem;
    }

    .tp-board__meta {
        font-size: 0.7rem;
    }

    .tp-board__price {
        min-width: 70px;
    }

    .tp-acc-item {
        grid-template-columns: 24px 1fr auto;
    }

    .tp-acc-item__img { display: none; }
}

/* ═══════════════════════════════════════════════════
   QUICK OPTIONS PANEL (gap, pads, UK material, screws)
   Added in v3.1 — addresses Tony's feedback about empty
   space above the planner being unused.
   ═══════════════════════════════════════════════════ */
.tp-quick-options {
    margin: 16px 0 24px;
    padding: 18px 22px;
    background: #fff;
    border: 1.5px solid var(--color-cream-dark);
    border-radius: var(--radius-md);
}
.tp-quick-options__title {
    margin: 0 0 14px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-muted, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tp-quick-options__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px 24px;
}
.tp-qo {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.tp-qo__label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary, #333);
}
.tp-qo__choices {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.tp-qo-btn {
    flex: 1 1 auto;
    padding: 8px 14px;
    background: #fff;
    border: 1.5px solid var(--color-cream-dark);
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary, #333);
    transition: all 0.15s;
    white-space: nowrap;
}
.tp-qo-btn:hover {
    border-color: var(--color-secondary-light, #8aa583);
}
.tp-qo-btn.active {
    background: var(--color-secondary, #4a6741);
    border-color: var(--color-secondary, #4a6741);
    color: #fff;
}

/* ─── Tighten board card spacing (Tony #12) ─── */
.tp-board {
    padding: 10px 14px;
}
.tp-board__info {
    line-height: 1.35;
}

/* ─── Mobile tweaks ─── */
@media (max-width: 600px) {
    .tp-quick-options {
        padding: 14px 16px;
    }
    .tp-quick-options__grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    .tp-qo-btn {
        padding: 9px 10px;
        font-size: 12.5px;
    }
}


/* ═══════════════════════════════════════════════════
   SHAPE TOGGLE (Rectangle / L-shape) — Tony #9
   ═══════════════════════════════════════════════════ */
.tp-field--shape {
    margin-bottom: 8px;
}
.tp-shape-toggle {
    display: flex;
    gap: 8px;
}
.tp-shape-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #fff;
    border: 1.5px solid var(--color-cream-dark);
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary, #333);
    transition: all 0.15s;
}
.tp-shape-btn:hover {
    border-color: var(--color-secondary-light, #8aa583);
}
.tp-shape-btn.active {
    background: var(--color-secondary, #4a6741);
    border-color: var(--color-secondary, #4a6741);
    color: #fff;
}
.tp-shape-btn svg {
    flex-shrink: 0;
}
.tp-lshape-extra {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px dashed var(--color-cream-dark);
}


/* ═══════════════════════════════════════════════════
   ADMIN-ONLY NOTICE: empty accessory groups
   Shows category-config hints, only visible to logged-in admins.
   ═══════════════════════════════════════════════════ */
.tp-acc-group--empty {
    background: #fff8e1;
    border: 1.5px dashed #f5b400;
    border-radius: var(--radius-md, 8px);
    padding: 14px 18px;
    margin-bottom: 12px;
}
.tp-acc-group--empty .tp-acc-group__header {
    margin-bottom: 8px;
}
.tp-acc-group--empty .tp-acc-group__title {
    color: #7a5a00;
}
.tp-acc-group__notice {
    font-size: 13px;
    line-height: 1.5;
    color: #4a3a00;
}
.tp-acc-group__notice strong {
    display: inline-block;
    margin-right: 6px;
    color: #7a5a00;
}


/* ═══════════════════════════════════════════════════
   FILTER NOTICE — when QO toggle hides all items
   ═══════════════════════════════════════════════════ */
.tp-acc-group__filter-notice {
    padding: 14px 18px;
    margin: 8px 0;
    background: #f5f3ed;
    border: 1px dashed var(--color-cream-dark);
    border-radius: var(--radius-md, 8px);
    font-size: 13px;
    color: var(--color-text-muted, #666);
    line-height: 1.5;
    text-align: center;
}