/* ── AI T-Shirt Maker — Design System ──
   Inspired by Notion, Kittl, Apple
   Light theme, generous spacing, premium feel
*/

:root {
    --bg: #f5f5f0;
    --surface: #ffffff;
    --surface-alt: #fafaf8;
    --surface-hover: #f0efec;
    --raised: #f5f4f1;
    --border: #e5e3de;
    --border-subtle: #eceae5;
    --text: #1a1a1a;
    --text-secondary: #5c5c5c;
    --text-tertiary: #9a9a9a;
    --accent: #1a1a1a;
    --accent-hover: #333333;
    --accent-subtle: #1a1a1a0a;
    --accent-text: #faffbb;
    --brand: #faffbb;
    --brand-hover: #f0f5a0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.03);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.03);
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    font-family: 'Instrument Serif', Georgia, serif;
}

/* ── Cards ── */

.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

/* ── Buttons ── */

.btn-primary {
    height: 40px;
    padding: 0 20px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-text);
    font-size: 15px;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.15s, transform 0.1s;
    cursor: pointer;
    border: none;
    white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.4; pointer-events: none; }

.btn-secondary {
    height: 36px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 14px;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border);
    transition: all 0.15s;
    cursor: pointer;
    white-space: nowrap;
}
.btn-secondary:hover {
    background: var(--surface-hover);
    border-color: #d5d3ce;
    color: var(--text);
}
.btn-secondary:active { transform: scale(0.98); }

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    transition: all 0.15s;
    cursor: pointer;
}
.btn-icon:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.tool-btn {
    height: 32px;
    padding: 0 10px;
    border-radius: 6px;
    background: var(--raised);
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 1px solid var(--border-subtle);
    transition: all 0.15s;
    cursor: pointer;
    white-space: nowrap;
}
.tool-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border);
    color: var(--text);
}
.tool-btn svg, .tool-btn i { width: 14px; height: 14px; }

/* ── Form elements ── */

textarea { resize: none; }

.input {
    width: 100%;
    height: 40px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}
.input:focus {
    border-color: var(--text);
    box-shadow: 0 0 0 3px #faffbb60;
}
.input::placeholder { color: var(--text-tertiary); }

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--brand);
    border: 2px solid var(--text);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}
input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--brand);
    border: 2px solid var(--text);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

/* ── Toggle ── */

.toggle-track {
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: #d1d1cc;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}
.toggle-track::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
input:checked + .toggle-track {
    background: var(--text);
}
input:checked + .toggle-track::after {
    transform: translateX(18px);
}

/* ── Labels ── */

.label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

/* ── Scrollbar ── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d1cc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #b5b5b0; }

/* ── T-shirt Preview ── */

.preview-card {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}

#tshirtPhoto {
    filter: drop-shadow(0 4px 20px rgba(0,0,0,0.06));
}

.print-zone {
    stroke-dasharray: 6 4;
    animation: dash 20s linear infinite;
}
@keyframes dash { to { stroke-dashoffset: -100; } }

/* ── Loading ── */

.loading-spinner { animation: spin 1s linear infinite; }
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ── Animations ── */

.fade-in {
    animation: fadeIn 0.3s ease forwards;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
}

/* ── Side toggle + Zone ── */

.side-toggle, .zone-option {
    transition: all 0.15s;
    color: var(--text-secondary);
}
.side-toggle:hover, .zone-option:hover {
    color: var(--text);
    background: var(--surface-hover);
}
.side-toggle.active {
    background: var(--text);
    color: var(--brand);
}
.zone-option.active {
    background: var(--text);
    color: var(--brand);
}

/* ── SVG Layers ── */

#designLayers image, #designLayers text { cursor: move; }
#designLayers image:hover, #designLayers text:hover {
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.25));
}
.selection-handle { cursor: nwse-resize; }

/* ── Color Swatches ── */

.color-swatch {
    transition: transform 0.15s;
    cursor: pointer;
    border: 2px solid transparent;
}
.color-swatch:hover { transform: scale(1.12); }
.color-swatch.active {
    transform: scale(1.15);
    box-shadow: 0 0 0 3px var(--brand), 0 0 0 5px var(--text);
}

/* ── Image tools ── */

#bgRemoveBtn.processing { opacity: 0.5; pointer-events: none; }
#eraserToggleBtn.active {
    background: #faffbb !important;
    border-color: var(--text) !important;
    color: var(--text) !important;
}
.eraser-cursor, .eraser-cursor image, .eraser-cursor rect, .eraser-cursor text {
    cursor: crosshair !important;
}
#eraserBrush { pointer-events: none; }

/* ── Layers strip ── */

.layers-strip {
    width: 160px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-subtle);
    background: var(--surface-alt);
}

.layer-strip-item {
    cursor: grab;
    transition: all 0.15s;
    user-select: none;
}
.layer-strip-item:active { cursor: grabbing; }
.layer-strip-item:hover { background: var(--surface-hover); }
.layer-strip-item.selected {
    background: #faffbb30;
    border-color: var(--text) !important;
}
.layer-strip-item.drag-over { border-top: 2px solid var(--text); }
.layer-strip-item.dragging { opacity: 0.3; }
.layer-strip-item .delete-btn { opacity: 0; transition: opacity 0.15s; }
.layer-strip-item:hover .delete-btn { opacity: 1; }

/* ── History ── */

.history-item { transition: all 0.2s; }
.history-item:hover {
    transform: scale(1.03);
    box-shadow: var(--shadow-lg);
}

/* ── Auth ── */

.auth-modal { animation: modalIn 0.2s ease forwards; }
.auth-tab { transition: all 0.15s; color: var(--text-tertiary); }
.auth-tab.active { color: var(--text); border-bottom: 2px solid var(--text); }

/* ── Image Editor ── */

.editor-modal { animation: modalIn 0.2s ease forwards; }
#editorCanvas { transition: border-radius 0.2s ease; }
.editor-draw-cursor { cursor: crosshair !important; }

#editorPaintBtn.active,
#editorEraserBtn.active {
    background: #faffbb !important;
    border-color: var(--text) !important;
    color: var(--text) !important;
}

/* ── Canvas wrapper ── */

/* ── Niche strip ── */

.niche-strip { scrollbar-width: none; }
.niche-strip::-webkit-scrollbar { display: none; }

.canvas-bg {
    background:
        linear-gradient(45deg, #f0efec 25%, transparent 25%),
        linear-gradient(-45deg, #f0efec 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f0efec 75%),
        linear-gradient(-45deg, transparent 75%, #f0efec 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
    background-color: #e8e7e3;
}
