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

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-body, 'Inter', system-ui, sans-serif);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    transition: background .25s, color .25s;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading, 'Inter', system-ui, sans-serif);
}

/* ── Layout ──────────────────────────────────────────────────────── */
.app-layout { display: flex; flex-direction: column; min-height: 100vh; }

.app-nav {
    height: var(--nav-height);
    background: var(--bg-nav);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.app-nav .brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary);
    text-decoration: none;
    letter-spacing: -.02em;
}

.app-nav .nav-links { display: none; margin-left: auto; }

.app-nav .nav-links a {
    padding: .4rem .85rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.app-nav .nav-links a:hover,
.app-nav .nav-links a.active {
    background: var(--primary-soft);
    color: var(--primary);
}

.app-body { display: flex; flex: 1; }

.app-sidebar {
    width: 240px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1rem;
    display: none;
    flex-direction: column;
    gap: .25rem;
    flex-shrink: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .85rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.sidebar-link:hover, .sidebar-link.active {
    background: var(--primary-soft);
    color: var(--primary);
}

.sidebar-section {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    padding: 1rem .85rem .35rem;
}

.app-main { flex: 1; padding: 1rem; overflow-x: hidden; }

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-direction: column;
}

.card-title { font-weight: 600; font-size: 1rem; }
.card-body  { padding: 1.5rem; }
.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg);
    border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: opacity .15s, transform .1s, box-shadow .15s;
    white-space: nowrap;
}

.btn:active { transform: scale(.98); }

.btn-primary   { background: var(--primary); color: var(--text-inv); }
.btn-primary:hover { opacity: .88; }

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

.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .88; }

.btn-ghost   { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--primary-soft); color: var(--primary); }

.btn-sm   { padding: .35rem .75rem; font-size: .82rem; }
.btn-lg   { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }

.form-label {
    display: block;
    font-size: .85rem;
    font-weight: 500;
    margin-bottom: .4rem;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: .6rem .9rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: .9rem;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

.form-hint  { font-size: .78rem; color: var(--text-muted); margin-top: .3rem; }
.form-error { font-size: .78rem; color: var(--danger);     margin-top: .3rem; }

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert {
    padding: .85rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    margin-bottom: 1rem;
}

.alert-success { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); border: 1px solid color-mix(in srgb, var(--success) 30%, transparent); }
.alert-danger  { background: color-mix(in srgb, var(--danger)  15%, transparent); color: var(--danger);  border: 1px solid color-mix(in srgb, var(--danger)  30%, transparent); }
.alert-warning { background: color-mix(in srgb, var(--warning) 15%, transparent); color: var(--warning); border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent); }
.alert-info    { background: var(--primary-soft); color: var(--primary); border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); }

/* ── Tables ──────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
    text-align: left;
    padding: .75rem 1rem;
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    white-space: nowrap;
}
.table td {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--primary-soft); }

/* ── Badges ──────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-success { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.badge-danger  { background: color-mix(in srgb, var(--danger)  18%, transparent); color: var(--danger);  }
.badge-warning { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-muted   { background: var(--border); color: var(--text-muted); }

/* ── Auth pages ──────────────────────────────────────────────────── */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: var(--bg);
}

.auth-box {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.auth-header {
    padding: 1.5rem 1.25rem 1rem;
    text-align: center;
}

.auth-header .brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -.02em;
    display: block;
    margin-bottom: .5rem;
}

.auth-header h1 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: .25rem;
}

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

.auth-body { padding: 1.25rem 1.25rem 1.5rem; }

.auth-divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 1.25rem 0;
    color: var(--text-muted);
    font-size: .82rem;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.sso-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    padding: .6rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s;
    margin-bottom: .6rem;
}
.sso-btn:hover { background: var(--bg); border-color: var(--primary); }
.sso-btn img   { width: 18px; height: 18px; }

.auth-footer {
    padding: .85rem 1.25rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: .85rem;
    color: var(--text-muted);
    background: var(--bg);
}
.auth-footer a { color: var(--primary); text-decoration: none; font-weight: 500; }

/* ── Theme switcher ──────────────────────────────────────────────── */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .6rem;
}

.theme-swatch {
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .5rem;
    cursor: pointer;
    text-align: center;
    transition: border-color .15s, transform .1s;
    background: var(--bg-card);
}

.theme-swatch:hover { border-color: var(--primary); transform: translateY(-2px); }
.theme-swatch.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.theme-swatch .swatch-preview {
    width: 100%;
    height: 32px;
    border-radius: 4px;
    margin-bottom: .35rem;
}

.theme-swatch span { font-size: .75rem; font-weight: 500; color: var(--text-muted); }

