/* SupplyChainX Custom Styles */

:root {
    --primary-color: #0066cc;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;

    --bs-primary: #0d6efd;
    --bs-success: #198754;
    --bs-warning: #ffc107;
    --bs-danger: #dc3545;
    --bs-info: #0dcaf0;
}

/* Main Layout */
body {
    padding-top: 60px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f5f7fa;
}

main {
    min-height: calc(100vh - 120px);
}

/* Navbar Customization */
.navbar {
    box-shadow: 0 2px 4px rgba(0,0,0,.08);
}

/* Offcanvas navigation styling */
.offcanvas .nav-link {
    padding: 0.75rem 1rem;
    color: #495057;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.offcanvas .nav-link:hover {
    background-color: #f8f9fa;
    color: var(--bs-primary);
}

.offcanvas .nav-link.active {
    background-color: var(--bs-primary);
    color: white;
}

.offcanvas .nav-link i {
    width: 20px;
    margin-right: 0.5rem;
}

/* Cards */
.card {
    border: 1px solid rgba(0,0,0,.125);
    border-radius: 8px;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,.075);
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,.15);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid rgba(0,0,0,.125);
    font-weight: 600;
}

/* KPI Cards */
.kpi-card {
    position: relative;
    overflow: hidden;
}

.kpi-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1));
}

/* Progress Bars */
.progress {
    height: 8px;
    border-radius: 4px;
    background-color: #e9ecef;
}

/* Badges */
.badge {
    font-size: 0.75em;
    font-weight: 500;
}

/* Supplier Cards */
.supplier-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    border: 1px solid #e3e6f0;
}

.supplier-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,.15);
}

.supplier-card .card-body {
    padding: 1.5rem;
}

.supplier-card .card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.supplier-rating {
    margin-bottom: 1rem;
}

.supplier-rating .stars {
    color: #ffc107;
    font-size: 0.9rem;
    margin-right: 0.5rem;
}

.supplier-rating .rating-value {
    font-weight: 500;
    color: #495057;
}

.supplier-category {
    font-size: 0.8rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.supplier-metrics {
    background-color: #f8f9fa;
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 1rem 0;
}

.supplier-metrics .metric {
    text-align: center;
}

.supplier-metrics .metric-value {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.supplier-metrics .metric-label {
    font-size: 0.75rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.supplier-actions {
    margin-top: 1rem;
}

.supplier-actions .btn {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
}

/* Status badges */
.status-active {
    background-color: #28a745 !important;
}

.status-inactive {
    background-color: #6c757d !important;
}

.status-suspended {
    background-color: #dc3545 !important;
}

/* Performance indicators */
.performance-good {
    color: #28a745 !important;
}

.performance-warning {
    color: #ffc107 !important;
}

.performance-danger {
    color: #dc3545 !important;
}

/* Summary Cards */
.summary-card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,.1);
    transition: transform 0.2s ease-in-out;
}

.summary-card:hover {
    transform: translateY(-2px);
}

.summary-card .card-body {
    padding: 1.5rem;
}

.summary-card h3 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.summary-card p {
    font-size: 0.9rem;
    font-weight: 500;
    color: #6c757d;
}

/* Filter Card */
.filter-card {
    border: 1px solid #e3e6f0;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.filter-card .card-body {
    padding: 1.25rem;
}

/* Responsive improvements */
@media (max-width: 768px) {
    .supplier-card {
        margin-bottom: 1rem;
    }
    
    .supplier-metrics {
        padding: 0.75rem;
    }
    
    .supplier-metrics .metric-value {
        font-size: 1rem;
    }
    
    .summary-card h3 {
        font-size: 2rem;
    }
    
    .filter-card .row > div {
        margin-bottom: 0.5rem;
    }
}

.badge {
    font-size: 0.75em;
    padding: 0.35em 0.65em;
    font-weight: 500;
}

.bg-low { background-color: #28a745 !important; }
.bg-medium { background-color: #ffc107 !important; }
.bg-high { background-color: #fd7e14 !important; }
.bg-critical { background-color: #dc3545 !important; }

/* Tables */
.table {
    margin-bottom: 0;
}

.table thead th {
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: #495057;
    background-color: #f8f9fa;
}

.table-hover tbody tr {
    cursor: pointer;
    transition: background-color 0.2s;
}

.table-hover tbody tr:hover {
    background-color: rgba(0,0,0,.02);
}

/* Kanban Board */
.kanban-column {
    min-height: 400px;
    background-color: #f8f9fa;
    border-radius: 4px;
    padding: 8px;
}

.po-card {
    cursor: move;
    transition: transform 0.2s;
}

.po-card:hover {
    transform: translateY(-2px);
}

.po-card.dragging {
    opacity: 0.5;
}

/* Maps */
#disruptionMap, #shipmentsMap, #riskHeatmap {
    width: 100%;
    border-radius: 4px;
}

.leaflet-container {
    font-family: inherit;
}

.map-legend {
    background: rgba(255,255,255,0.95);
    border: 1px solid #dee2e6;
}

/* Timeline */
.timeline-container {
    position: relative;
    padding: 20px 0;
}

.timeline-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #dee2e6;
    z-index: 0;
}

.timeline-item {
    position: relative;
    z-index: 1;
}

.timeline-marker {
    position: relative;
    z-index: 2;
}

/* Chat Widget */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1050;
}

.chat-widget button {
    width: 60px;
    height: 60px;
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,.15);
}

.chat-toggle {
    width: 60px;
    height: 60px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    position: relative;
}

.chat-toggle .badge {
    position: absolute;
    top: -5px;
    right: -5px;
}

.chat-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,.15);
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 15px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

