/*
 * styles.css
 *
 * This stylesheet defines the visual appearance of the Inventory Intelligence & Risk Dashboard.
 * It builds upon the original SCM‑Analytics design with a light, modern palette and
 * adds layouts for the executive overview and risk dashboard. Variables are used for
 * easy theming and consistency. New classes introduced here support metric cards,
 * risk filters and responsive chart panels.
 */

/* CSS custom properties for easy theming */
:root {
    --primary-color: #07131b;    /* dark blue used for header and headings */
    --secondary-color: #1db561;  /* vibrant green from the SCM‑Analytics logo */
    --background-color: #f5f8fb; /* very light blue/grey for the page background */
    --card-bg: #ffffff;          /* white for card backgrounds */
    --text-color: #1a202c;       /* dark grey for readability */
    --border-radius: 0.5rem;
    --card-shadow: rgba(0,0,0,0.08);
    --focus-color: #00a16d;      /* darker green for focus outlines */
}

/* Reset defaults for margin, padding and box sizing */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', 'Open Sans', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Skip link styling for keyboard users */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background-color: var(--secondary-color);
    color: #fff;
    padding: 0.5rem 1rem;
    z-index: 100;
    transition: top 0.3s;
}
.skip-link:focus {
    top: 0;
}

/* Header and navigation bar */
.navbar {
    background-color: var(--primary-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}
.navbar .logo img {
    height: 42px;
}
.navbar nav {
    position: relative;
}
.navbar .menu {
    display: flex;
    gap: 1.5rem;
    list-style: none;
}
.navbar .menu a {
    color: #fff;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}
.navbar .menu a:hover,
.navbar .menu a:focus {
    color: var(--secondary-color);
    outline: none;
}
.navbar .menu-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
}

/* Hero section */
.hero {
    background: linear-gradient(90deg, #f5f8fb 0%, #eaf4f9 50%, #f5f8fb 100%);
    padding: 3rem 2rem;
    text-align: center;
}
.hero h1 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}
.hero p {
    font-size: 1.125rem;
    margin-bottom: 1.5rem;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}
.hero .hero-btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    background-color: var(--secondary-color);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.2s;
}
.hero .hero-btn:hover,
.hero .hero-btn:focus {
    background-color: #16934a;
    outline: none;
}

/* Generic section styling */
.section {
    padding: 2rem 1rem;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}
.section h2 {
    margin-bottom: 1rem;
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 600;
}

/* Upload controls */
.upload-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.input-group label {
    font-weight: 600;
    font-size: 0.9rem;
}
.input-group small {
    font-size: 0.75rem;
    color: #6b7280;
}
input[type="file"] {
    padding: 0.4rem;
    border: 1px solid #cbd5e1;
    border-radius: var(--border-radius);
    background-color: #fff;
    font-size: 0.9rem;
}
input[type="file"]:focus {
    outline: 2px solid var(--focus-color);
}
.btn {
    background-color: var(--secondary-color);
    color: #fff;
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 0.5rem;
}
.btn:disabled {
    background-color: #9bd3b5;
    cursor: not-allowed;
}
.btn:hover:not(:disabled),
.btn:focus:not(:disabled) {
    background-color: #16934a;
    outline: none;
}

/* Tabs */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 2rem auto 1rem;
    max-width: 1200px;
    padding: 0 1rem;
}
.tab {
    padding: 0.5rem 1rem;
    border: 1px solid var(--secondary-color);
    border-radius: var(--border-radius);
    background-color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}
.tab.active {
    background-color: var(--secondary-color);
    color: #fff;
}
.tab:not(.active):hover,
.tab:not(.active):focus {
    background-color: #e6f5ee;
}

/* Tab content visibility */
.tab-content {
    display: none;
    padding: 1rem;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}
.tab-content.active {
    display: block;
}

/* Cards and tables reused from original */
.card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px var(--card-shadow);
    padding: 1rem;
    margin-bottom: 1rem;
}
.card h3 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    font-size: 1.125rem;
}

