/* ═══════════════════════════════════════
   AliExpress Affiliate Manager – Design System
   Soft Professional UI
═══════════════════════════════════════ */

/* ─── Design Tokens ─── */
:root {
    --sidebar-width: 240px;

    /* Backgrounds */
    --bg-page:    #F1F5F9;
    --bg-surface: #FFFFFF;
    --bg-subtle:  #F8FAFC;

    /* Borders */
    --border:       #E2E8F0;
    --border-light: #F1F5F9;

    /* Sidebar */
    --sidebar-bg:     #1E3A5F;
    --sidebar-hover:  rgba(255,255,255,0.08);
    --sidebar-active: rgba(255,255,255,0.16);
    --sidebar-text:   rgba(255,255,255,0.82);

    /* Brand / Primary */
    --primary:       #3B82F6;
    --primary-hover: #2563EB;
    --primary-light: #EFF6FF;
    --primary-text:  #1D4ED8;

    /* Status colours */
    --success:       #10B981;
    --success-light: #ECFDF5;
    --warning:       #F59E0B;
    --warning-light: #FFFBEB;
    --danger:        #EF4444;
    --danger-light:  #FEF2F2;
    --info:          #06B6D4;
    --info-light:    #ECFEFF;

    /* Price / affiliate highlight */
    --orange:       #F97316;
    --orange-light: #FFF7ED;

    /* Text */
    --text-primary:   #1E293B;
    --text-secondary: #64748B;
    --text-tertiary:  #94A3B8;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.07), 0 4px 6px rgba(0,0,0,0.05);

    /* Radii */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 12px;
    --r-xl: 16px;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-page);
    line-height: 1.5;
}

/* ═══════════════════════════════════════
   LAYOUT
═══════════════════════════════════════ */

/* ─── Sidebar ─── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: white;
    z-index: 1000;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: white;
    text-decoration: none;
}

.sidebar-brand img {
    width: 26px;
    height: 26px;
    border-radius: 6px;
}

.sidebar-nav {
    padding: 0.75rem 0;
    flex: 1;
}

.sidebar-section-label {
    padding: 0.75rem 1.25rem 0.25rem;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.38);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-link i {
    font-size: 1rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: white;
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: white;
    border-left-color: var(--primary);
}

/* ─── Page Wrapper ─── */
.page-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── Topbar ─── */
.topbar {
    height: 54px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-xs);
}

.topbar-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

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

/* ─── Page Content ─── */
.page-content {
    flex: 1;
    padding: 1.5rem;
}

/* ═══════════════════════════════════════
   CARDS
═══════════════════════════════════════ */

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

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.card-header .card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.card-body {
    padding: 1.25rem;
}

/* ─── Stat Card ─── */
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.stat-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.amber  { background: var(--warning-light); color: var(--warning); }
.stat-icon.cyan   { background: var(--info-light); color: var(--info); }
.stat-icon.orange { background: var(--orange-light); color: var(--orange); }

.stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.15;
}

.stat-meta {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 0.15rem;
}

/* ═══════════════════════════════════════
   TABLES
═══════════════════════════════════════ */

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

.data-table thead th {
    padding: 0.625rem 1rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
    white-space: nowrap;
    text-align: left;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background 0.1s;
}

.data-table tbody tr:hover { background: var(--bg-subtle); }
.data-table tbody tr:last-child { border-bottom: none; }

.data-table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    font-size: 0.875rem;
    color: var(--text-primary);
}

/* Products table thumbnail */
.table-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
}

