/* ============================================================
   TTPixel Studio — Premium Builder CSS
   Deep Navy × Gold design system
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─── CSS Variables ─────────────────────────────────────────── */
:root {
    --navy:          #0d1128;
    --navy-2:        #141a35;
    --navy-3:        #1c2444;
    --navy-4:        #232b50;
    --gold:          #c9a84c;
    --gold-light:    #e6c97a;
    --gold-dark:     #a8863b;
    --text:          #e8eaf0;
    --text-muted:    #8892a4;
    --border:        rgba(201, 168, 76, 0.15);
    --border-hover:  rgba(201, 168, 76, 0.4);
    --success:       #22c55e;
    --danger:        #ef4444;
    --info:          #3b82f6;
    --radius:        12px;
    --radius-sm:     8px;
    --shadow:        0 4px 32px rgba(0, 0, 0, 0.5);
    --topbar-h:      56px;
    --bottombar-h:   72px;
    --transition:    all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--navy);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    height: 100%;
    overflow: hidden;
}

.ttpixel-studio-body {
    overflow: hidden;
}

/* ─── Studio Container ──────────────────────────────────────── */
.ts-studio {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    max-width: 100%;
    margin: 0;
    position: relative;
}

/* ─── Top Bar ───────────────────────────────────────────────── */
.ts-topbar {
    height: var(--topbar-h);
    background: var(--navy-2);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
    z-index: 100;
}

.ts-topbar__logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.ts-topbar__logo img { height: 36px; object-fit: contain; }

.ts-topbar__brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.5px;
}

.ts-topbar__title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.ts-topbar__label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

.ts-topbar-btn {
    background: rgba(201, 168, 76, 0.1);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 20px;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.ts-topbar-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
}

/* ─── Main Split Area ───────────────────────────────────────── */
.ts-main {
    flex: 1;
    display: flex;
    overflow: hidden;
    height: calc(100vh - var(--topbar-h) - var(--bottombar-h));
}

/* ─── Panels ────────────────────────────────────────────────── */
.ts-panel {
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ts-panel--left  { flex-basis: 60%; }
.ts-panel--right { flex-basis: 40%; }

.ts-panel--left {
    background: var(--navy-2);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--navy-4) transparent;
}

.ts-panel--left::-webkit-scrollbar { width: 4px; }
.ts-panel--left::-webkit-scrollbar-track { background: transparent; }
.ts-panel--left::-webkit-scrollbar-thumb { background: var(--navy-4); border-radius: 4px; }

.ts-panel--right {
    background: var(--navy);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ─── Combined Design Section (Front + Back in one tab) ──────── */
.ts-design-section {
    margin-bottom: 6px;
}

.ts-design-section__header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px 6px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(201, 168, 76, 0.2);
}

.ts-design-section__icon { font-size: 1rem; }

.ts-design-section__label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 1;
}

.ts-design-section__hint {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.ts-design-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(201, 168, 76, 0.2), transparent);
    margin: 10px 0 14px;
}

/* ─── Category Accordion ────────────────────────────────────── */
.ts-accordion {
    padding: 12px;
}

.ts-accordion__item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    overflow: hidden;
    transition: var(--transition);
}

.ts-accordion__item.is-open {
    border-color: var(--gold);
    box-shadow: 0 0 0 1px rgba(201, 168, 76, 0.15), var(--shadow);
}

