/* Production Order Modal Styles */

/* Location Badge Styles */
.item-location-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    margin: 8px 0;
    background-color: rgba(107, 114, 128, 0.1);
    border: 1px solid rgba(107, 114, 128, 0.3);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    color: #4b5563;
    white-space: nowrap;
    width: 100%;
    justify-content: center;
    box-sizing: border-box;
}

.item-location-badge svg {
    flex-shrink: 0;
}

.item-location-badge span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Location type color coding */
.item-location-badge.location-type-production {
    background-color: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
    color: #1d4ed8;
}

.item-location-badge.location-type-depot {
    background-color: rgba(168, 85, 247, 0.1);
    border-color: #a855f7;
    color: #7c3aed;
}

.item-location-badge.location-type-customer {
    background-color: rgba(34, 197, 94, 0.1);
    border-color: #22c55e;
    color: #15803d;
}

.item-location-badge.location-type-transit {
    background-color: rgba(251, 146, 60, 0.1);
    border-color: #fb923c;
    color: #ea580c;
}

/* Override the parent grid layout */
#order-items-grid {
    display: block !important;
    grid-template-columns: none !important;
    width: 100% !important;
}

/* Horizontal Items Container - WRAP AFTER 4 ITEMS */
.items-horizontal-container {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;  /* Allow wrapping to next line */
    gap: 20px !important;  /* Slightly larger gap for better spacing */
    padding: 12px !important;
    width: 100% !important;
    overflow-x: hidden !important;  /* No horizontal scroll */
    overflow-y: auto !important;  /* Allow vertical scroll if needed */
    min-height: 450px !important;  /* Taller to accommodate larger items */
    align-items: stretch !important;  /* Make all items same height */
    justify-content: flex-start !important;
    max-width: 1380px !important;  /* 4 items * 320px + 3 gaps * 20px = 1340px + padding */
}

/* Override any conflicting order-item styles from other CSS files */
.modal-production .items-horizontal-container .order-item {
    /* Force block display and fixed dimensions - 320px wide */
    display: flex !important;  /* Keep flex for internal layout */
    flex-direction: column !important;  /* Keep column for internal content */
    flex: 0 0 320px !important;  /* 320px width as requested */
    width: 320px !important;
    min-width: 320px !important;
    max-width: 320px !important;
    height: auto !important;
    margin: 0 !important;
    float: none !important;
    position: relative !important;
    
    /* Ensure proper styling */
    background: white !important;
    border: 2px solid transparent !important;
    border-radius: 8px !important;
    padding: 16px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    gap: 12px !important;
    
    /* Ensure proper box sizing */
    box-sizing: border-box !important;
}

/* Hover and selected states for items */
.modal-production .items-horizontal-container .order-item:hover {
    border-color: #e5e7eb !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
}

.modal-production .items-horizontal-container .order-item.selected {
    border-color: #3b82f6 !important;
    background: #eff6ff !important;
}

/* Item image adjustments for wider containers */
.modal-production .items-horizontal-container .item-image-large {
    width: 100% !important;
    height: 320px !important;  /* Match container width for square aspect */
    border-radius: 6px !important;
    overflow: hidden !important;
    background: #f9fafb !important;
    position: relative !important;
}

.modal-production .items-horizontal-container .item-image-large img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
}

/* Sync Bands Pill Styling */
.sync-band-pill {
    position: absolute;
    top: 10px;
    right: 10px;  /* Moved to right corner */
    padding: 8px 14px;  /* Slightly larger padding */
    border-radius: 18px;
    color: white;
    font-weight: 600;
    font-size: 13px;  /* Slightly larger font */
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Merge Cassette Pill Styling */
.merge-cassette-pill {
    position: absolute;
    top: 45px;  /* Positioned below sync_bands pill (10px + pill height + gap) */
    right: 10px;  /* Same right position as sync_bands */
    padding: 8px 14px;  /* Slightly larger padding */
    border-radius: 18px;
    background-color: #fbbf24;
    color: #78350f;
    font-weight: 600;
    font-size: 13px;  /* Slightly larger font */
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Motor Pill Styling */
.motor-pill {
    position: absolute;
    top: 80px;  /* Positioned below merge_cassette pill (45px + pill height + gap) */
    right: 10px;  /* Same right position as other pills */
    padding: 8px 14px;  /* Slightly larger padding */
    border-radius: 18px;
    background-color: #fde047;  /* Yellow background */
    color: #713f12;  /* Dark brown text for contrast */
    font-weight: 600;
    font-size: 13px;  /* Slightly larger font */
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Kolorama Dimension Adjustment Pills */
.width-adjustment-pill {
    position: absolute;
    left: 10px;  /* Top-left corner */
    top: 10px;  /* Top-left corner */
    padding: 8px 14px;
    border-radius: 20px;
    background-color: #3b82f6;  /* Blue background */
    color: white;
    font-weight: 700;
    font-size: 16px;  /* Bigger font */
    z-index: 2;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
    min-width: 70px;
    text-align: center;
}

.height-adjustment-pill {
    position: absolute;
    right: 10px;  /* Bottom-right corner */
    bottom: 10px;  /* Bottom-right corner */
    padding: 8px 14px;
    border-radius: 20px;
    background-color: #10b981;  /* Green background */
    color: white;
    font-weight: 700;
    font-size: 16px;  /* Bigger font */
    z-index: 2;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
    min-width: 70px;
    text-align: center;
}

/* Note Icon Pulse Animation */
@keyframes subtle-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 2px 8px rgba(252, 211, 77, 0.5);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }
}

/* Order Note Panel Styles */
.order-note-panel {
    background: #fef3c7 !important;
    border: 2px solid #fbbf24 !important;
    border-radius: 12px !important;
    padding: 0 !important;
    margin: 20px 0 !important;
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3) !important;
    animation: slideIn 0.3s ease-out;
    position: relative !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 10 !important;
}

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

