/* Stock Forecaster Styles */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-light: #fecaca;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.5;
}

/* Screens */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Login Screen */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 40px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--gray-500);
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#login-form input {
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 16px;
}

#login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#login-form button {
    padding: 12px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

#login-form button:hover {
    background: var(--primary-dark);
}

.error-message {
    color: var(--danger);
    text-align: center;
    margin-top: 16px;
}

.hidden {
    display: none !important;
}

/* Header */
header {
    background: white;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--gray-200);
}

.header-left h1 {
    font-size: 20px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    background: var(--gray-100);
    color: var(--gray-500);
}

.status-badge.connected {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.error {
    background: var(--danger-light);
    color: #991b1b;
}

/* Buttons */
.btn-primary {
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

.btn-secondary {
    padding: 10px 20px;
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    cursor: pointer;
}

.btn-small:hover {
    background: var(--gray-50);
}

/* Main Content */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* Steps */
.step {
    display: none;
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.step.active {
    display: block;
}

.step h2 {
    font-size: 20px;
    margin-bottom: 24px;
    color: var(--gray-900);
}

.step-actions {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Search Section */
.search-section {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 24px;
}

.search-box {
    display: flex;
    gap: 12px;
    flex: 1;
}

.search-box input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

.or-divider {
    color: var(--gray-500);
    font-size: 14px;
}

.category-select {
    display: flex;
    gap: 12px;
}

.category-select select {
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    min-width: 200px;
}

/* Results Panel */
.results-panel {
    margin-bottom: 24px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 16px;
}

.results-panel h3 {
    font-size: 14px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.results-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.sku-list {
    max-height: 300px;
    overflow-y: auto;
}

.sku-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.sku-item:hover {
    background: var(--gray-50);
}

.sku-item.selected {
    background: #eff6ff;
}

.sku-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.sku-info {
    flex: 1;
}

.sku-code {
    font-weight: 600;
    font-size: 14px;
}

.sku-title {
    font-size: 12px;
    color: var(--gray-500);
}

.sku-stock {
    font-size: 12px;
    color: var(--gray-700);
    padding: 4px 8px;
    background: var(--gray-100);
    border-radius: 4px;
}

/* Selected Panel */
.selected-panel {
    margin-bottom: 24px;
}

.selected-panel h3 {
    font-size: 14px;
    margin-bottom: 12px;
}

.sku-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 40px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: 8px;
}

.sku-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 20px;
    font-size: 13px;
}

.sku-chip .remove {
    cursor: pointer;
    color: var(--gray-500);
}

.sku-chip .remove:hover {
    color: var(--danger);
}

/* Parameters */
.param-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.param-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.param-group label {
    font-weight: 500;
    font-size: 14px;
}

.param-group select,
.param-group input[type="number"] {
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
}

.param-help {
    font-size: 12px;
    color: var(--gray-500);
}

.range-input {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-input input[type="range"] {
    flex: 1;
}

.input-with-unit {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-with-unit input {
    width: 80px;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.loading-content {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    background: var(--gray-50);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.summary-card .card-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.summary-card .card-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.summary-card .card-label {
    font-size: 13px;
    color: var(--gray-500);
}

.summary-card.risk-critical {
    background: #fef2f2;
}

.summary-card.risk-high {
    background: #fff7ed;
}

/* Results Toolbar */
.results-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: 8px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filter-group select {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
}

.toolbar-actions {
    display: flex;
    gap: 12px;
}

/* Results Table */
.results-table-container {
    overflow-x: auto;
}

#results-table {
    width: 100%;
    border-collapse: collapse;
}

#results-table th {
    text-align: left;
    padding: 12px 16px;
    background: var(--gray-50);
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
}

#results-table th.num {
    text-align: right;
}

#results-table th.sortable {
    cursor: pointer;
}

#results-table th.sortable:hover {
    background: var(--gray-100);
}

#results-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
    font-size: 14px;
}

#results-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

#results-table tr:hover {
    background: var(--gray-50);
}

/* Risk Badges */
.risk-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.risk-badge.critical {
    background: #fef2f2;
    color: #991b1b;
}

.risk-badge.high {
    background: #fff7ed;
    color: #9a3412;
}

.risk-badge.medium {
    background: #fefce8;
    color: #854d0e;
}

.risk-badge.low {
    background: #f0fdf4;
    color: #166534;
}

/* Trend Indicators */
.trend-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
}

.trend-indicator.increasing {
    color: var(--success);
}

.trend-indicator.decreasing {
    color: var(--danger);
}

.trend-indicator.stable {
    color: var(--gray-500);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
    font-size: 18px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-500);
}

.modal-body {
    padding: 24px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

.detail-section h4 {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
}

.detail-row.highlight {
    background: var(--gray-50);
    padding: 8px 12px;
    margin: 4px -12px;
    border-radius: 6px;
    font-weight: 600;
}

.chart-container {
    margin-top: 24px;
}

.chart-container h4 {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 16px;
}

.chart-container canvas {
    max-height: 250px;
}

/* Responsive */
@media (max-width: 768px) {
    .search-section {
        flex-direction: column;
    }
    
    .or-divider {
        display: none;
    }
    
    .search-box,
    .category-select {
        width: 100%;
    }
    
    .param-grid {
        grid-template-columns: 1fr;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .results-toolbar {
        flex-direction: column;
        gap: 12px;
    }
}