.ts-accordion__trigger {
    width: 100%;
    background: var(--navy-3);
    border: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    cursor: pointer;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.ts-accordion__trigger:hover,
.ts-accordion__item.is-open .ts-accordion__trigger {
    background: var(--navy-4);
}

.ts-acc-icon { font-size: 1.2rem; }
.ts-acc-name { flex: 1; text-align: left; font-weight: 600; }
.ts-acc-charge {
    font-size: 0.75rem;
    color: var(--gold);
    background: rgba(201, 168, 76, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
}
.ts-acc-arrow {
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: transform 0.2s ease;
}
.ts-accordion__item.is-open .ts-acc-arrow {
    transform: rotate(180deg);
    color: var(--gold);
}

.ts-accordion__body {
    display: none;
    padding: 0 12px 12px;
    background: var(--navy-2);
    animation: accBodyIn 0.2s ease;
}

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

.ts-accordion__item.is-open .ts-accordion__body {
    display: block;
}

/* ─── Accordion Active Selection Summary ────────────────────── */
.ts-accordion-summary {
    background: rgba(201, 168, 76, 0.05);
    border: 1px solid rgba(201, 168, 76, 0.15);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.78rem;
    animation: fadeIn 0.2s ease;
}

.ts-acc-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
}

.ts-acc-summary-item strong {
    font-weight: 500;
    color: var(--text-muted);
}

.ts-acc-summary-item span {
    color: var(--gold);
    font-weight: 600;
    text-align: right;
}

/* ─── Sub Tabs ──────────────────────────────────────────────── */
.ts-subtabs {
    display: flex;
    gap: 4px;
    padding: 12px 0 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.ts-subtab {
    flex: 1;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-size: 0.72rem;
    font-weight: 500;
    padding: 6px 4px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    white-space: nowrap;
}

.ts-subtab:hover {
    color: var(--text);
    background: rgba(201, 168, 76, 0.06);
}

.ts-subtab.active {
    color: var(--gold);
    background: rgba(201, 168, 76, 0.1);
    border-color: rgba(201, 168, 76, 0.3);
}

/* ─── Pagination (Fabrics & Designs) ────────────────────────── */
.ts-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
}

.ts-page-info {
    color: var(--text-muted);
    font-weight: 500;
}

.ts-page-btn {
    background: var(--navy-3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ts-page-btn:hover:not(:disabled) {
    background: rgba(201, 168, 76, 0.15);
    border-color: var(--gold);
    color: var(--gold);
}

.ts-page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.ts-page-numbers {
    display: flex;
    gap: 5px;
    align-items: center;
}

.ts-page-num {
    min-width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--navy-3);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    padding: 0 4px;
}

.ts-page-num:hover {
    border-color: var(--gold);
    color: var(--text);
}

.ts-page-num.active {
    background: var(--gold);
    color: var(--navy);
    border-color: var(--gold);
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(201, 168, 76, 0.3);
}

/* ─── Grid (Fabrics + Designs) ──────────────────────────────── */
.ts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    padding: 4px 0;
}

/* Fabric Card */
.ts-fabric-card {
    background: var(--navy-3);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.ts-fabric-card:hover {
    border-color: rgba(201, 168, 76, 0.4);
    transform: translateY(-2px);
}

.ts-fabric-card.selected {
    border-color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold), 0 4px 12px rgba(201, 168, 76, 0.2);
}

.ts-fabric-card.selected::after {
    content: '✓';
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--gold);
    color: var(--navy);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
}

.ts-fabric-card__img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--navy-4);
    display: block;
}

.ts-fabric-card__info {
    padding: 6px 8px;
}

.ts-fabric-card__name {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ts-fabric-card__price {
    font-size: 0.7rem;
    color: var(--gold);
    font-weight: 600;
    margin-top: 1px;
}

/* Design Card */
.ts-design-card {
    background: var(--navy-3);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.ts-design-card:hover  { border-color: rgba(201, 168, 76, 0.4); transform: translateY(-2px); }
.ts-design-card.selected {
    border-color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold);
}

.ts-design-card__img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--navy-4);
    display: block;
}

.ts-design-card__none {
    background: var(--navy-3);
    color: var(--text-muted);
    font-size: 0.68rem;
    cursor: pointer;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    overflow: hidden;
}

.ts-design-card__none:hover { border-color: rgba(201, 168, 76, 0.4); transform: translateY(-2px); }
.ts-design-card__none.selected { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }

