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

:root {
    --bg-main: #f5f6f8;
    --sidebar-bg: #1e2330;
    --sidebar-hover: #2d3446;
    --sidebar-active-bg: #2d3446;
    --text-dark: #111827;
    --text-gray: #6b7280;
    --border: #e5e7eb;
    --blue: #1d4ed8;
    --blue-hover: #1e40af;
    --green-text: #059669;
    --green-bg: #d1fae5;
    --red-text: #dc2626;
    --yellow-text: #b45309;
    --yellow-bg: #fef3c7;
    --skeleton: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-dark);
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* SIDEBAR */
.sidebar {
    width: 240px;
    min-width: 240px;
    background-color: var(--sidebar-bg);
    color: #9ca3af;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.3s ease;
    z-index: 50;
    overflow: hidden;
}

.logo-area {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-box {
    background-color: #fff;
    color: var(--sidebar-bg);
    font-weight: 800;
    font-size: 14px;
    padding: 6px 8px;
    border-radius: 6px;
    letter-spacing: -0.5px;
}

.logo-text {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    padding: 0 12px;
    gap: 6px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    color: #9ca3af;
    text-decoration: none;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 500;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.nav-item:hover {
    background-color: var(--sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background-color: var(--sidebar-active-bg);
    color: #fff;
}

.nav-item i {
    font-size: 17px;
    flex-shrink: 0;
}

.nav-badge {
    flex-shrink: 0;
    margin-left: auto;
    font-size: 10px;
    background: rgba(255,255,255,0.1);
    padding: 2px 5px;
    border-radius: 4px;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.sidebar-footer {
    padding: 24px 16px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.marketplace-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.marketplace-selector label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    font-weight: 600;
}
.marketplace-selector select {
    background: #111827;
    color: white;
    border: 1px solid #374151;
    padding: 8px;
    border-radius: 6px;
    outline: none;
    font-size: 13px;
    width: 100%;
}
.powered-by {
    margin-top: 16px;
    font-size: 11px;
    color: #6b7280;
    text-align: center;
}

/* MAIN CONTENT */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* TOPBAR */
.topbar {
    height: 70px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 32px;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-dark);
}
.page-title {
    font-weight: 600;
    font-size: 18px;
    letter-spacing: -0.3px;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 24px;
}
.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--green-bg);
    color: var(--green-text);
    padding: 6px 12px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
}
.status-dot {
    width: 8px;
    height: 8px;
    background: var(--green-text);
    border-radius: 50%;
}
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
}
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

/* DASHBOARD */
.dashboard-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    position: relative;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}
.page.active {
    display: block;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}
.page-desc {
    color: var(--text-gray);
    font-size: 15px;
}

/* INPUT CARDS */
.input-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.input-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 16px;
}
.input-row:last-child {
    margin-bottom: 0;
}
.input-row.three-col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
}
.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}
.input-group.flex-2 {
    flex: 2;
}
.input-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
}
.input-group input, .input-group select {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.input-group input:focus, .input-group select:focus {
    border-color: var(--blue);
}

/* BLACK BOX FILTERS */
.bb-advanced-filters {
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.bb-filter-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}
.bb-filters-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.filter-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 6px;
}
.filter-group label i {
    color: var(--text-gray);
    font-size: 14px;
}
.min-max-row {
    display: flex;
    gap: 8px;
}
.min-max-row input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}
.min-max-row input:focus {
    border-color: var(--blue);
}

.btn-primary {
    background-color: var(--blue);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 45px;
    transition: background-color 0.2s;
}
.btn-primary:hover {
    background-color: var(--blue-hover);
}
.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* SUMMARY CARDS */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}
.metric-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.metric-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-gray);
    margin-bottom: 8px;
}
.metric-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark);
}