/* ── Nav: hamburger (mobile default) ────────────────────────────── */
.hamburger {
    display: flex;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: .4rem;
    background: none;
    border: none;
    margin-left: auto;
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform .2s, opacity .2s;
}

.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Mobile nav drawer ───────────────────────────────────────────── */
.nav-mobile-menu {
    display: flex;
    flex-direction: column;
    background: var(--bg-nav);
    border-bottom: 1px solid var(--border);
    padding: .75rem 1.5rem;
    gap: .25rem;
}

.nav-mobile-menu a {
    padding: .6rem .85rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: .95rem;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.nav-mobile-menu a:hover { background: var(--primary-soft); color: var(--primary); }
.nav-mobile-menu.hidden  { display: none; }

/* ── Designer breakpoints ────────────────────────────────────────── */
.designer-desktop { display: none; }
.designer-mobile  { display: block; }
.designer-tablet  { display: none; }

/* ── Mobile wizard ───────────────────────────────────────────────── */
.wizard-steps {
    display: flex;
    overflow-x: auto;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
    scrollbar-width: none;
}
.wizard-steps::-webkit-scrollbar { display: none; }

.wizard-step {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .75rem 1rem;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    user-select: none;
}

.wizard-step.active { color: var(--primary); border-bottom-color: var(--primary); }
.wizard-step.done   { color: var(--success); }

.wizard-step .step-num {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
}

.wizard-step.active .step-num { background: var(--primary); color: #fff; }
.wizard-step.done   .step-num { background: var(--success); color: #fff; }

.wizard-panel        { display: none; }
.wizard-panel.active { display: block; }

/* Mobile upload zone */
.mobile-upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}

.mobile-upload-zone:hover,
.mobile-upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.mobile-upload-zone .upload-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.mobile-upload-zone p { color: var(--text-muted); font-size: .9rem; }

/* Mobile image list */
.mobile-image-list { display: flex; flex-direction: column; gap: .75rem; }

.mobile-image-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .75rem;
}

.mobile-image-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.mobile-image-item .item-info { flex: 1; min-width: 0; }
.mobile-image-item .item-name {
    font-size: .85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-image-item .qty-control {
    display: flex;
    align-items: center;
    gap: .35rem;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.qty-btn:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.qty-val { font-weight: 600; font-size: .9rem; min-width: 20px; text-align: center; }

/* Product card grid */
.product-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: .75rem;
}

.product-card {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
    background: var(--bg-card);
}

.product-card:hover  { border-color: var(--primary); }
.product-card.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.product-card .product-name  { font-weight: 600; margin-bottom: .25rem; }
.product-card .product-size  { font-size: .82rem; color: var(--text-muted); }
.product-card .product-price { font-size: .9rem; color: var(--primary); font-weight: 600; margin-top: .35rem; }

/* ── Utilities ───────────────────────────────────────────────────── */
.d-flex          { display: flex; }
.align-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .25rem; } .gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; } .gap-4 { gap: 1rem;  }
.mt-1 { margin-top: .25rem; }  .mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; } .mt-4 { margin-top: 1rem;  }
.mb-1 { margin-bottom: .25rem; }  .mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: .75rem; } .mb-4 { margin-bottom: 1rem;  }
.text-muted    { color: var(--text-muted); }
.text-primary  { color: var(--primary); }
.text-danger   { color: var(--danger); }
.text-success  { color: var(--success); }
.text-sm       { font-size: .85rem; }
.text-xs       { font-size: .75rem; }
.font-bold     { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-center   { text-align: center; }
.w-full        { width: 100%; }

/* ── Tablet (768px+) ─────────────────────────────────────────────── */
@media (min-width: 768px) {
    .app-main    { padding: 1.5rem; }
    .auth-box    { border-radius: var(--radius); }
    .auth-body   { padding: 1.5rem 2rem 2rem; }
    .auth-header { padding: 2rem 2rem 1.25rem; }
    .auth-footer { padding: 1rem 2rem; }
    .theme-grid  { grid-template-columns: repeat(4, 1fr); }
    .product-grid { grid-template-columns: repeat(2, 1fr); }
    .card-header { flex-direction: row; align-items: center; }
    .designer-tablet { display: block; }
}

/* ── Desktop (1024px+) ───────────────────────────────────────────── */
@media (min-width: 1024px) {
    .app-main    { padding: 2rem; }
    .app-nav .nav-links { display: flex; }
    .hamburger   { display: none; }
    .app-sidebar { display: flex; }
    .nav-mobile-menu { display: none !important; }

    .designer-desktop { display: block; }
    .designer-mobile  { display: none; }
    .designer-tablet  { display: none; }

    .product-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── Wide (1280px+) ──────────────────────────────────────────────── */
@media (min-width: 1280px) {
    .app-main { padding: 2rem 2.5rem; }
}