/* ═══════════════════════════════════════
   BADGES
═══════════════════════════════════════ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 0.2em 0.55em;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 20px;
    white-space: nowrap;
    line-height: 1.4;
}

.badge-success   { background: var(--success-light); color: var(--success); }
.badge-warning   { background: var(--warning-light); color: var(--warning); }
.badge-danger    { background: var(--danger-light);  color: var(--danger); }
.badge-info      { background: var(--info-light);    color: var(--info); }
.badge-primary   { background: var(--primary-light); color: var(--primary-text); }
.badge-secondary { background: #F1F5F9; color: var(--text-secondary); }
.badge-orange    { background: var(--orange-light);  color: var(--orange); }
.badge-dark      { background: #1E293B; color: white; }

/* Status-specific */
.badge-posted  { background: var(--success-light); color: var(--success); }
.badge-queued  { background: var(--warning-light); color: var(--warning); }
.badge-default { background: #F1F5F9; color: var(--text-secondary); }

/* ═══════════════════════════════════════
   BUTTONS
═══════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }

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

.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-success:hover { filter: brightness(0.92); color: white; }

.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(0.92); color: white; }

.btn-outline-primary {
    background: transparent;
    color: var(--primary);
    border-color: var(--border);
}
.btn-outline-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-text);
}

.btn-outline-secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-outline-secondary:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

.btn-outline-success {
    background: transparent;
    color: var(--success);
    border-color: var(--border);
}
.btn-outline-success:hover { background: var(--success-light); border-color: var(--success); }

.btn-outline-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--border);
}
.btn-outline-danger:hover { background: var(--danger-light); border-color: var(--danger); }

.btn-sm   { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-xs   { padding: 0.22rem 0.5rem;  font-size: 0.75rem; }
.btn-lg   { padding: 0.65rem 1.25rem; font-size: 0.95rem; }
.btn-icon { padding: 0.375rem; }

/* ═══════════════════════════════════════
   FORMS
═══════════════════════════════════════ */

.form-control,
.form-select {
    display: block;
    width: 100%;
    padding: 0.45rem 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-primary);
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748B' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    padding-right: 2rem;
}

.form-control-sm,
.form-select-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.form-select-sm {
    padding-right: 1.75rem;
    background-position: right 0.5rem center;
}

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

.form-check-input[type="checkbox"].form-check-input,
.form-check-input[type="radio"] {
    cursor: pointer;
}

/* Switch accent color */
.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* ═══════════════════════════════════════
   FILTERS PANEL
═══════════════════════════════════════ */

.filters-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 0.875rem 1.25rem;
    box-shadow: var(--shadow-xs);
    margin-bottom: 1.25rem;
}

/* ═══════════════════════════════════════
   PAGINATION
═══════════════════════════════════════ */

.pagination {
    display: flex;
    gap: 0.2rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
    background: white;
}

.page-link:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-text);
}

.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.page-item.disabled .page-link {
    opacity: 0.4;
    pointer-events: none;
}

/* ═══════════════════════════════════════
   PRODUCT CARD (Grid view)
═══════════════════════════════════════ */

.product-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.15s;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.product-card-img-wrap {
    position: relative;
    background: var(--bg-subtle);
    overflow: hidden;
}

.product-card-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform 0.3s;
    display: block;
}

.product-card:hover .product-card-img { transform: scale(1.04); }

.product-card-img-placeholder {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    font-size: 2rem;
}

.product-card-status-badge {
    position: absolute;
    top: 8px;
    right: 8px;
}

.product-card-body {
    padding: 0.875rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-card-title {
    font-size: 0.82rem;
    line-height: 1.4;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.4em;
}

.product-card-title a { color: var(--text-primary); text-decoration: none; }
.product-card-title a:hover { color: var(--primary); }

.product-price     { font-size: 0.95rem; font-weight: 700; color: var(--orange); }
.product-price-was { font-size: 0.75rem; color: var(--text-tertiary); text-decoration: line-through; }

.discount-pill {
    display: inline-block;
    background: var(--danger-light);
    color: var(--danger);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15em 0.4em;
    border-radius: 4px;
}

.product-card-actions {
    margin-top: auto;
    padding-top: 0.625rem;
    display: flex;
    gap: 0.3rem;
}

.card-action-btn {
    flex: 1;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0.35rem;
    border-radius: var(--r-sm);
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-family: inherit;
}

.card-action-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-text);
}

.card-action-btn.tg:hover {
    background: #E7F3FB;
    border-color: #0088cc;
    color: #0088cc;
}

.card-action-btn.copied {
    background: var(--success-light);
    border-color: var(--success);
    color: var(--success);
}

/* ═══════════════════════════════════════
   VIEW TOGGLE
═══════════════════════════════════════ */

.view-toggle { display: inline-flex; }