.ts-design-card__name {
    font-size: 0.68rem;
    padding: 5px 6px;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ts-design-card__price {
    font-size: 0.65rem;
    color: var(--gold);
    padding: 0 6px 5px;
    text-align: center;
}

/* Fabric Info Box */
.ts-fabric-info {
    background: var(--navy-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 10px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.ts-fabric-info__name { font-weight: 600; font-size: 0.875rem; color: var(--gold); }
.ts-fabric-info__price { font-size: 0.8rem; color: var(--text-muted); margin: 4px 0 8px; }
.ts-fabric-info__attrs { display: flex; flex-direction: column; gap: 5px; }
.ts-attr-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    padding: 3px 0;
    border-bottom: 1px solid rgba(201, 168, 76, 0.06);
}
.ts-attr-item .at-label { color: var(--text-muted); }
.ts-attr-item .at-value { color: var(--text); font-weight: 500; }

/* ─── Measurement ───────────────────────────────────────────── */
.ts-measure-wrap { padding: 4px 0; }

.ts-measure-mode-toggle {
    display: flex;
    background: var(--navy-3);
    border-radius: var(--radius-sm);
    padding: 3px;
    gap: 3px;
    margin-bottom: 14px;
}

.ts-mode-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 7px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.ts-mode-btn.active {
    background: var(--navy);
    color: var(--gold);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Size chips */
.ts-size-chips { display: flex; gap: 8px; flex-wrap: wrap; }

.ts-size-chip {
    padding: 8px 18px;
    background: var(--navy-3);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.5px;
}

.ts-size-chip:hover { border-color: rgba(201, 168, 76, 0.4); }
.ts-size-chip.selected { background: rgba(201, 168, 76, 0.12); border-color: var(--gold); color: var(--gold); }

/* Size preview grid */
.ts-size-preview__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.ts-size-cell {
    background: rgba(201, 168, 76, 0.06);
    border: 1px solid rgba(201, 168, 76, 0.15);
    border-radius: 6px;
    padding: 8px;
    text-align: center;
}

.ts-size-cell .sc-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.ts-size-cell .sc-value { font-size: 0.9rem; font-weight: 700; color: var(--gold); margin-top: 2px; }
.ts-size-cell .sc-unit  { font-size: 0.6rem; color: var(--text-muted); }

/* Unit toggle */
.ts-unit-toggle {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.ts-unit-btn {
    background: var(--navy-3);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    padding: 5px 14px;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
}

.ts-unit-btn.active {
    background: rgba(201, 168, 76, 0.12);
    border-color: var(--gold);
    color: var(--gold);
}

/* Custom measurement inputs */
.ts-custom-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.ts-measure-field label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
    margin-bottom: 4px;
}

.ts-measure-field input {
    width: 100%;
    background: var(--navy-3);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    padding: 7px 10px;
    outline: none;
    transition: var(--transition);
}

.ts-measure-field input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(201, 168, 76, 0.1);
}

/* Add to Order Button */
.ts-add-btn-wrap { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }

/* Quantity + Add row */
.ts-add-btn-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.ts-qty-wrap {
    display: flex;
    align-items: center;
    background: rgba(201, 168, 76, 0.1);
    border: 1px solid rgba(201, 168, 76, 0.5);
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    transition: var(--transition);
    min-height: 44px;
}

.ts-qty-wrap:focus-within {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(201, 168, 76, 0.15);
}

.ts-qty-btn {
    background: transparent;
    border: none;
    color: var(--navy);
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 800;
    width: 28px;
    height: 100%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    min-height: 44px;
}

.ts-qty-btn:hover {
    background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
    box-shadow: inset 0 0 8px rgba(0,0,0,0.15);
}

.ts-qty-input {
    width: 34px;
    background: rgba(201, 168, 76, 0.08);
    border: none;
    border-left: 1px solid rgba(201, 168, 76, 0.3);
    border-right: 1px solid rgba(201, 168, 76, 0.3);
    color: var(--gold);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 800;
    text-align: center;
    padding: 0;
    outline: none;
    -moz-appearance: textfield;
    height: 100%;
    min-height: 44px;
    letter-spacing: 0.5px;
}

.ts-qty-input::-webkit-outer-spin-button,
.ts-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ts-add-btn {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--navy);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 10px 8px;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.2px;
    line-height: 1.25;
    white-space: normal;
    word-break: break-word;
}

.ts-add-btn:hover {
    background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
    box-shadow: 0 4px 16px rgba(201, 168, 76, 0.35);
    transform: translateY(-1px);
}

/* ─── Loading State ─────────────────────────────────────────── */
.ts-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 20px 0;
}

.ts-loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ─── Right Panel: Preview ──────────────────────────────────── */
.ts-preview-wrap {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 14px;
}