table.display {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
table.display thead th {
    background-color: var(--primary-color);
    color: #fff;
    padding: 0.5rem;
    text-align: left;
    position: sticky;
    top: 0;
}
table.display tbody td {
    padding: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
}
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
}
.badge-critical { background-color: #e53e3e; }
.badge-low { background-color: #ed8936; }
.badge-ok { background-color: #38a169; }
.badge-excess { background-color: #3182ce; }
.badge-stale { background-color: #6b46c1; }

/* Overview specific classes */
.overview-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}
.metric-card {
    flex: 1 1 200px;
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px var(--card-shadow);
    padding: 1rem;
    text-align: center;
}
.metric-card h3 {
    font-size: 1rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}
.metric-card p {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--secondary-color);
}
.overview-charts {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}
.chart-card {
    flex: 1 1 300px;
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px var(--card-shadow);
    padding: 1rem;
    height: 280px;
    display: flex;
    flex-direction: column;
}
.chart-card h3 {
    font-size: 1rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}
.chart-card canvas {
    flex: 1;
    width: 100%;
}
.overview-toprisks {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px var(--card-shadow);
    padding: 1rem;
    margin-bottom: 1rem;
}
.overview-toprisks h3 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    font-size: 1.125rem;
}
.overview-toprisks ul {
    list-style: none;
    padding-left: 0;
}
.overview-toprisks li {
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

/* Risk dashboard styles */
.risk-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.risk-filters button {
    padding: 0.4rem 1rem;
    border: 1px solid var(--secondary-color);
    background-color: #fff;
    color: var(--primary-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.2s;
}
.risk-filters button.active {
    background-color: var(--secondary-color);
    color: #fff;
}
.risk-filters button:hover:not(.active),
.risk-filters button:focus:not(.active) {
    background-color: #e6f5ee;
}
.flex-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}
.table-container {
    flex: 1 1 320px;
    max-height: 420px;
    overflow: auto;
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px var(--card-shadow);
}
.table-container table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.table-container thead th {
    position: sticky;
    top: 0;
    background-color: var(--primary-color);
    color: #fff;
    padding: 0.4rem;
    text-align: left;
    font-weight: 600;
}
.table-container tbody td {
    padding: 0.4rem;
    border-bottom: 1px solid #e2e8f0;
}
.table-container tr.selected {
    background-color: #e6fffa;
}
.chart-container {
    flex: 1 1 320px;
    min-height: 420px;
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px var(--card-shadow);
    padding: 1rem;
}

.badge.low {
    background-color: #38a169;
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
}
.badge.medium {
    background-color: #ed8936;
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
}
.badge.high {
    background-color: #e53e3e;
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* Footer */
.footer {
    background-color: var(--primary-color);
    color: #fff;
    text-align: center;
    padding: 1rem 0;
    margin-top: 2rem;
}
.footer p {
    font-size: 0.8rem;
}

/* Analysis overview and charts (Inventory & Demand) */
.analysis-overview {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}
.analysis-charts {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}
.demand-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.demand-controls label {
    font-weight: 600;
    font-size: 0.9rem;
}
.demand-controls select {
    flex: 1 1 200px;
    min-width: 200px;
    padding: 0.4rem;
    border: 1px solid #cbd5e1;
    border-radius: var(--border-radius);
    background-color: #fff;
    font-size: 0.9rem;
}
.demand-controls button {
    align-self: flex-start;
}

/* Vendor table adjustments */
#vendorTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
#vendorTable thead th {
    background-color: var(--primary-color);
    color: #fff;
    padding: 0.5rem;
    text-align: left;
    position: sticky;
    top: 0;
}
#vendorTable tbody td {
    padding: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
}

/* Responsive tweaks */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 1.5rem;
    }
    .metric-card p {
        font-size: 1.25rem;
    }
    .chart-card {
        height: 240px;
    }
    .table-container, .chart-container {
        flex: 1 1 100%;
    }
}

/* Current State Dashboard Styles */
.dashboard-filters {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 150px;
}

