:root {
    /* Modern Color Palette - Slate & Indigo Theme */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;

    /* Neutrals - Slate Gray */
    --bg: #0f172a;
    --bg-secondary: #1e293b;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* Table Header */
    --header-bg: #1e293b;
    --header-text: #f8fafc;

    /* Accent Colors for Variants */
    --variant-default-bg: #f8fafc;
    --variant-default-border: #e2e8f0;
    --variant-selected-bg: #fef3c7;
    --variant-selected-border: #f59e0b;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, var(--bg) 0%, var(--bg-secondary) 100%);
    min-height: 100vh;
    color: var(--text);
}

.container {
    max-width: 1500px;
    margin: 0 auto;
    padding: 30px 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    opacity: 0.8;
    font-size: 1.1rem;
    color: var(--text-muted);
}

.control-panel {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

input[type="text"] {
    padding: 14px 18px;
    width: 450px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    outline: none;
    background: var(--card-bg);
    transition: border-color 0.3s, box-shadow 0.3s;
}

input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

button {
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

button#scrapeBtn {
    background: var(--primary);
    color: white;
}

button#scrapeBtn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

button#exportBtn {
    background: var(--success);
    color: white;
}

button#exportBtn:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* Clear Button */
button.clear-btn {
    background: var(--danger);
    color: white;
}

button.clear-btn:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

/* Retry Pending Button */
button.retry-btn {
    background: var(--warning);
    color: white;
    padding: 8px 16px;
    font-size: 13px;
    margin-left: 12px;
}

button.retry-btn:hover {
    background: #d97706;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

button:active:not(:disabled) {
    transform: scale(0.98);
}

.status-area {
    margin-bottom: 20px;
    text-align: center;
    color: white;
}

#statusText {
    color: var(--text-muted);
    font-size: 14px;
}

#progressBarContainer {
    width: 100%;
    max-width: 600px;
    height: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin: 10px auto;
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--success) 100%);
    transition: width 0.3s ease;
    border-radius: 4px;
}

/* Stats and Filter Bar */
.stats-filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px 24px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: 16px;
}

.stats {
    display: flex;
    gap: 24px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    background: var(--border-light);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.stat-value {
    font-weight: 700;
    font-size: 18px;
    color: var(--text);
}

.stat-in-stock {
    background: var(--success-light);
}

.stat-in-stock .stat-value {
    color: var(--success);
}

.stat-out-of-stock {
    background: var(--danger-light);
}

.stat-out-of-stock .stat-value {
    color: var(--danger);
}

/* Filter Dropdowns */
.filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.filter-select {
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.2s;
    min-width: 100px;
}

.filter-select-wide {
    min-width: 160px;
    max-width: 200px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

.filter-select:hover {
    border-color: var(--primary);
}

.table-container {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

th,
td {
    padding: 12px 10px;
    text-align: left;
    vertical-align: top;
}

/* Row borders - bottom only on tr, not td */
tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background-color 0.15s;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background-color: var(--primary-light);
}

/* Column Widths - 7 columns */
th:nth-child(1),
td:nth-child(1) {
    width: 40px;
}

/* Checkbox */
th:nth-child(2),
td:nth-child(2) {
    width: 65px;
}

/* Image */
th:nth-child(3),
td:nth-child(3) {
    width: 320px;
}

/* Product Name - WIDER */
th:nth-child(4),
td:nth-child(4) {
    width: 90px;
}

/* Vendor */
th:nth-child(5),
td:nth-child(5) {
    width: 115px;
}

/* Barcode */
th:nth-child(6),
td:nth-child(6) {
    width: 140px;
}

/* Category */
th:nth-child(7),
td:nth-child(7) {
    width: 140px;
}

/* Shopify */
th:nth-child(8),
td:nth-child(8) {
    width: 120px;
}

/* Variants - strict width */
th:nth-child(9),
td:nth-child(9) {
    width: 160px;
    max-width: 160px;
    overflow: hidden;
}

/* Actions */
th:nth-child(10),
td:nth-child(10) {
    width: 70px;
}

/* Modern Table Header */
th {
    background: var(--header-bg);
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--header-text);
    position: sticky;
    top: 0;
    border-bottom: 3px solid var(--primary);
    vertical-align: middle;
}

/* Product Image with Hover Zoom */
.product-img-container {
    position: relative;
    display: inline-block;
}

.product-img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: white;
    cursor: pointer;
    transition: transform 0.2s ease;
}