.view-toggle-btn {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.35rem 0.65rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
}

.view-toggle-btn:first-child {
    border-radius: var(--r-sm) 0 0 var(--r-sm);
    border-right: none;
}

.view-toggle-btn:last-child {
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

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

.view-toggle-btn:hover:not(.active) {
    background: var(--primary-light);
    color: var(--primary);
}

/* ═══════════════════════════════════════
   TOAST NOTIFICATIONS
═══════════════════════════════════════ */

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast-msg {
    background: var(--text-primary);
    color: white;
    padding: 0.625rem 1rem;
    border-radius: var(--r-md);
    font-size: 0.82rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.22s ease;
    max-width: 300px;
    pointer-events: auto;
}

.toast-msg.success { background: var(--success); }
.toast-msg.error   { background: var(--danger); }
.toast-msg.info    { background: var(--info); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ═══════════════════════════════════════
   LOADING OVERLAY
═══════════════════════════════════════ */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

/* ═══════════════════════════════════════
   MODAL
═══════════════════════════════════════ */

.modal-content {
    border: none !important;
    border-radius: var(--r-lg) !important;
    box-shadow: 0 25px 50px rgba(0,0,0,0.15) !important;
}

.modal-header {
    border-bottom: 1px solid var(--border) !important;
    background: var(--bg-subtle) !important;
    border-radius: var(--r-lg) var(--r-lg) 0 0 !important;
    padding: 1rem 1.25rem !important;
}

.modal-footer {
    border-top: 1px solid var(--border) !important;
    padding: 0.875rem 1.25rem !important;
}

/* Script output */
.script-output {
    background: #0F172A;
    border-radius: var(--r-sm);
    padding: 1rem;
    max-height: 380px;
    overflow-y: auto;
}

.script-output pre { margin: 0; white-space: pre-wrap; word-break: break-all; }
.script-output code { font-family: 'Cascadia Code','Consolas','Monaco',monospace; font-size: 0.78rem; color: #94A3B8; }
.script-output code.text-success { color: #34D399 !important; }
.script-output code.text-danger  { color: #F87171 !important; }

/* ═══════════════════════════════════════
   PRODUCT DETAIL
═══════════════════════════════════════ */

.product-detail-image {
    width: 100%;
    max-height: 420px;
    object-fit: contain;
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    background: var(--bg-subtle);
}

.detail-info-row {
    display: flex;
    align-items: flex-start;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.875rem;
    gap: 1rem;
}

.detail-info-row:last-child { border-bottom: none; }

.detail-info-label {
    width: 140px;
    flex-shrink: 0;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.8rem;
}

.detail-info-value { color: var(--text-primary); flex: 1; }

/* ═══════════════════════════════════════
   CONFIG / SCHEDULER
═══════════════════════════════════════ */

.script-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    height: 100%;
    transition: box-shadow 0.2s;
}

.script-card:hover { box-shadow: var(--shadow-md); }

.script-card-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-bottom: 0.875rem;
}

.script-card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.25rem;
}

.script-card-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.875rem;
    line-height: 1.4;
}

.scheduler-meta {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.scheduler-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border-light);
}

.scheduler-meta-row:last-child { border-bottom: none; }

.scheduler-meta-label { color: var(--text-tertiary); }
.scheduler-meta-value { font-weight: 500; color: var(--text-primary); font-size: 0.75rem; }

/* ═══════════════════════════════════════
   PAGE HEADERS
═══════════════════════════════════════ */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.page-header-info {}

.page-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.125rem;
}

.page-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
}

.section-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 0.875rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* ═══════════════════════════════════════
   SEARCH PAGE
═══════════════════════════════════════ */

.search-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
    overflow: hidden;
}

