/* ============ CSS Variables - Fresh Light Theme ============ */
:root {
    --bg-primary: #f0f9f4;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8f5e9;
    --accent-primary: #4caf50;
    --accent-secondary: #2196f3;
    --accent-success: #66bb6a;
    --accent-warning: #ffa726;
    --accent-error: #ef5350;
    --text-primary: #1b5e20;
    --text-secondary: #388e3c;
    --text-muted: #81c784;
    --border-color: #c8e6c9;
    --glow-primary: rgba(76, 175, 80, 0.2);
    --glow-secondary: rgba(33, 150, 243, 0.2);
    --shadow-light: rgba(0, 0, 0, 0.05);
    --shadow-medium: rgba(0, 0, 0, 0.1);
}

/* ============ Global Styles ============ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ============ Header ============ */
.header {
    background: linear-gradient(135deg, #ffffff 0%, #e8f5e9 100%);
    padding: 2rem;
    border-bottom: 2px solid var(--accent-primary);
    box-shadow: 0 2px 10px var(--shadow-light);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow-light);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

/* ============ Tab Navigation ============ */
.tab-nav {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
    box-shadow: 0 2px 8px var(--shadow-light);
}

.tab-nav-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 2rem;
}

.tab-button {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 1rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-button:hover {
    color: var(--accent-primary);
    background: rgba(76, 175, 80, 0.05);
}

.tab-button.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
    font-weight: 600;
}

/* ============ Main Container ============ */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* ============ Dashboard Grid ============ */
.dashboard-grid {
    display: none; /* Hidden by default, shown after data loads */
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* ============ Loading Spinner ============ */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    gap: 1rem;
}

.loading-spinner.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner p {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
}

.category-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow-light);
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
}

.category-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px var(--shadow-medium);
    border-color: var(--accent-primary);
}

.category-card.updating {
    animation: cardPulse 0.3s ease;
}

@keyframes cardPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.01); }
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.category-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 0.25rem;
}

.category-stats {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.category-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============ Product Table ============ */
.product-table-wrapper {
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
}

.product-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.product-table thead {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 10;
}

.product-table th {
    padding: 0.75rem 0.5rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.product-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease;
    cursor: pointer;
}

.product-table tbody tr:hover {
    background: rgba(0, 212, 255, 0.05);
}

.product-table td {
    padding: 0.75rem 0.5rem;
    vertical-align: middle;
}

.time-col {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

.title-col {
    min-width: 200px;
    max-width: 300px;
}

.product-title-text {
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.product-meta-text {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.tags-col {
    min-width: 120px;
}

.tag {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: rgba(0, 212, 255, 0.1);
    color: var(--accent-primary);
    border-radius: 4px;
    font-size: 0.75rem;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
}

.tag-none {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.price-col {
    text-align: right;
    white-space: nowrap;
}

.current-price {
    color: var(--accent-error);
    font-weight: 600;
    font-size: 1rem;
}

.original-price {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-decoration: line-through;
}

.coupon-col {
    text-align: center;
}

.coupon-yes {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-error);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.coupon-no {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.worthiness-col {
    text-align: center;
    min-width: 80px;
}

.worthiness-rate {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.worthiness-rate.excellent {
    color: #10b981;
}

.worthiness-rate.good {
    color: #3b82f6;
}

.worthiness-rate.fair {
    color: #f59e0b;
}

.worthiness-rate.poor {
    color: #ef4444;
}

.worthiness-votes {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.no-data {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.product-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
}

.product-item {
    background: var(--bg-primary);
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.product-item:hover {
    border-color: var(--accent-primary);
    background: rgba(0, 212, 255, 0.05);
}

.product-title {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.product-price {
    color: var(--accent-error);
    font-weight: 600;
}

.product-discount {
    color: var(--accent-success);
    font-weight: 500;
}

.product-platform {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ============ Logs Section ============ */
.logs-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 2rem;
    box-shadow: 0 2px 8px var(--shadow-light);
}

.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.logs-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.logs-controls {
    display: flex;
    gap: 0.5rem;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

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

.logs-content {
    background: #fafafa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    height: 400px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

.log-entry {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.log-entry.info {
    color: var(--accent-secondary);
}

.log-entry.warning {
    color: var(--accent-warning);
}

.log-entry.error {
    color: var(--accent-error);
}

.log-entry.debug {
    color: var(--text-muted);
}

.timestamp {
    color: var(--text-muted);
    margin-right: 0.5rem;
}

/* ============ Config Section ============ */
.config-sub-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
}

.config-sub-tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    margin-bottom: -2px;
}

.config-sub-tab:hover {
    color: var(--accent-primary);
    background: rgba(76, 175, 80, 0.05);
}

.config-sub-tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
    font-weight: 600;
}

.config-subtab-content {
    display: none;
}

.config-subtab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.section-hint {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: rgba(76, 175, 80, 0.05);
    border-left: 3px solid var(--accent-primary);
    border-radius: 4px;
}

.config-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow-light);
}

.config-section h2 {
    font-size: 1.5rem;
    color: var(--accent-primary);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.form-group {
    margin-bottom: 1.5rem;
}

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

.form-input {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--glow-primary);
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.form-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.category-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-option:hover {
    border-color: var(--accent-primary);
    background: rgba(0, 212, 255, 0.05);
}

.category-option input[type="checkbox"] {
    cursor: pointer;
}

.btn-primary {
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--glow-primary);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--glow-primary);
}

.btn-secondary {
    padding: 0.75rem 2rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* ============ Alert Messages ============ */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: none;
}

.alert.show {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--accent-success);
    color: var(--accent-success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--accent-error);
    color: var(--accent-error);
}

/* ============ Loading State ============ */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============ Scrollbar Styling ============ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* ============ Responsive Design ============ */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .tab-nav-content {
        gap: 1rem;
    }

    .category-grid {
        grid-template-columns: 1fr;
    }
}