/* Face Toggle */
.ts-face-toggle {
    display: flex;
    gap: 4px;
    background: var(--navy-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
    align-self: flex-start;
}

.ts-face-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.ts-face-btn.active {
    background: var(--navy-3);
    color: var(--gold);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Stage */
.ts-stage {
    flex: 1;
    background: var(--navy-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

/* 3:4 fixed ratio preview canvas — always portrait, centered inside stage */
.ts-stage-canvas {
    position: relative;
    aspect-ratio: 3 / 4;
    /* Take full width but never overflow the stage height */
    width: auto;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
    background: var(--navy-3);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.ts-stage__placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
}

.ts-placeholder-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.4; }
.ts-stage__placeholder p { font-size: 0.85rem; opacity: 0.6; }

/* Layer Stack */
.ts-layer-stack {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ts-layer {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.ts-layer img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.3s ease;
}

.ts-layer--silhouette { z-index: 1; display: none !important; }
.ts-layer--fabric {
    z-index: 2;
}
.ts-layer--design     { z-index: 3; }
/* Frame layer hidden — SVG silhouettes are solid white, not outline-only */
.ts-layer--frame      { display: none !important; }

.ts-layer--fabric img {
    object-fit: contain;
    mix-blend-mode: normal;
}

/* Garment frame overlay — currently hidden, reserved for future outline-only frames */
#ts-frame-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    display: none !important;
}

/* Summary Panel */
.ts-summary {
    background: var(--navy-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    flex-shrink: 0;
}

.ts-summary__title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 10px;
}

.ts-summary__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid rgba(201, 168, 76, 0.06);
    font-size: 0.8rem;
}

.ts-sum-label { color: var(--text-muted); }
.ts-sum-value { color: var(--text); font-weight: 500; max-width: 60%; text-align: right; }

.ts-summary__total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    margin-top: 4px;
    font-weight: 700;
    font-size: 0.95rem;
}

.ts-summary__amount { color: var(--gold); font-size: 1.1rem; }

/* Price breakdown sub-rows */
.ts-price-breakdown {
    border-top: 1px dashed rgba(201, 168, 76, 0.2);
    margin-top: 6px;
    padding-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ts-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
}

.ts-price-row .pr-label { color: var(--text-muted); }
.ts-price-row .pr-value { color: var(--text); font-weight: 500; }
.ts-price-row.pr-tailor .pr-label { color: var(--gold-light); }
.ts-price-row.pr-tailor .pr-value { color: var(--gold-light); font-weight: 600; }
.ts-price-row.pr-total .pr-label  { color: var(--text); font-weight: 700; }
.ts-price-row.pr-total .pr-value  { color: var(--gold); font-weight: 800; font-size: 0.85rem; }

/* ─── Bottom Bar ────────────────────────────────────────────── */
.ts-bottombar {
    height: var(--bottombar-h);
    background: var(--navy-2);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    flex-shrink: 0;
    z-index: 100;
}

.ts-bottombar__cart {
    flex: 1;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
    scrollbar-width: none;
}

.ts-bottombar__cart::-webkit-scrollbar { display: none; }

.ts-cart-empty { color: var(--text-muted); font-size: 0.8rem; align-self: center; }

/* Cart chip */
.ts-cart-chip {
    background: rgba(201, 168, 76, 0.1);
    border: 1px solid rgba(201, 168, 76, 0.3);
    border-radius: 20px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    white-space: nowrap;
    animation: chipIn 0.2s ease;
}

@keyframes chipIn {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}

.ts-cart-chip__name  { color: var(--text); font-weight: 600; }
.ts-cart-chip__fabric { color: var(--text-muted); font-size: 0.72rem; }
.ts-cart-chip__qty {
    background: rgba(201, 168, 76, 0.2);
    color: var(--gold);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    border: 1px solid rgba(201, 168, 76, 0.3);
}
.ts-cart-chip__price { color: var(--gold); font-weight: 700; }
.ts-cart-chip__remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 0;
    line-height: 1;
    transition: color 0.15s;
}
.ts-cart-chip__remove:hover { color: var(--danger); }

.ts-bottombar__actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.ts-bottombar__total {
    text-align: right;
}

