/* =============================================================================
   Order Picking - Professional UI Styles
   ============================================================================= */

:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --primary-light: #34d399;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #1e293b;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: 200ms ease;

    /* Trolley colors */
    --trolley-1: #ef4444;
    --trolley-2: #3b82f6;
    --trolley-3: #10b981;
    --trolley-4: #f59e0b;
    --trolley-5: #8b5cf6;
    --trolley-6: #06b6d4;
    --trolley-7: #ec4899;
    --trolley-8: #84cc16;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    min-height: 100vh;
}

/* =============================================================================
   Main Container
   ============================================================================= */

.main-container {
    padding: 0 1rem 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* =============================================================================
   Notification Area
   ============================================================================= */

.notification-area {
    position: fixed;
    top: 4rem;
    right: 1rem;
    z-index: 1050;
    max-width: 400px;
}

.notification-area .alert {
    box-shadow: var(--shadow-lg);
    border: none;
    border-radius: var(--radius-md);
}

/* =============================================================================
   Header Bar
   ============================================================================= */

.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-left {
    flex: 0 0 auto;
}

.header-left h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
    letter-spacing: -0.02em;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-title i {
    color: var(--primary);
}

.header-center {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    justify-content: center;
}

.header-right {
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
.btn-solve {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-md);
}

.btn-solve:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, var(--primary-dark) 0%, #047857 100%);
}

.btn-stop {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-md);
}

.btn-stop:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-settings, .btn-analyze {
    background: white;
    border: 1px solid var(--gray-200);
    color: var(--gray-600);
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-settings:hover, .btn-analyze:hover {
    background: var(--gray-50);
    color: var(--primary);
    border-color: var(--primary);
}

/* Score Display */
.score-display {
    background: white;
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
}

.score-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
}

.score-value {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'SF Mono', 'Consolas', monospace;
    color: var(--gray-800);
}

.score-display.improved {
    animation: scoreFlash 0.5s ease-out;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    border-color: var(--primary);
}

.score-display.improved .score-label,
.score-display.improved .score-value {
    color: white;
}

@keyframes scoreFlash {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); box-shadow: 0 0 20px rgba(16, 185, 129, 0.5); }
    100% { transform: scale(1); }
}

/* Solving Indicator */
.solving-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
    font-weight: 500;
}

.solving-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* =============================================================================
   Settings Panel
   ============================================================================= */

.settings-panel {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-200);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    align-items: end;
}

.setting-item label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.setting-item label i {
    color: var(--primary);
}

.setting-item label .badge {
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-left: auto;
}

.setting-item input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
    height: 6px;
    cursor: pointer;
}

.btn-generate {
    background: linear-gradient(135deg, var(--info) 0%, #2563eb 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    width: 100%;
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* =============================================================================
   Content Area
   ============================================================================= */

.content-area {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Stats Sidebar */
.stats-sidebar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stat-card {
    background: white;
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all var(--transition);
}

.stat-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
}

.stat-card .stat-info {
    display: flex;
    flex-direction: column;
}

.stat-card .stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Canvas Area */
.canvas-area {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    position: relative;
}

#warehouseContainer {
    position: relative;
    width: 100%;
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

#warehouseCanvas {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Legend Overlay */
#legendOverlay {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-200);
    min-width: 140px;
    z-index: 10;
}

.legend-header {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-header i {
    color: var(--primary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    font-size: 0.85rem;
    color: var(--gray-600);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.legend-item:hover {
    background: var(--gray-100);
    padding-left: 0.5rem;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
}

.legend-text {
    flex: 1;
    font-weight: 500;
}

.legend-distance {
    font-size: 0.75rem;
    color: var(--gray-400);
    font-family: 'SF Mono', monospace;
}

/* =============================================================================
   Trolley Section
   ============================================================================= */

.trolley-section {
    margin-top: 1rem;
}

.section-header {
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.section-header h2 i {
    color: var(--primary);
}

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

/* Trolley Card */
.trolley-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    transition: all var(--transition);
    cursor: pointer;
}

.trolley-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.trolley-card-header {
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--gray-100);
}

.trolley-color-badge {
    width: 12px;
    height: 40px;
    border-radius: 4px;
    flex-shrink: 0;
}

.trolley-card-info {
    flex: 1;
}

.trolley-card-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--gray-800);
}

.trolley-card-stats {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.trolley-capacity-bar {
    width: 80px;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.trolley-capacity-fill {
    height: 100%;
    border-radius: 4px;
    transition: width var(--transition);
}

.trolley-capacity-fill.low { background: var(--primary); }
.trolley-capacity-fill.medium { background: var(--warning); }
.trolley-capacity-fill.high { background: var(--danger); }

.trolley-card-body {
    padding: 1rem;
    background: var(--gray-50);
    max-height: 200px;
    overflow-y: auto;
}

.trolley-items-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.trolley-item {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.trolley-item-number {
    background: var(--primary);
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
}

.trolley-empty {
    color: var(--gray-400);
    font-style: italic;
    padding: 1rem;
    text-align: center;
}

/* =============================================================================
   3D Bucket View Modal
   ============================================================================= */

.bucket-modal .modal-body {
    padding: 0;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    min-height: 400px;
}

#bucketViewCanvas {
    width: 100%;
    height: 400px;
    display: block;
}

.bucket-modal-stats {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    padding: 1rem;
    display: flex;
    justify-content: space-around;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.bucket-stat {
    text-align: center;
    color: white;
}

.bucket-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.bucket-stat-label {
    font-size: 0.75rem;
    opacity: 0.7;
    text-transform: uppercase;
}

/* =============================================================================
   Modal Styling
   ============================================================================= */

.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 1.5rem;
}

.modal-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-title i {
    color: var(--primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--gray-200);
    padding: 1rem 1.5rem;
}

/* Score Analysis */
.constraint-group {
    margin-bottom: 1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.constraint-header {
    background: var(--gray-50);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.constraint-name {
    font-weight: 600;
    color: var(--gray-800);
}

.constraint-score {
    font-family: 'SF Mono', monospace;
    font-size: 0.9rem;
}

.constraint-score.hard { color: var(--danger); }
.constraint-score.soft { color: var(--warning); }

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 768px) {
    .header-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .header-center {
        order: 3;
        justify-content: center;
    }

    .header-right {
        position: absolute;
        right: 1rem;
        top: 1rem;
    }

    .content-area {
        grid-template-columns: 1fr;
    }

    .stats-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .stat-card {
        flex: 1;
        min-width: 120px;
    }

    .trolley-cards-grid {
        grid-template-columns: 1fr;
    }

    #legendOverlay {
        position: relative;
        top: auto;
        right: auto;
        margin: 1rem;
    }
}

/* =============================================================================
   Animations
   ============================================================================= */

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

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

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* Value change animation */
.value-changed {
    animation: valueChange 0.5s ease-out;
}

@keyframes valueChange {
    0% { transform: scale(1); color: var(--primary); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); color: inherit; }
}