.note-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #fbbf24;
    background: rgba(251, 191, 36, 0.1);
    border-radius: 10px 10px 0 0;
}

.note-panel-header h4 {
    margin: 0;
    color: #92400e;
    font-size: 16px;
    font-weight: 600;
}

.note-panel-close {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
    color: #92400e;
}

.note-panel-close:hover {
    background: rgba(146, 64, 14, 0.1);
}

.note-panel-content {
    padding: 16px;
    color: #78350f;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* Style the note button when there's a note */
.modal-production .btn-note.has-note {
    background-color: #fef3c7 !important;
    border-color: #fbbf24 !important;
    color: #92400e !important;
}


/* Additional overrides to ensure proper wrapping */
.modal-production .items-horizontal-container {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
}

/* Ensure items maintain their width but can wrap */
.modal-production .items-horizontal-container > * {
    flex-shrink: 0 !important;
    flex-basis: 320px !important;  /* Each item takes 320px width */
}

/* Override any parent container that might force vertical layout */
.modal-production #order-items-grid {
    display: block !important;
    width: 100% !important;
    overflow: visible !important;
}

/* Force horizontal layout on the items container */
.modal-production .items-grid {
    display: block !important;
    width: 100% !important;
}

/* Scrollbar styling for horizontal container */
.items-horizontal-container::-webkit-scrollbar {
    height: 8px;
}

.items-horizontal-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.items-horizontal-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.items-horizontal-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Button Loading State */
.btn-production.loading {
    opacity: 0.6;
    cursor: not-allowed;
    position: relative;
}

.btn-production.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: button-spinner 0.6s linear infinite;
}

@keyframes button-spinner {
    to { transform: rotate(360deg); }
}

.btn-production:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Modal Body Sections - Ensure full width */
.modal-production .modal-body {
    overflow-x: hidden;
    overflow-y: auto;
}

.modal-production .modal-body > * {
    width: 100%;
    box-sizing: border-box;
}

/* Completed Steps Section */
.completed-steps-section {
    margin-bottom: 30px;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
}

.steps-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.steps-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}

.steps-progress {
    display: flex;
    align-items: center;
    gap: 10px;
}

.overall-progress-bar {
    width: 120px;
    height: 6px;
    background: #e0e6ed;
    border-radius: 3px;
    overflow: hidden;
}

.overall-progress-bar .progress-fill {
    height: 100%;
    background: #3b82f6;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 13px;
    color: #64748b;
}

.steps-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Completed Step Items */
.completed-step-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e0e6ed;
}

.completed-step-item .step-icon {
    width: 40px;
    height: 40px;
    background: #dcfce7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #22c55e;
    flex-shrink: 0;
}

.completed-step-item .step-icon svg {
    width: 20px;
    height: 20px;
}

.step-details {
    flex: 1;
}

.step-name {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
}

.step-progress-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #64748b;
}

.items-completed {
    font-weight: 500;
    color: #22c55e;
}

.step-time {
    color: #94a3b8;
}

.step-user {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 2px;
}

.step-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #94a3b8;
    margin-top: 4px;
}

.step-date {
    font-size: 12px;
    color: #94a3b8;
}

.no-completed-steps {
    text-align: center;
    padding: 20px;
    color: #94a3b8;
    font-size: 14px;
}

.step-card {
    background: white;
    border: 1px solid #e0e6ed;
    border-radius: 10px;
    padding: 16px;
    transition: all 0.2s ease;
}

.step-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.step-card.completed {
    background: #f0fdf4;
    border-color: #86efac;
}

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

.step-icon {
    width: 48px;
    height: 48px;
    background: #eff6ff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #3b82f6;
    flex-shrink: 0;
}

.step-card.completed .step-icon {
    background: #dcfce7;
    color: #22c55e;
}

.step-info {
    flex: 1;
}