.ts-total-label { display: block; font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.ts-total-amount { display: block; font-size: 1.2rem; font-weight: 800; color: var(--gold); }

.ts-order-btn {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--navy);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    padding: 12px 28px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.ts-order-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.ts-order-btn:not(:disabled):hover {
    box-shadow: 0 4px 20px rgba(201, 168, 76, 0.4);
    transform: translateY(-1px);
}

/* ─── Modal ─────────────────────────────────────────────────── */
.ts-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ts-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

.ts-modal__box {
    position: relative;
    background: var(--navy-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    box-shadow: var(--shadow);
    animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    scrollbar-width: thin;
    scrollbar-color: var(--navy-4) transparent;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(16px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.ts-modal__close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ts-modal__close:hover { background: rgba(239,68,68,0.15); color: var(--danger); border-color: var(--danger); }

.ts-modal__title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 24px 0;
}

/* ─── Checkout Layout ───────────────────────────────────────── */
.ts-checkout-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    align-items: start;
}

.ts-co-section { margin-bottom: 24px; }
.ts-co-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 14px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.ts-co-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.ts-co-group { margin-bottom: 14px; }

.ts-co-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
}

.ts-co-group label .req { color: var(--danger); }

.ts-co-input {
    width: 100%;
    background: var(--navy-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    padding: 10px 14px;
    outline: none;
    transition: var(--transition);
    resize: vertical;
}

.ts-co-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(201, 168, 76, 0.1);
}

.ts-co-input::placeholder { color: var(--text-muted); }

/* Shipping / Payment Options */
.ts-shipping-options,
.ts-payment-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ts-radio-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    background: var(--navy-3);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.ts-radio-option:hover    { border-color: rgba(201, 168, 76, 0.4); }
.ts-radio-option.selected { border-color: var(--gold); background: rgba(201, 168, 76, 0.06); }
.ts-radio-option.selected .ro-radio { background: var(--gold); }

.ro-radio {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 2px;
    transition: var(--transition);
    position: relative;
}

.ts-radio-option.selected .ro-radio::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--navy);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.ro-content { flex: 1; }
.ro-title { font-size: 0.875rem; font-weight: 600; color: var(--text); }
.ro-sub   { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.ro-price { font-size: 0.85rem; font-weight: 700; color: var(--gold); }

/* Terms checkbox */
.ts-terms-check {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.ts-terms-check input[type="checkbox"] {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-top: 2px;
    accent-color: var(--gold);
}

/* Submit Button */
.ts-submit-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--navy);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    padding: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.ts-submit-btn:hover {
    box-shadow: 0 4px 20px rgba(201, 168, 76, 0.4);
    transform: translateY(-1px);
}

/* Checkout Summary Sidebar */
.ts-checkout-summary {
    background: var(--navy-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: sticky;
    top: 0;
}

.ts-co-item {
    padding: 10px 0;
    border-bottom: 1px solid rgba(201, 168, 76, 0.07);
}

.ts-co-item__header { display: flex; justify-content: space-between; font-weight: 600; font-size: 0.85rem; margin-bottom: 4px; }
.ts-co-item__header .item-price { color: var(--gold); }
.ts-co-item__detail { font-size: 0.72rem; color: var(--text-muted); line-height: 1.7; }

.ts-co-totals { margin-top: 12px; }
.ts-co-total-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 4px 0;
}
.ts-co-total-row.grand {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
    border-top: 1px solid var(--border);
    padding-top: 10px;
    margin-top: 6px;
}
.ts-co-total-row.grand .gt-amount { color: var(--gold); font-size: 1.15rem; }

/* ─── Confirmation Screen ───────────────────────────────────── */
.ts-confirm-wrap { text-align: center; padding: 20px; }
.ts-confirm-icon { font-size: 4rem; margin-bottom: 16px; }
.ts-confirm-title { font-size: 1.6rem; font-weight: 800; color: #fff; margin-bottom: 12px; }
.ts-confirm-order-code {
    background: rgba(201, 168, 76, 0.1);
    border: 1px solid rgba(201, 168, 76, 0.3);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    display: inline-block;
    margin-bottom: 16px;
    font-size: 1rem;
    color: var(--gold);
}
.ts-confirm-msg { color: var(--text-muted); font-size: 0.9rem; max-width: 440px; margin: 0 auto 28px; line-height: 1.7; }
.ts-confirm-actions { display: flex; gap: 12px; justify-content: center; }
.ts-btn-primary {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--navy);
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    padding: 10px 24px;
    cursor: pointer;
    text-decoration: none;
}
.ts-btn-outlined {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    padding: 10px 24px;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}
.ts-btn-outlined:hover { border-color: var(--gold); color: var(--gold); }

/* ─── Empty States ──────────────────────────────────────────── */
.ts-empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.ts-empty-state .es-icon { font-size: 2rem; opacity: 0.4; margin-bottom: 8px; }

/* ─── Responsive: Tablet ────────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
    .ts-panel--left  { flex-basis: 55%; }
    .ts-panel--right { flex-basis: 45%; }
}

/* ─── Responsive: Mobile (≤ 768px) ─────────────────────────── */
@media (max-width: 768px) {
    /* Allow page to scroll on mobile */
    html, body {
        overflow: auto;
        height: auto;
    }
    .ttpixel-studio-body {
        overflow: auto;
        height: auto;
    }

    /* Sticky topbar on mobile */
    .ts-topbar {
        position: sticky;
        top: 0;
        z-index: 150;
        padding: 0 12px;
    }
    .ts-topbar__title {
        display: none;
    }

    /* Studio container: vertical flow */
    .ts-studio {
        height: auto;
        min-height: 100svh;
        overflow: visible;
        display: flex;
        flex-direction: column;
    }

    /* Main area: stacked column */
    .ts-main {
        flex-direction: column;
        height: auto;
        overflow: visible;
        flex: 1;
    }

    /* Panels: full width */
    .ts-panel {
        flex-basis: auto !important;
        width: 100%;
    }

    /* Right panel (preview): compact sticky at top */
    .ts-panel--right {
        height: 310px;
        position: sticky;
        top: var(--topbar-h);
        z-index: 50;
        border-bottom: 1px solid var(--border);
        border-right: none;
        flex-shrink: 0;
        overflow: hidden;
        padding: 10px;
        gap: 8px;
    }

    /* Left panel: normal flow (no scroll lock) */
    .ts-panel--left {
        overflow: visible;
        border-right: none;
        border-top: 1px solid var(--border);
        flex-shrink: 0;
    }

    /* Preview layout on mobile: face toggle + stage side by side */
    .ts-preview-wrap {
        flex-direction: column;
        height: 100%;
        gap: 6px;
    }

    /* Face toggle: centered, smaller */
    .ts-face-toggle {
        align-self: center;
    }
    .ts-face-btn {
        font-size: 0.7rem;
        padding: 4px 10px;
    }

    /* Summary panel: hide on mobile (info visible in cart chips) */
    .ts-summary {
        display: none;
    }

    /* Stage fills all remaining space */
    .ts-stage {
        flex: 1;
        min-height: 0;
    }

    /* Accordion tighter on mobile */
    .ts-accordion { padding: 8px; }
    .ts-accordion__trigger {
        padding: 10px 12px;
        font-size: 0.82rem;
        gap: 8px;
    }

    /* Compact Quantity + Add button row on mobile */
    .ts-add-btn-row {
        gap: 6px;
    }

    .ts-qty-wrap {
        min-height: 38px;
        flex-shrink: 0;
    }

    .ts-qty-btn {
        width: 24px;
        min-height: 38px;
        font-size: 0.9rem;
    }

    .ts-qty-input {
        width: 28px;
        min-height: 38px;
        font-size: 0.85rem;
    }

    .ts-add-btn {
        font-size: 0.78rem;
        padding: 6px 8px;
        min-height: 38px;
        line-height: 1.2;
    }

    /* Grid: 3 columns on mobile */
    .ts-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    /* Bottom bar: stacked, sticky */
    .ts-bottombar {
        flex-direction: column;
        height: auto;
        padding: 10px 14px;
        gap: 8px;
        position: sticky;
        bottom: 0;
        z-index: 100;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
    }

    .ts-bottombar__cart {
        width: 100%;
        padding: 2px 0;
    }

    .ts-bottombar__actions {
        width: 100%;
        justify-content: space-between;
        gap: 12px;
    }

    .ts-order-btn {
        flex: 1;
        text-align: center;
        justify-content: center;
        padding: 11px 16px;
        font-size: 0.85rem;
    }

    /* Checkout modal: full screen and stacked on mobile */
    .ts-checkout-grid {
        display: flex;
        flex-direction: column;
    }
    .ts-checkout-summary {
        order: -1;
        margin-bottom: 20px;
        position: static;
    }
    .ts-co-grid {
        grid-template-columns: 1fr;
    }

    .ts-modal__box {
        padding: 16px;
        width: 98%;
        max-height: 98svh;
        border-radius: 8px;
    }

    .ts-modal__title {
        font-size: 1.1rem;
        margin-bottom: 16px;
        padding-right: 32px;
    }

    /* Stack confirmation actions on mobile */
    .ts-confirm-actions {
        flex-direction: column;
        gap: 10px;
    }
    .ts-confirm-actions a,
    .ts-confirm-actions button {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}

/* ─── Very Small Phones (≤ 380px) ───────────────────────────── */
@media (max-width: 380px) {
    .ts-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .ts-panel--right {
        height: 260px;
    }

    .ts-topbar__title { display: none; }
}
