/* ============================================
   Linnworks Product Creator v2.0
   We Can Source It - Multipack Generator
   ============================================ */

:root {
    --primary: #0066ff;
    --primary-dark: #0052cc;
    --primary-light: #e6f0ff;
    --success: #00875a;
    --success-light: #e3fcef;
    --warning: #ff8b00;
    --danger: #de350b;
    --danger-light: #ffebe6;
    
    --bg: #f4f5f7;
    --bg-card: #ffffff;
    --bg-input: #fafbfc;
    --border: #dfe1e6;
    --border-focus: #4c9aff;
    --text: #172b4d;
    --text-muted: #6b778c;
    --text-light: #97a0af;
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    --shadow-sm: 0 1px 2px rgba(9, 30, 66, 0.08);
    --shadow-md: 0 4px 8px rgba(9, 30, 66, 0.1);
    --shadow-lg: 0 8px 16px rgba(9, 30, 66, 0.15);
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ============================================
   Header
   ============================================ */

.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.logo-title {
    font-weight: 700;
    font-size: 1.1rem;
    display: block;
}

.logo-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.15s;
}

.btn-icon:hover {
    background: var(--border);
    color: var(--text);
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-light);
    animation: pulse 2s infinite;
}

.connection-status.connected .status-dot {
    background: var(--success);
    animation: none;
}

.connection-status.error .status-dot {
    background: var(--danger);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ============================================
   Main Layout
   ============================================ */

.main-content {
    padding: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
}

.layout {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .layout {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Panels
   ============================================ */

.panel {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.panel-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
}

.panel-header p {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.panel-setup {
    display: flex;
    flex-direction: column;
}

/* ============================================
   Forms
   ============================================ */

.form-section {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section h3 {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.form-section.collapsible h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.form-section.collapsible .section-content {
    display: none;
}

.form-section.collapsible.open .section-content {
    display: block;
}

.form-section.collapsible .chevron {
    transition: transform 0.2s;
}

.form-section.collapsible.open .chevron {
    transform: rotate(180deg);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: var(--text);
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--bg-input);
    transition: all 0.15s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--border-focus);
    background: var(--bg-card);
    box-shadow: 0 0 0 2px var(--primary-light);
}

input::placeholder {
    color: var(--text-light);
}

.help-text {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

/* Radio Groups */
.radio-group {
    display: flex;
    gap: 0.75rem;
}

.radio-option {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.radio-option:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-light);
}

.radio-option input {
    margin: 0;
}

.radio-option code {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.checkbox-label input {
    width: 16px;
    height: 16px;
}

/* ============================================
   Quantity Grid
   ============================================ */

.quantity-presets {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.preset-btn {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.preset-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.preset-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.quantity-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.qty-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all 0.15s;
}

.qty-tag:hover {
    border-color: var(--text-light);
}

.qty-tag.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.qty-tag .remove {
    font-size: 1rem;
    line-height: 1;
    opacity: 0.6;
}

.qty-tag .remove:hover {
    opacity: 1;
}

.custom-quantity {
    display: flex;
    gap: 0.5rem;
}

.custom-quantity input {
    flex: 1;
}

.btn-add {
    padding: 0.625rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-add:hover {
    background: var(--border);
}

/* ============================================
   Buttons
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #006644;
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-generate {
    width: calc(100% - 3rem);
    margin: 1.5rem;
}

/* ============================================
   Image Upload
   ============================================ */

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
}

.upload-preview {
    position: relative;
    display: inline-block;
}

.upload-preview img {
    max-width: 150px;
    max-height: 150px;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

.remove-image {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: var(--danger);
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   Preview Panel
   ============================================ */

.panel-preview {
    min-height: 500px;
    display: flex;
    flex-direction: column;
}

.preview-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 3rem;
    color: var(--text-light);
    text-align: center;
}

.preview-table-wrapper {
    flex: 1;
    overflow: auto;
    padding: 0 1.5rem;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
}

.preview-table th,
.preview-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.preview-table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    background: var(--bg-card);
}

.preview-table td {
    font-size: 0.8125rem;
}

.preview-table code {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: var(--bg);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.preview-table .title-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-table .price-cell {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

.preview-table .btn-remove {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: var(--text-light);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-table .btn-remove:hover {
    background: var(--danger-light);
    color: var(--danger);
}

.preview-actions {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
}

.action-options {
    display: flex;
    gap: 1rem;
}

/* ============================================
   Modal
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(9, 30, 66, 0.54);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--bg);
    color: var(--text);
}

.modal-body {
    padding: 1.5rem;
    max-height: 400px;
    overflow-y: auto;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Result Items */
.result-success {
    text-align: center;
    padding: 1rem 0;
}

.result-success svg {
    width: 56px;
    height: 56px;
    color: var(--success);
}

.result-list {
    margin-top: 1rem;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.8125rem;
}

.result-item:last-child {
    border-bottom: none;
}

.result-item .icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.result-item.success .icon {
    background: var(--success-light);
    color: var(--success);
}

.result-item.error .icon {
    background: var(--danger-light);
    color: var(--danger);
}

.result-item code {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: var(--bg);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
}

.result-item .error-msg {
    color: var(--danger);
    font-size: 0.75rem;
    margin-left: auto;
}