.step-name {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

.step-progress {
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #e0e6ed;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar .progress-fill {
    height: 100%;
    background: #3b82f6;
    transition: width 0.3s ease;
}

.step-card.completed .progress-bar .progress-fill {
    background: #22c55e;
}

.progress-label {
    font-size: 13px;
    color: #64748b;
    white-space: nowrap;
}

.step-status {
    display: flex;
    align-items: center;
}

.check-icon {
    color: #22c55e;
}

.btn-complete-step {
    padding: 8px 16px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-complete-step:hover {
    background: #2563eb;
}

.step-meta {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e0e6ed;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #64748b;
}

/* Activity Timeline Section */
.activity-section {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e0e6ed;
    color: #2c3e50;
    width: 100%;
    box-sizing: border-box;
}

.activity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.activity-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}

.activity-filters {
    display: flex;
    gap: 8px;
}

.activity-filter {
    padding: 6px 12px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
}

.activity-filter:hover {
    background: #e2e8f0;
}

.activity-filter.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.activity-timeline {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    min-height: 100px;
    width: 100%;
}

#order-activity-list {
    min-height: 80px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.activity-loading {
    display: none; /* Hide loading spinner by default */
}

.timeline-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

/* Activity Items - matching completed steps style */
.activity-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e0e6ed;
    width: 100%;
    box-sizing: border-box;
}

.activity-icon {
    width: 40px;
    height: 40px;
    background: #eff6ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #3b82f6;
    flex-shrink: 0;
    font-size: 20px;
    font-weight: bold;
}

.activity-icon.status_change {
    background: #fef3c7;
    color: #f59e0b;
}

.activity-icon.hub_status,
.activity-icon.hub_status_change {
    background: #e0e7ff;
    color: #6366f1;
}

.activity-icon.order_created {
    background: #dbeafe;
    color: #2563eb;
}

.activity-details {
    flex: 1;
}

.activity-name {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
}

.activity-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #64748b;
    flex-wrap: wrap;
}

.activity-description {
    color: #475569;
}

.activity-time {
    color: #94a3b8;
}

.activity-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #94a3b8;
    margin-top: 4px;
}

.activity-user {
    font-weight: 500;
}

.activity-date {
    color: #94a3b8;
}

.timeline-group {
    margin-bottom: 24px;
}

.timeline-date {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 16px;
    padding-left: 40px;
}

.timeline-items {
    position: relative;
}

.timeline-item {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    position: relative;
    overflow: visible;
}

.timeline-marker {
    position: relative;
    flex-shrink: 0;
}

.marker-icon {
    width: 32px;
    height: 32px;
    background: #eff6ff;
    border: 2px solid #dbeafe;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #3b82f6;
    position: relative;
    z-index: 1;
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
    flex-shrink: 0;
}

.timeline-item.status_change .marker-icon {
    background: #fef3c7;
    border-color: #fde68a;
    color: #f59e0b;
}

/* Hub Status Colors in Timeline */
.timeline-item.hub_status .marker-icon,
.timeline-item.hub_status_change .marker-icon {
    background: #e0e7ff;
    border-color: #c7d2fe;
    color: #6366f1;
}

.timeline-item.order_created .marker-icon {
    background: #dbeafe;
    border-color: #bfdbfe;
    color: #2563eb;
}

.activity-info .hub-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

/* Hub Status Specific Colors */
.hub-status-badge.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.hub-status-badge.status-in-production {
    background: #dbeafe;
    color: #1e40af;
}

.hub-status-badge.status-cutting {
    background: #e0e7ff;
    color: #4338ca;
}

.hub-status-badge.status-completed {
    background: #dcfce7;
    color: #166534;
}

.hub-status-badge.status-shipped {
    background: #f3e8ff;
    color: #6b21a8;
}

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

.hub-status-badge.status-on-hold {
    background: #fee2e2;
    color: #991b1b;
}

.timeline-item.note_added .marker-icon {
    background: #ede9fe;
    border-color: #ddd6fe;
    color: #8b5cf6;
}

.timeline-item.production_step .marker-icon {
    background: #dcfce7;
    border-color: #bbf7d0;
    color: #22c55e;
}

.timeline-line {
    position: absolute;
    left: 50%;
    top: 32px;
    bottom: -16px;
    width: 2px;
    background: #e0e6ed;
    transform: translateX(-50%);
    z-index: 0;
}

.timeline-content {
    flex: 1;
    background: #f8fafc;
    border-radius: 8px;
    padding: 12px 14px;
    border: 1px solid #e2e8f0;
    min-height: 60px;
    position: relative;
    z-index: 2;
    overflow: visible;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.timeline-title,
.timeline-content h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50 !important;
}

.timeline-time {
    font-size: 11px;
    color: #64748b !important;
    white-space: nowrap;
}

.timeline-description,
.timeline-content p {
    font-size: 13px;
    color: #475569 !important;
    line-height: 1.4;
    margin: 4px 0;
}

.timeline-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #64748b !important;
    margin-top: 6px;
}

.timeline-meta span {
    color: #64748b !important;
}

.timeline-user {
    font-weight: 500;
}

.timeline-date {
    text-align: right;
}

.timeline-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.timeline-meta svg {
    opacity: 0.5;
}

.empty-timeline,
.timeline-error,
.no-steps,
.steps-error {
    text-align: center;
    padding: 40px;
    color: #64748b;
    font-size: 14px;
}

/* Responsive adjustments for iPad */
@media (max-width: 1024px) {
    .process-steps-section,
    .activity-section {
        padding: 16px;
    }
    
    .steps-header,
    .activity-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .activity-timeline {
        max-height: 300px;
    }
}