/* DATA TABLE */
.table-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    overflow: visible;
}
.table-header-bar {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.table-header-bar h2 {
    font-size: 16px;
    font-weight: 600;
}
.result-count {
    font-size: 13px;
    color: var(--text-gray);
    font-weight: 500;
}
.table-wrapper {
    overflow-x: auto;
    max-height: 65vh;
    overflow-y: auto;
}

/* PAGINATION BAR */
.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: #f8f9fb;
    border-top: 2px solid var(--primary);
    border-radius: 0 0 12px 12px;
    position: sticky;
    bottom: 0;
    z-index: 5;
}
.pagination-left {
    display: flex;
    align-items: center;
    gap: 4px;
}
.pagination-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.pg-arrow {
    width: 32px;
    height: 32px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.pg-arrow:hover:not(:disabled) {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.pg-arrow:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.pg-numbers {
    display: flex;
    align-items: center;
    gap: 2px;
}
.pg-num {
    min-width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.pg-num:hover {
    background: #e8eaed;
}
.pg-num.active {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
}
.pg-ellipsis {
    min-width: 24px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #999;
}
.pg-label {
    font-size: 13px;
    color: #666;
    font-weight: 500;
}
.pg-select {
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}
.data-table th, .data-table td {
    padding: 16px 24px;
    text-align: left;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}
.data-table th {
    background: #f9fafb;
    font-weight: 600;
    color: var(--text-gray);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}
.data-table td {
    color: var(--text-dark);
    font-weight: 500;
    vertical-align: middle;
}
.data-table tbody tr:hover {
    background-color: #f8fafc;
}

/* Product cells */
.product-cell {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 300px;
}
.product-cell img {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--border);
}
.product-cell-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.product-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--blue);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.product-title:hover {
    text-decoration: underline;
}
.product-meta {
    font-size: 12px;
    color: var(--text-gray);
}

.badge {
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}
.badge-green { background: var(--green-bg); color: var(--green-text); }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f3f4f6; color: #4b5563; }

/* LOADING STATE */
.loading-state {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}
.skeleton-table {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.skeleton-row {
    height: 48px;
    background: var(--skeleton);
    border-radius: 8px;
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* EMPTY STATE */
.empty-state {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 64px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 24px;
}
.empty-state i {
    font-size: 48px;
    color: #9ca3af;
    margin-bottom: 16px;
}
.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}
.empty-state p {
    color: var(--text-gray);
    max-width: 400px;
    line-height: 1.5;
}

/* LQS SPECIFIC */
.lqs-score-section {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.lqs-hero-card {
    display: flex;
    align-items: center;
    padding: 32px;
    border-bottom: 1px solid var(--border);
    gap: 32px;
}
.lqs-score-circle {
    position: relative;
    width: 120px;
    height: 120px;
}
.lqs-score-circle svg {
    width: 120px;
    height: 120px;
    transform: rotate(-90deg);
}
.score-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 10;
}
.score-fill {
    fill: none;
    stroke: var(--green-text);
    stroke-width: 10;
    stroke-dasharray: 339.292; /* 2 * pi * 54 */
    stroke-dashoffset: 339.292;
    transition: stroke-dashoffset 1s ease-out;
}
.score-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    font-weight: 800;
    color: var(--text-dark);
    margin-top: -8px;
}
.score-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-gray);
    margin-top: 20px;
}
.lqs-product-info {
    display: flex;
    align-items: center;
    gap: 24px;
    flex: 1;
}
.lqs-product-image {
    width: 100px;
    height: 100px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
}
.lqs-product-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    line-height: 1.4;
}
.lqs-meta {
    display: flex;
    gap: 16px;
    font-size: 14px;
    color: var(--text-gray);
    font-weight: 500;
}
.lqs-breakdown {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
}
.lqs-item {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}
.lqs-item:nth-child(odd) {
    border-right: 1px solid var(--border);
}
.lqs-icon {
    font-size: 24px;
}
.lqs-icon.good { color: var(--green-text); }
.lqs-icon.bad { color: var(--red-text); }
.lqs-icon.warn { color: var(--yellow-text); }
.lqs-item-content h4 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}
.lqs-item-content p {
    font-size: 14px;
    color: var(--text-gray);
    line-height: 1.5;
}

/* TOASTS */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 100;
}
.toast {
    background: #1f2937;
    color: #fff;
    padding: 16px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastIn 0.3s ease;
}
.toast.error {
    border-left: 4px solid var(--red-text);
}
.toast.success {
    border-left: 4px solid var(--green-text);
}
@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@media (max-width: 1024px) {
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    .input-row.three-col {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        height: 100vh;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .mobile-menu-btn {
        display: block;
    }
    .input-row {
        flex-direction: column;
        align-items: stretch;
    }
    .summary-cards {
        grid-template-columns: 1fr;
    }
    .lqs-hero-card {
        flex-direction: column;
        text-align: center;
    }
    .lqs-product-info {
        flex-direction: column;
    }
    .lqs-breakdown {
        grid-template-columns: 1fr;
    }
    .lqs-item:nth-child(odd) {
        border-right: none;
    }
}