/* Procurement Chat Panel (embedded in purchase order page) */
.procurement-chat-panel {
    position: relative;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.chat-message {
    margin-bottom: 15px;
}

.chat-message.user {
    text-align: right;
}

.chat-message.user p {
    background-color: var(--primary-color);
    color: white;
    display: inline-block;
    padding: 8px 12px;
    border-radius: 18px 18px 4px 18px;
    max-width: 80%;
}

.chat-message.bot p {
    background-color: #f1f3f4;
    display: inline-block;
    padding: 8px 12px;
    border-radius: 18px 18px 18px 4px;
    max-width: 80%;
}

.chat-footer {
    padding: 15px;
    border-top: 1px solid #dee2e6;
}

.chat-quick-actions {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

/* Notifications */
.notification-item {
    transition: background-color 0.2s;
}

.notification-item:hover {
    background-color: #f8f9fa;
}

/* Toasts */
.toast-container {
    z-index: 1080;
}

/* Loading States */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Recommendation cards */
.recommendation-card {
    border-left: 4px solid var(--bs-primary);
}

.recommendation-card.high-priority {
    border-left-color: var(--bs-danger);
}

/* Recommendation filters */
.rec-search-input { width:160px; }
.rec-severity-select { width:120px; }

/* XAI rationale snippet */
.recommendation-card .xai-snippet {
    border-left: 3px solid var(--bs-info);
    padding-left: 8px;
    font-style: italic;
}

/* Pagination controls for recommendations */
.rec-pager { border-top:1px solid #eee; padding-top:6px; margin-top:6px; }
.rec-pager button { min-width:60px; }

/* Empty States */
.empty-state {
    padding: 3rem;
    text-align: center;
    color: #6c757d;
}

.empty-state i {
    font-size: 4rem;
    opacity: 0.3;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Animation for real-time updates */
.update-flash {
    animation: flash 0.5s;
}

@keyframes flash {
    0%, 100% {
        background-color: transparent;
    }
    50% {
        background-color: rgba(13,110,253,.1);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .chat-panel {
        width: 100%;
        right: -20px;
        left: -20px;
        bottom: 70px;
        height: 80vh;
        border-radius: 8px 8px 0 0;
    }
    
    .offcanvas {
        width: 250px !important;
    }
    
    .chat-widget {
        bottom: 70px !important;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
}

/* Print Styles */
@media print {
    .navbar,
    .offcanvas,
    .chat-widget,
    .btn,
    footer {
        display: none !important;
    }
    
    body {
        padding-top: 0;
    }
    
    .card {
        border: 1px solid #dee2e6;
        box-shadow: none;
    }
}

/* Custom styles for SupplyChainX */

/* Risk indicator colors */
.risk-high { color: #dc3545; }
.risk-medium { color: #ffc107; }
.risk-low { color: #28a745; }

/* Status badge colors */
.bg-in-transit { background-color: #17a2b8; }
.bg-delayed { background-color: #ffc107; }
.bg-delivered { background-color: #28a745; }

/* Map markers */
.risk-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 16px;
    color: white;
}

.risk-marker.risk-high {
    background-color: #dc3545;
}

.risk-marker.risk-medium {
    background-color: #ffc107;
}

.risk-marker.risk-low {
    background-color: #28a745;
}

/* Connection indicator */
.connection-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 5px;
}

.connection-indicator.connected {
    background-color: #28a745;
}

.connection-indicator.disconnected {
    background-color: #dc3545;
}

/* Chat styles */
.chat-message {
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 5px;
}

.chat-message.user {
    background-color: #007bff;
    color: white;
    margin-left: 20%;
}

.chat-message.bot {
    background-color: #f8f9fa;
    margin-right: 20%;
}

/* Timeline styles */
.timeline {
    position: relative;
    padding: 20px 0;
}

.timeline-item {
    position: relative;
    padding-left: 40px;
    margin-bottom: 20px;
}

.timeline-marker {
    position: absolute;
    left: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #007bff;
    top: 0;
}

.timeline-content {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
}

/* Recommendation card */
.recommendation-card {
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 15px;
    background-color: #f8f9fa;
}

/* Alert item */
.alert-item {
    border-left: 4px solid;
    margin-bottom: 10px;
}

.alert-item.severity-high {
    border-left-color: #dc3545;
}

.alert-item.severity-medium {
    border-left-color: #ffc107;
}

.alert-item.severity-low {
    border-left-color: #28a745;
}

/* Loading skeleton */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Toast container */
#toastContainer {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1050;
}

/* Floating chat widget */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1040;
}

.chat-widget-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #007bff;
    color: white;
    border: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.chat-widget-button:hover {
    background-color: #0056b3;
}

/* Offcanvas navigation */
.offcanvas-start {
    width: 280px;
}

/* Dashboard cards */
.metric-card {
    transition: transform 0.2s;
}

.metric-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* Table hover effects */
.table-hover tbody tr:hover {
    background-color: rgba(0,123,255,0.05);
}

/* Progress bars */
.progress {
    height: 20px;
}

.progress-bar {
    font-weight: 600;
}

/* Map container */
#disruptionMap, #shipmentMap {
    width: 100%;
    height: 400px;
    border-radius: 5px;
}

/* Logistics specific */
.logistics-map {
    height: 500px;
    width: 100%;
}

.route-line-sample {
    width: 30px;
    height: 2px;
    background: var(--danger-color);
    display: inline-block;
}

/* Enhanced Chat Styles */
.typing-animation {
    display: inline-flex;
    align-items: center;
}

.typing-animation span {
    height: 8px;
    width: 8px;
    border-radius: 50%;
    background-color: #6c757d;
    margin: 0 2px;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-animation span:nth-child(1) { animation-delay: -0.32s; }
.typing-animation span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.chat-message {
    animation: fadeInUp 0.3s ease forwards;
}

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

#chatInput {
    resize: none;
    min-height: 38px;
    border-radius: 20px;
    padding: 10px 15px;
}

.chat-messages {
    scroll-behavior: smooth;
}