.filter-group label {
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
}

.filter-group select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 14px;
}

.dashboard-section {
    margin-bottom: 30px;
}

.status-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
}

.status-metrics {
    display: flex;
    justify-content: center;
    gap: 60px;
    margin-top: 20px;
}

.status-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.status-metric .metric-value {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.status-metric .metric-label {
    font-size: 1rem;
    opacity: 0.9;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.dashboard-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.card-header {
    background: #f8f9fa;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header i {
    color: #007bff;
    font-size: 1.2rem;
}

.card-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.1rem;
}

.card-content {
    padding: 20px;
}

.gauge-container {
    position: relative;
    margin-bottom: 20px;
}

.gauge-legend {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.inventory-metrics, .waste-metrics {
    margin-bottom: 20px;
}

.metric-item {
    display: flex;
    justify-content: between;
    margin-bottom: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.metric-label {
    color: #666;
    font-size: 0.9rem;
}

.metric-value {
    font-weight: bold;
    color: #333;
}

.metric-group {
    margin-bottom: 20px;
}

.metric-group h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 1rem;
}

.key-figures-section {
    margin-bottom: 40px;
}

.key-figures-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.key-figure-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.figure-label {
    display: block;
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.figure-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
}

.figure-value.positive {
    color: #28a745;
}

.figure-value.negative {
    color: #dc3545;
}

.bottom-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.anomaly-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 15px;
}

.anomaly-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.anomaly-label {
    display: block;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 10px;
}

.anomaly-values {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.anomaly-count {
    font-size: 1.5rem;
    font-weight: bold;
    color: #dc3545;
}

.anomaly-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
}

/* Risk Settings Styles */
.risk-settings-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

.settings-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 30px;
}

.settings-card h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.threshold-settings {
    margin: 30px 0;
}

.threshold-group {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.threshold-group h4 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.1rem;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
}

.threshold-inputs {
    display: grid;
    gap: 20px;
}

.threshold-inputs .input-group {
    display: grid;
    gap: 8px;
}

.threshold-inputs label {
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
}

.threshold-inputs input {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.threshold-inputs input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.threshold-inputs small {
    color: #666;
    font-size: 0.85rem;
    font-style: italic;
}

.settings-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

.btn-outline {
    background: transparent;
    color: #007bff;
    border: 2px solid #007bff;
}

.btn-outline:hover {
    background: #007bff;
    color: white;
}

.settings-status {
    margin-top: 20px;
    padding: 15px;
    border-radius: 6px;
    text-align: center;
}

.settings-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.settings-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.settings-status.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.settings-preview {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 30px;
}

.settings-preview h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.preview-table-container {
    margin-top: 20px;
    overflow-x: auto;
}

.preview-table-container table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.preview-table-container th,
.preview-table-container td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.preview-table-container th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.preview-table-container td {
    color: #666;
}

/* Risk level indicators */
.risk-low {
    color: #28a745;
    font-weight: bold;
}

.risk-medium {
    color: #fd7e14;
    font-weight: bold;
}

.risk-high {
    color: #dc3545;
    font-weight: bold;
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
    .dashboard-filters {
        flex-direction: column;
        gap: 15px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .status-metrics {
        flex-direction: column;
        gap: 20px;
    }
    
    .key-figures-grid {
        grid-template-columns: 1fr;
    }
    
    .bottom-section {
        grid-template-columns: 1fr;
    }
    
    .risk-settings-container {
        grid-template-columns: 1fr;
    }
    
    .settings-actions {
        flex-direction: column;
    }
    
    .anomaly-grid {
        grid-template-columns: 1fr;
    }
}

/* Canvas sizing for charts */
.gauge-container canvas,
.prediction-chart canvas,
.inventory-gauge canvas,
.waste-gauge canvas {
    max-width: 100%;
    height: auto;
}

.prediction-chart {
    margin-top: 20px;
}

.prediction-chart h4 {
    margin-bottom: 10px;
    color: #333;
    font-size: 1rem;
}

