/* ===================================================================
   Image Pack Generator - Main Stylesheet
   =================================================================== */

/* ── Reset & Base ────────────────────────────────────────────────── */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-primary-light: #dbeafe;
    --color-secondary: #7c3aed;
    --color-success: #059669;
    --color-success-light: #d1fae5;
    --color-warning: #d97706;
    --color-warning-light: #fef3c7;
    --color-danger: #dc2626;
    --color-danger-light: #fee2e2;
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --color-border-dark: #cbd5e1;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Fira Code', 'Cascadia Code', monospace;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-dark); }

/* ── Layout ──────────────────────────────────────────────────────── */

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

.app-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon { font-size: 28px; }

.logo h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-primary);
}

.main-nav { display: flex; gap: 4px; }

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.nav-link.active {
    background: var(--color-primary);
    color: white;
}

.app-main {
    min-height: calc(100vh - 140px);
    padding: 32px 0;
}

.app-footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 20px 0;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

/* ── Cards ───────────────────────────────────────────────────────── */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
}

/* ── Stat Cards ──────────────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* ── Buttons ─────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.4;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover { background: var(--color-primary-dark); }

.btn-secondary {
    background: var(--color-border);
    color: var(--color-text);
}

.btn-secondary:hover { background: var(--color-border-dark); }

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

.btn-block { width: 100%; justify-content: center; }

/* ── Forms ────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--color-text);
    margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    background: var(--color-surface);
    transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-textarea { resize: vertical; min-height: 80px; }

/* ── Tables ──────────────────────────────────────────────────────── */

.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead th {
    background: var(--color-bg);
    font-weight: 600;
    text-align: left;
    padding: 12px 16px;
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
}

tbody tr:hover { background: var(--color-primary-light); }

/* ── Badges ──────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background: var(--color-success-light); color: var(--color-success); }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge-danger  { background: var(--color-danger-light);  color: var(--color-danger); }
.badge-info    { background: var(--color-primary-light);  color: var(--color-primary); }

/* ── Product Grid ────────────────────────────────────────────────── */

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.product-card { cursor: pointer; }

.product-card .product-images-preview {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.img-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

/* ── Image Gallery ───────────────────────────────────────────────── */

.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.image-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.image-card .img-placeholder {
    width: 100%;
    height: 160px;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    border-bottom: 1px solid var(--color-border);
}

.image-card .img-meta {
    padding: 12px;
    font-size: 0.8rem;
}

.image-card .img-meta .filename {
    font-weight: 600;
    margin-bottom: 4px;
    word-break: break-all;
}

.image-card .img-meta .dim {
    color: var(--color-text-muted);
}

/* ── Wizard Steps ────────────────────────────────────────────────── */

.wizard-steps {
    display: flex;
    gap: 8px;
    margin-bottom: 32px;
}

.wizard-step {
    flex: 1;
    padding: 12px 16px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

.wizard-step.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.wizard-step.done {
    background: var(--color-success-light);
    color: var(--color-success);
    border-color: var(--color-success);
}

/* ── Channel Selector ────────────────────────────────────────────── */

.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.channel-option {
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.channel-option.selected {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.channel-option .channel-name { font-weight: 600; margin-bottom: 4px; }

.channel-option .channel-dims {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* ── Spec Preview ────────────────────────────────────────────────── */

.spec-list { display: flex; flex-direction: column; gap: 12px; }

.spec-item {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 14px;
    background: var(--color-surface);
}

.spec-item .spec-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.spec-item .spec-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.spec-tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--color-bg);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* ── Pack History ────────────────────────────────────────────────── */

.pack-list { display: flex; flex-direction: column; gap: 16px; }

.pack-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px;
}

.pack-card .pack-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.pack-card .pack-channels {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

/* ── Loading ─────────────────────────────────────────────────────── */

.loading {
    text-align: center;
    padding: 40px;
    color: var(--color-text-muted);
}

.spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty State ─────────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-text-muted);
}

.empty-state h3 { margin-bottom: 8px; color: var(--color-text); }

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .header-inner { flex-direction: column; height: auto; padding: 12px 16px; }
    .main-nav { flex-wrap: wrap; justify-content: center; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .wizard-steps { flex-direction: column; }
    .product-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .channel-grid { grid-template-columns: 1fr; }
}