.search-section-header {
    padding: 0.875rem 1.25rem;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.search-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-section-body {
    padding: 1.25rem;
}

/* ═══════════════════════════════════════
   UTILITIES
═══════════════════════════════════════ */

.text-orange  { color: var(--orange) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary-color { color: var(--primary) !important; }

.fw-semibold { font-weight: 600; }

/* Spinner accent */
.spinner-border { color: var(--primary); }

/* Scrollbar polish */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* Override Bootstrap table header to use our style */
.table-card thead th {
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 2px solid var(--border);
    padding: 0.625rem 1rem;
}

.table-card tbody tr:hover { background: var(--bg-subtle); }
.table-card td { padding: 0.75rem 1rem; vertical-align: middle; font-size: 0.875rem; border-bottom: 1px solid var(--border-light); }
.table-card tbody tr:last-child td { border-bottom: none; }

/* Stop script button hidden by default */
.stop-script { display: none; }
.run-script  { display: block; }

/* ═══════════════════════════════════════
   MOBILE / RESPONSIVE
═══════════════════════════════════════ */

/* Hamburger button — hidden on desktop */
.hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: white;
    cursor: pointer;
    color: var(--text-secondary);
    flex-shrink: 0;
    font-size: 1.1rem;
    transition: all 0.15s;
}
.hamburger:hover { background: var(--bg-subtle); color: var(--text-primary); }

/* Sidebar overlay (mobile click-to-close) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.sidebar-overlay.show { opacity: 1; pointer-events: auto; }

/* ─── Tablet (≤ 1024px) ─── */
@media (max-width: 1024px) {
    :root { --sidebar-width: 210px; }
    .page-content { padding: 1.25rem; }
}

/* ─── Mobile (≤ 767px) ─── */
@media (max-width: 767px) {

    /* Show hamburger */
    .hamburger { display: flex; }
    .sidebar-overlay { display: block; }

    /* Sidebar slides off-screen; .open brings it back */
    .sidebar {
        width: 240px;
        transform: translateX(-240px);
        transition: transform 0.25s ease;
        z-index: 1000;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.28);
    }

    /* Content takes full width */
    .page-wrapper { margin-left: 0 !important; }

    /* Topbar */
    .topbar { padding: 0 0.875rem; height: 50px; gap: 0.5rem; }
    .topbar-title { font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar-actions .form-select-sm { font-size: 0.75rem; }

    /* Page content */
    .page-content { padding: 0.875rem; }

    /* Stat cards — 2-up */
    .stat-card { padding: 0.875rem; gap: 0.6rem; }
    .stat-icon { width: 36px; height: 36px; font-size: 0.95rem; }
    .stat-value { font-size: 1.2rem; }

    /* Filters — stack vertically */
    .filters-panel .row { flex-direction: column !important; gap: 0.5rem !important; }
    .filters-panel .col-auto,
    .filters-panel .col-auto.ms-auto { width: 100% !important; flex: 0 0 100%; margin-left: 0 !important; }
    .filters-panel .form-control,
    .filters-panel .form-select { width: 100%; }

    /* Page header — stack */
    .page-header { flex-direction: column; gap: 0.625rem; align-items: flex-start; }

    /* Shorter product images */
    .product-card-img,
    .product-card-img-placeholder { height: 150px; }

    /* Table horizontal scroll */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-thumb { width: 60px; height: 60px; }

    /* Config / script cards full-width on mobile */
    .col-md-4, .col-md-6, .col-lg-4 { flex: 0 0 100% !important; max-width: 100% !important; }

    /* Search form fields stack */
    .search-section-body .row { flex-direction: column !important; }
    .search-section-body [class*="col-md"],
    .search-section-body [class*="col-"] { flex: 0 0 100% !important; max-width: 100% !important; }

    /* Product detail */
    .product-detail-image { max-height: 250px; }
    .col-md-5, .col-md-7 { flex: 0 0 100% !important; max-width: 100% !important; }
    .detail-info-label { width: 100px; font-size: 0.75rem; }

    /* Pagination compact */
    .page-link { min-width: 28px; height: 28px; font-size: 0.75rem; padding: 0 0.4rem; }

    /* Toast full-width */
    .toast-container { left: 0.75rem; right: 0.75rem; bottom: 0.75rem; }
    .toast-msg { max-width: 100%; }

    /* Modal */
    .modal-dialog { margin: 0.5rem; }
}

/* ─── Small phones (≤ 420px) ─── */
@media (max-width: 420px) {
    /* Single-column product grid */
    .row-cols-2 > * { flex: 0 0 100% !important; max-width: 100% !important; }
}
