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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 2em;
    font-weight: 600;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1em;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #4caf50;
    animation: pulse 2s infinite;
}

.status-dot.running {
    background: #ff9800;
}

.status-dot.stopped {
    background: #f44336;
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.main-content {
    padding: 30px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.control-panel,
.functions-panel {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.control-panel {
    grid-column: 1 / -1;
}

.functions-panel {
    grid-column: 1 / -1;
}

h2 {
    margin-bottom: 20px;
    color: #667eea;
    font-size: 1.5em;
}

.button-group {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

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

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #5568d3;
}

.btn-danger {
    background: #f44336;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #d32f2f;
}

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

.btn-secondary:hover {
    background: #5a6268;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85em;
}

.status-info {
    background: white;
    padding: 15px;
    border-radius: 6px;
    margin-top: 15px;
}

.status-info p {
    margin: 8px 0;
    font-size: 0.95em;
}

.status-info span {
    font-weight: 600;
    color: #667eea;
}

.logs-panel {
    grid-column: 1 / -1;
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.logs-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.logs-container {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 20px;
    border-radius: 6px;
    height: 400px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.6;
}

.log-entry {
    margin-bottom: 5px;
    padding: 4px 0;
    border-bottom: 1px solid #333;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.error {
    color: #f48771;
}

.log-entry.success {
    color: #4ec9b0;
}

.log-entry.warning {
    color: #dcdcaa;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 20px;
    top: 15px;
}

.close:hover {
    color: #000;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1em;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 25px;
}

/* Scrollbar styling */
.logs-container::-webkit-scrollbar {
    width: 8px;
}

.logs-container::-webkit-scrollbar-track {
    background: #2d2d2d;
}

.logs-container::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

.logs-container::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* Orders Panel */
.orders-panel {
    grid-column: 1 / -1;
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    margin-top: 20px;
}

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

.orders-header h2 {
    margin: 0;
    color: #667eea;
}

.orders-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95em;
    min-width: 200px;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.orders-container {
    background: white;
    border-radius: 6px;
    overflow: hidden;
    max-height: 600px;
    overflow-y: auto;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
}

.orders-table thead {
    background: #667eea;
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.orders-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.orders-table td {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 0.9em;
}

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

.orders-table tbody tr:hover {
    background-color: #f5f5f5;
}

.orders-table tbody tr.expanded {
    background-color: #f0f0f0;
}

.orders-table tbody tr.expanded td {
    border-bottom: 2px solid #667eea;
}

.order-details {
    display: none;
    background: #fafafa;
    padding: 20px;
}

.order-details.expanded {
    display: block;
}

.order-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.detail-item {
    padding: 10px;
    background: white;
    border-radius: 4px;
    border-left: 3px solid #667eea;
}

.detail-item label {
    display: block;
    font-weight: 600;
    color: #667eea;
    font-size: 0.85em;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.detail-item .value {
    color: #333;
    font-size: 0.95em;
}

.items-list {
    margin-top: 15px;
}

.items-list h4 {
    margin-bottom: 10px;
    color: #667eea;
}

.item-row {
    display: grid;
    grid-template-columns: 1fr 2fr 80px 100px 100px;
    gap: 10px;
    padding: 10px;
    background: white;
    border-radius: 4px;
    margin-bottom: 8px;
    border-left: 3px solid #4caf50;
    font-size: 0.9em;
}

.item-row-header {
    font-weight: 600;
    color: #667eea;
    border-left-color: #667eea;
    background: #f0f0f0;
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
}

.status-badge.open {
    background: #4caf50;
    color: white;
}

.status-badge.awaiting-payment {
    background: #ff9800;
    color: white;
}

.status-badge.awaiting-fulfilment {
    background: #2196f3;
    color: white;
}

.order-details-row {
    display: none;
}

.order-details-row.active {
    display: table-row;
}

/* Price badges */
.shipping-prices {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

.price-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 500;
    white-space: nowrap;
}

.price-badge.dhl {
    background: #ffc107;
    color: #000;
}

.price-badge.lp {
    background: #4caf50;
    color: white;
}

.price-badge.parcelstar {
    background: #2196f3;
    color: white;
}

.price-badge.scanning {
    background: #9e9e9e;
    color: white;
    animation: pulse 1.5s infinite;
}

/* Scan button */
.btn-scan {
    padding: 6px 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-scan:hover {
    background: #5568d3;
}

.btn-scan:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Has changes indicator */
.orders-table tbody tr.has-changes {
    border-left: 4px solid #ff9800;
}

.orders-table tbody tr.has-changes td:first-child {
    padding-left: 8px;
}

/* Full width detail item */
.detail-item.full-width {
    grid-column: 1 / -1;
}

.price-section {
    margin-bottom: 10px;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 4px;
    border-left: 3px solid #667eea;
}

.price-section strong {
    color: #667eea;
    display: block;
    margin-bottom: 5px;
}

.price-section small {
    color: #666;
    font-size: 0.85em;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .button-grid {
        grid-template-columns: 1fr;
    }
    
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .orders-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .orders-controls {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .search-input {
        width: 100%;
    }
    
    .orders-table {
        font-size: 0.8em;
    }
    
    .orders-table th,
    .orders-table td {
        padding: 8px;
    }
    
    .order-details-grid {
        grid-template-columns: 1fr;
    }
    
    .item-row {
        grid-template-columns: 1fr;
        gap: 5px;
    }
}
