/* TeeSpectrum - Main Styles */

* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 0;
    background: #f5f5f5;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Site Header */
.site-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 1rem;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    gap: 0.5rem;
}

.site-header h1 {
    color: #333;
    margin: 0;
    font-size: 1.25rem;
    padding: 0;
    text-align: center;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.user-info {
    font-size: 0.8rem;
    color: #666;
}

.credit-badge {
    background: #dcfce7;
    color: #166534;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.nav-link {
    color: #2563eb;
    text-decoration: none;
    font-size: 0.875rem;
}

.nav-link:hover {
    text-decoration: underline;
}

.nav-link-primary {
    background: #2563eb;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
}

.nav-link-primary:hover {
    background: #1d4ed8;
    text-decoration: none;
}

/* Messages */
.messages {
    padding: 0 1rem;
    margin-bottom: 0.5rem;
}

.message {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.message.success {
    background: #dcfce7;
    color: #166534;
}

.message.info {
    background: #e0f2fe;
    color: #0369a1;
}

.message.error {
    background: #fee2e2;
    color: #dc2626;
}

h1 {
    color: #333;
    padding: 1rem 1rem 0;
    margin: 0;
}

.error {
    background: #fee2e2;
    color: #dc2626;
    padding: 1rem;
    border-radius: 4px;
    margin: 0 1rem 1rem;
}

.results {
    background: white;
    padding: 0;
    padding-bottom: 80px;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

/* Preview stack */
.preview-wrapper {
    padding: 16px;
    transition: background-color 0.2s, background-image 0.2s;
    margin-bottom: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}

.preview-stack {
    position: relative;
    aspect-ratio: 15 / 17;
    overflow: hidden;
    transition: width 0.3s, left 0.3s, top 0.3s;
}

.preview-stack .sizer {
    display: none;
}

.preview-stack .bg-layer,
.preview-stack .fg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Zoom out mode */
.preview-wrapper.zoomed-out {
    padding: 0;
    aspect-ratio: 1 / 1;
}

.preview-wrapper.zoomed-out .preview-stack {
    position: absolute;
    width: 40%;
    left: 30%;
    top: 22.5%;
}

/* Zoom toggle button */
.zoom-toggle {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: background 0.15s;
    z-index: 10;
}

.zoom-toggle:hover {
    background: white;
}

.fabric-name {
    text-align: center;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    color: #666;
    background: white;
}

/* Switches */
.switches {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 0.5rem;
    padding: 0 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.switch-group {
    display: flex;
    background: #e5e7eb;
    border-radius: 8px;
    padding: 3px;
}

.switch-option {
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: #666;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.switch-option:hover:not(.disabled) {
    color: #333;
}

.switch-option.active {
    background: white;
    color: #333;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.switch-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Temporary green flash when watercolor becomes ready */
.switch-option.just-ready {
    background: #16a34a;
    color: white;
    animation: ready-pulse 0.3s ease-out;
}

@keyframes ready-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Spinner - for preview loading */
.spinner {
    width: 36px;
    height: 36px;
    border: 2px solid #ccc;
    border-top-color: #666;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Watercolor button with spinner overlay */
#watercolor-switch {
    position: relative;
    flex-direction: column;
    gap: 2px;
}

#watercolor-switch .switch-text {
    order: 2;
}

.spinner-overlay {
    order: 1;
    width: 20px;
    height: 20px;
    border: 2px solid #ccc;
    border-top-color: #666;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Fabric sections */
.fabric-section {
    margin-bottom: 1.5rem;
    padding: 0 1rem;
    overflow: hidden;
}

.section-label {
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #333;
}

/* Recommended colors - single scrollable row */
.recommended-colors {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.recommended-colors::-webkit-scrollbar {
    display: none;
}

/* Other colors - responsive grid */
.other-colors {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
    gap: 4px;
}

.fabric-swatch {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: 3px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s;
}

.recommended-colors .fabric-swatch {
    width: 36px;
    height: 36px;
}

.fabric-swatch.selected {
    border-color: #2563eb;
}

.fabric-swatch.placeholder-swatch {
    background: #e5e7eb;
    cursor: default;
}

/* Timing (collapsible) */
.timing-toggle {
    font-size: 0.85rem;
    color: #888;
    cursor: pointer;
    margin-top: 1rem;
    padding: 1rem;
    text-align: center;
}

.timing-toggle:hover {
    color: #666;
}

.timing-details {
    display: none;
    padding: 0 1rem 1rem;
}

.timing-details.show {
    display: block;
}

.timing-table {
    font-size: 0.85rem;
    color: #666;
    margin: 0 auto;
}

.timing-table td {
    padding: 0.25rem 1rem 0.25rem 0;
}

.timing-table td:last-child {
    text-align: right;
    font-family: monospace;
}

/* Empty preview placeholder */
.preview-empty {
    background: #e5e7eb;
}

.preview-placeholder {
    aspect-ratio: 15 / 17;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

/* Preview loading spinner */
.preview-loading {
    aspect-ratio: 15 / 17;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
}

.preview-loading .spinner {
    width: 48px;
    height: 48px;
    border-width: 3px;
    margin: 0;
}

.placeholder-text {
    font-size: 1.5rem;
    color: #666;
    text-align: center;
    line-height: 1.4;
}

/* Thumbnail navigation */
.thumbnail-nav {
    display: flex;
    align-items: center;
    padding: 12px 0.5rem;
    background: white;
    gap: 4px;
}

.thumb-arrow {
    width: 32px;
    height: 56px;
    border: none;
    background: transparent;
    color: #ccc;
    font-size: 24px;
    cursor: default;
    flex-shrink: 0;
    display: none;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}

.thumbnail-nav.has-overflow .thumb-arrow {
    display: flex;
}

.thumb-arrow:not(:disabled) {
    color: #666;
    cursor: pointer;
}

.thumb-arrow:not(:disabled):hover {
    color: #333;
}

.thumbnail-viewport {
    flex: 1;
    overflow: hidden;
}

.thumbnail-strip {
    display: flex;
    gap: 8px;
    transition: transform 0.2s ease-out;
}

.thumbnail-strip::-webkit-scrollbar {
    display: none;
}

.thumbnail {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    border: 3px solid transparent;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.thumb-fabric {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
}

.thumb-bg,
.thumb-fg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.thumb-bg {
    opacity: 0.4;
}

.thumbnail.active {
    border-color: #2563eb;
}

/* Thumbnail with watercolor processing */
.thumbnail[data-watercolor-pending]::after {
    content: '⏳';
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 12px;
    background: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumbnail.processing::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.7);
    border-radius: 3px;
}

.thumbnail.processing::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #ccc;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 1;
}

/* Upload row when 6+ designs or empty state */
.thumbnail-add-row {
    padding: 12px 1rem;
    background: white;
}

/* Remove top padding when following thumbnail nav */
.thumbnail-nav + .thumbnail-add-row {
    padding-top: 0;
}

.thumbnail-add-row .upload-btn {
    width: 100%;
}

/* Upload button (empty state - full width) */
.upload-btn {
    flex: 1 1 auto;
    min-width: 0;
    padding: 14px 20px;
    background: #dbeafe;
    color: #1e40af;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.upload-btn:hover {
    background: #bfdbfe;
}

.upload-btn.disabled {
    background: #e5e7eb;
    color: #999;
    cursor: not-allowed;
}

.upload-btn.disabled:hover {
    background: #e5e7eb;
}

/* Upload limited state */
.upload-limited {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 8px;
}

.upload-limit-message {
    text-align: center;
    font-size: 0.85rem;
    color: #666;
}

.upload-limit-message a {
    color: #2563eb;
    text-decoration: none;
}

.upload-limit-message a:hover {
    text-decoration: underline;
}

/* Add another button (with image) */
.add-thumbnail-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #dbeafe;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #1e40af;
    font-weight: 600;
    transition: all 0.15s;
    min-width: 0;
}

.add-thumbnail-btn:hover:not(.disabled) {
    background: #bfdbfe;
}

.add-thumbnail-btn.disabled {
    background: #e5e7eb;
    color: #999;
    cursor: not-allowed;
}

.add-thumbnail-plus {
    font-size: 20px;
    font-weight: 500;
    line-height: 1;
}

.add-thumbnail-text {
}

.add-thumbnail-text a {
    color: #2563eb;
    text-decoration: none;
}

.add-thumbnail-text a:hover {
    text-decoration: underline;
}

/* Sticky cart bar */
.cart-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 12px 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    z-index: 100;
}

.size-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.size-selector label {
    font-size: 0.875rem;
    color: #666;
}

.size-selector select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    background: white;
}

.cart-price {
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
}

.cart-button {
    background: #f7ca00;
    color: #111;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.cart-button:hover {
    background: #e5b800;
}

.cart-button:disabled {
    background: #e5e7eb;
    color: #999;
    cursor: not-allowed;
}

/* Cart link in header */
.cart-link {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.cart-count {
    background: #dc2626;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    margin-left: 0.25rem;
    display: none;
}

/* Hidden file input */
.hidden-input {
    display: none;
}

/* Desktop enhancements */
@media (min-width: 600px) {
    body {
        max-width: 600px;
        margin: 0 auto;
    }
    
    h1 {
        padding: 1.5rem 1.5rem 0;
    }
    
    .preview-wrapper {
        padding: 24px;
        margin: 0 1rem;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }
    
    .preview-stack {
        border-radius: 4px;
    }
    
    .switches {
        padding: 0 1.5rem;
    }
    
    .switch-option {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    .fabric-section {
        padding: 0 1.5rem;
    }
    
    .fabric-swatch {
        width: 32px;
        height: 32px;
    }
    
    .recommended-colors .fabric-swatch {
        width: 44px;
        height: 44px;
    }
    
    .fabric-swatch:hover:not(.placeholder-swatch) {
        transform: scale(1.1);
        z-index: 1;
    }
    
    .cart-bar {
        left: 50%;
        transform: translateX(-50%);
        max-width: 600px;
        border-radius: 8px 8px 0 0;
        border-left: 1px solid #e5e7eb;
        border-right: 1px solid #e5e7eb;
    }
}