/* Hover zoom popup */
.product-img-container:hover .product-img-zoom {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.product-img-zoom {
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%) scale(0.8);
    width: 180px;
    height: 180px;
    object-fit: contain;
    background: white;
    border: 2px solid var(--primary);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
}

.out-of-stock-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    background: var(--danger);
    color: white;
    font-size: 6px;
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 3px;
    text-transform: uppercase;
}

.product-name-cell {
    overflow: hidden;
}

.product-link {
    text-decoration: none;
    color: var(--primary);
    font-weight: 500;
    transition: color 0.2s;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    line-height: 1.4;
}

.product-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.stock-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 20px;
    font-size: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-top: 4px;
}

.stock-in {
    background: var(--success-light);
    color: var(--success);
}

.stock-out {
    background: var(--danger-light);
    color: var(--danger);
}

/* Vendor and Barcode cells */
.vendor-cell {
    font-weight: 600;
    font-size: 11px;
    color: var(--primary);
}

.barcode-cell {
    font-family: 'Courier New', monospace;
    font-size: 10px;
    color: var(--text-secondary);
    word-break: break-all;
}

.category-cell {
    color: var(--text-secondary);
    font-size: 10px;
    line-height: 1.3;
}

/* Source Badge Styles */
.source-cell {
    text-align: center;
}

.source-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.source-toptantr {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
}

.source-seyidoglu {
    background: #fce7f3;
    color: #be185d;
    border: 1px solid #f9a8d4;
}

.source-bizimtoptan {
    background: #d1fae5;
    color: #047857;
    border: 1px solid #6ee7b7;
}

.source-unknown {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #cbd5e1;
}

/* Variant Cards - Smart layout based on count */
.variants-container {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    max-width: 180px;
    overflow: hidden;
}

.variant-card {
    background: var(--variant-default-bg);
    border: 1px solid var(--variant-default-border);
    border-radius: 4px;
    padding: 4px 5px;
    text-align: center;
    transition: all 0.2s;
    flex: 1 1 calc(50% - 2px);
    max-width: calc(50% - 2px);
    min-width: 45px;
}

/* Single variant - compact */
.variants-container:has(.variant-card:only-child) .variant-card {
    flex: 0 0 auto;
    max-width: 90px;
}

/* 3+ variants - 4 per row to keep things compact */
.variants-container:has(.variant-card:nth-child(3)) .variant-card {
    flex: 1 1 calc(25% - 3px);
    max-width: calc(25% - 3px);
    min-width: 40px;
    padding: 3px 4px;
}

.variant-card.selected {
    background: var(--variant-selected-bg);
    border-color: var(--variant-selected-border);
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.15);
}

.variant-name {
    font-weight: 700;
    font-size: 9px;
    color: var(--text);
    margin-bottom: 1px;
    text-transform: capitalize;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.variant-qty {
    font-size: 7px;
    color: var(--text-muted);
    margin-bottom: 1px;
}

.variant-price {
    font-weight: 700;
    font-size: 10px;
    color: var(--text);
}

.variant-unit {
    font-size: 7px;
    color: var(--text-muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.page-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text);
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.2s;
    border: 1px solid var(--border);
}

.page-btn:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
}

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

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-ellipsis {
    color: var(--text-muted);
    padding: 0 8px;
}

.page-info {
    color: var(--text-muted);
    font-size: 14px;
    margin-left: 16px;
}

/* Checkbox Styling */
input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
    cursor: pointer;
    border-radius: 4px;
}

/* Responsive */
@media (max-width: 1400px) {

    th:nth-child(3),
    td:nth-child(3) {
        width: 260px;
    }

    th:nth-child(7),
    td:nth-child(7) {
        width: 200px;
    }
}

@media (max-width: 1200px) {

    th:nth-child(3),
    td:nth-child(3) {
        width: 200px;
    }

    th:nth-child(7),
    td:nth-child(7) {
        width: 180px;
    }
}

@media (max-width: 768px) {
    .control-panel {
        flex-direction: column;
        align-items: stretch;
    }

    input[type="text"] {
        width: 100%;
    }

    .stats-filter-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats {
        flex-wrap: wrap;
    }

    table {
        table-layout: auto;
    }

    th,
    td {
        padding: 8px 4px;
        font-size: 10px;
    }

    .variant-card {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Price Cell Styles */
.price-cell {
    text-align: right;
}

.price-tl {
    font-weight: 600;
    color: #f1f5f9;
}

.price-usd {
    font-size: 11px;
    color: #10b981;
}

/* Action Buttons */
.actions-cell {
    white-space: nowrap;
}

.action-btn {
    background: #334155;
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    margin-right: 4px;
    transition: all 0.2s;
}

.action-btn:hover {
    transform: scale(1.1);
}

.edit-btn:hover {
    background: #6366f1;
}

.ai-btn:hover {
    background: #8b5cf6;
}

.link-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.link-btn:hover {
    background: #059669;
}

/* Variant SKU */
.variant-sku {
    font-size: 9px;
    color: #64748b;
    font-family: monospace;
    margin-top: 2px;
}

/* Out of Stock Variant */
.variant-card.out-of-stock {
    opacity: 0.5;
    background: #991b1b !important;
    border-color: #7f1d1d !important;
}

/* Stock Select in Modal */
#modalStockStatus {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #334155;
    border-radius: 8px;
    background: #1e293b;
    color: #f1f5f9;
    font-size: 13px;
}

/* Variant table in modal */
.variant-table {
    table-layout: fixed;
}

.variant-table th:nth-child(1) {
    width: 80px;
}

.variant-table th:nth-child(2) {
    width: 160px;
}

.variant-table th:nth-child(3) {
    width: 60px;
}

.variant-table th:nth-child(4) {
    width: 100px;
}

.variant-table th:nth-child(5) {
    width: 80px;
}

.variant-table th:nth-child(6) {
    width: 70px;
}

/* Image Gallery */
.product-gallery {
    margin-bottom: 20px;
}

.gallery-main {
    position: relative;
    background: #0f172a;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 10px;
}

.gallery-main img {
    width: 100%;
    max-height: 280px;
    object-fit: contain;
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(30, 41, 59, 0.9);
    color: white;
    border: 2px solid rgba(99, 102, 241, 0.6);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.gallery-nav:hover {
    background: rgba(99, 102, 241, 0.9);
    border-color: #6366f1;
}

.gallery-prev {
    left: 8px;
}

.gallery-next {
    right: 8px;
}

.gallery-thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
}

.gallery-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s;
    border: 2px solid transparent;
    flex-shrink: 0;
}

.gallery-thumb:hover {
    opacity: 0.9;
}

.gallery-thumb.active {
    opacity: 1;
    border-color: #6366f1;
}

/* Activity Log Container */
.logs-container {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 4px;
}

.log-item {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
    background: #0f172a;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 11px;
}

.log-item .action {
    color: #a5b4fc;
    font-weight: 600;
}

.log-item .field {
    color: #94a3b8;
}

.log-item .time {
    color: #64748b;
    font-size: 10px;
    margin-left: auto;
}

/* AI Description Preview */
.ai-description-preview {
    background: #0f172a;
    border: 2px solid #334155;
    border-radius: 8px;
    padding: 12px 14px;
    color: #f1f5f9;
    font-size: 13px;
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
}

.ai-description-preview p {
    margin: 0 0 10px 0;
}

.ai-description-preview strong {
    color: #a5b4fc;
}

.ai-description-preview ol,
.ai-description-preview ul {
    margin: 10px 0;
    padding-left: 20px;
}

.ai-description-preview li {
    margin-bottom: 6px;
}