/* Maschinenplanung Plugin Styles */

.maschinenplanung-container {
    background: #f5f5f5;
    padding: 10px;
    margin: 10px 0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.planning-board {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 400px;
}

/* Machine Line Styles */
.machine-line {
    background: #ffffff;
    border: 2px solid #ddd;
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 15px; /* Add space between machine lines to prevent overlap */
    transition: all 0.3s ease;
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: stretch;
    position: relative; /* For proper z-index stacking */
}

/* Special styling for OPEN ORDERS machine (ID 0 - Offen/Unassigned) */
.machine-line[data-machine-id="0"],
.machine-line.machine-line-offen {
    background: linear-gradient(135deg, #fff8e1 0%, #fffbf0 100%);
    border: 2px dashed #ff9800;
    border-radius: 8px;
}

.machine-line[data-machine-id="0"] .machine-header,
.machine-line.machine-line-offen .machine-header {
    border-right-color: #ff9800;
}

.machine-line[data-machine-id="0"] .machine-header h2,
.machine-line.machine-line-offen .machine-header h2 {
    color: #e65100;
}

.machine-line[data-machine-id="0"] .machine-description,
.machine-line.machine-line-offen .machine-description {
    color: #f57c00;
    font-weight: 500;
}

/* Special styling for OPEN ORDERS machine (ID 1) */
.machine-line[data-machine-id="1"] {
    background: linear-gradient(135deg, #fff8e1 0%, #fffbf0 100%);
    border: 2px dashed #ff9800;
    border-radius: 8px;
}

.machine-line[data-machine-id="1"] .machine-header {
    border-right-color: #ff9800;
}

.machine-line[data-machine-id="1"] .machine-header h2 {
    color: #e65100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.machine-line[data-machine-id="1"] .machine-header h2::before {
    content: "📋";
    font-size: 16px;
    writing-mode: horizontal-tb;
    transform: rotate(0deg);
}

.machine-line[data-machine-id="1"] .machine-description {
    color: #f57c00;
    font-weight: 500;
}

.machine-line.drag-over {
    background: #e8f4f8;
    border-color: #2271b1;
    box-shadow: 0 4px 8px rgba(34, 113, 177, 0.2);
}

.machine-header {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    border-right: 2px solid #2271b1;
    border-bottom: none;
    padding-right: 8px;
    padding-bottom: 0;
    margin-right: 10px;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-width: 35px;
    flex-shrink: 0;
}

.machine-header h2 {
    margin: 0;
    color: #1d2327;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.machine-description {
    margin: 5px 0 0 0;
    color: #646970;
    font-size: 10px;
    font-style: italic;
    white-space: nowrap;
}

/* Orders Container */
.orders-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 80px;
    padding: 6px;
    background: #f9f9f9;
    border-radius: 4px;
    align-items: flex-start;
    justify-content: flex-start;
    flex-direction: row;
    flex: 1;
    overflow-x: auto; /* Allow horizontal scrolling for large cards */
    overflow-y: visible;
}

.orders-container.empty {
    background: repeating-linear-gradient(
        45deg,
        #f0f0f0,
        #f0f0f0 10px,
        #f9f9f9 10px,
        #f9f9f9 20px
    );
    border: 2px dashed #ddd;
}

/* Order Card Styles */
.order-card {
    background: #ffffff;
    border: 2px solid #2271b1;
    border-radius: 6px;
    padding: 8px;
    cursor: move;
    position: relative;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    min-width: 120px; /* Minimum width to fit typical part numbers without wrapping */
    max-width: 800px; /* Maximum width matches timeline scale */
    min-height: 120px; /* Changed from height to min-height to allow expansion */
    max-height: none; /* Allow cards to grow if needed */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: visible; /* Ensure content isn't clipped */
    touch-action: none; /* Prevent browser handling of touch gestures (scrolling) */
}

.order-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transform: translateY(-2px);
}

.order-card.ui-draggable-dragging {
    opacity: 0.8;
    cursor: grabbing;
    transform: rotate(3deg);
    z-index: 1000;
}

/* Priority-based colors */
.order-card.priority-high {
    border-color: #dc3232;
    background: linear-gradient(to bottom, #ffffff, #ffebeb);
}

.order-card.priority-normal {
    border-color: #2271b1;
    background: linear-gradient(to bottom, #ffffff, #e8f4f8);
}

.order-card.priority-low {
    border-color: #72aee6;
    background: linear-gradient(to bottom, #ffffff, #f0f6fc);
}

/* Order Card Content */
.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
    padding: 2px 4px 3px 4px;
    border-bottom: 1px solid #ddd;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.order-header:hover {
    background-color: rgba(34, 113, 177, 0.1);
}

.order-header:hover .order-title {
    color: #2271b1;
}

.order-title {
    font-weight: 600;
    font-size: 12px;
    color: #1d2327;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: fit-content;
}

.priority-badge {
    padding: 1px 5px;
    border-radius: 8px;
    font-size: 8px;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.priority-badge.priority-high {
    background: #dc3232;
    color: #ffffff;
}

.priority-badge.priority-normal {
    background: #2271b1;
    color: #ffffff;
}

.priority-badge.priority-low {
    background: #72aee6;
    color: #ffffff;
}

.order-body {
    font-size: 10px;
    color: #50575e;
    line-height: 1.2;
    flex: 0 0 auto;
}

.order-body p {
    margin: 1px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.order-body strong {
    color: #1d2327;
}

.order-actions {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    gap: 3px;
}

.order-card:hover .order-actions {
    opacity: 1;
}

.order-copy-btn,
.order-edit-btn {
    padding: 2px 6px !important;
    min-height: 0 !important;
    line-height: 1 !important;
    background: #2271b1 !important;
    border-color: #2271b1 !important;
    color: #fff !important;
}

.order-copy-btn {
    background: #50575e !important;
    border-color: #50575e !important;
}

.order-copy-btn:hover {
    background: #3c434a !important;
    border-color: #3c434a !important;
}

.order-edit-btn:hover {
    background: #135e96 !important;
    border-color: #135e96 !important;
}

.order-copy-btn .dashicons,
.order-edit-btn .dashicons {
    width: 14px;
    height: 14px;
    font-size: 14px;
    line-height: 1;
}

.order-copy-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.order-handle {
    text-align: center;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    color: #8c8f94;
    cursor: move;
    display: none;
}

.order-handle .dashicons {
    font-size: 12px;
    width: 12px;
    height: 12px;
}

/* Legend Styles */
.maschinenplanung-legend {
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    margin-top: 20px;
}

.maschinenplanung-legend h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #1d2327;
}

.legend-items {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #50575e;
}

.legend-controls {
    border-top: 1px solid #e0e0e0;
    padding-top: 15px;
    margin-top: 15px;
}

.legend-info {
    font-size: 12px;
    color: #646970;
    margin: 8px 0 0 0;
    line-height: 1.4;
}

.legend-info:first-child {
    margin-top: 0;
}

.legend-info strong {
    color: #1d2327;
}

.legend-info em {
    color: #2271b1;
    font-style: normal;
    font-weight: 600;
}

/* Drag placeholder */
.ui-sortable-placeholder {
    border: 2px dashed #2271b1;
    background: #e8f4f8;
    visibility: visible !important;
    border-radius: 6px;
    margin: 0 7.5px;
}

/* Animations */
@keyframes cardDrop {
    0% {
        transform: scale(0.95);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.order-card.just-dropped {
    animation: cardDrop 0.3s ease;
}

/* Timeline Styles */
.timeline-container {
    background: #ffffff;
    border: 2px solid #2271b1;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 4px 8px rgba(34, 113, 177, 0.1);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #2271b1 0%, #135e96 100%);
    color: #ffffff;
    border-radius: 6px 6px 0 0;
}

.timeline-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.timeline-header .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.timeline-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.timeline-controls .button {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    font-size: 12px;
    padding: 4px 8px;
    height: auto;
}

.timeline-controls .button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.timeline-date-selector {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #1d2327;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
}

.timeline-wrapper {
    position: relative;
    background: #f8f9fa;
}

.timeline-axis {
    position: relative;
    border-bottom: 2px solid #2271b1;
    background: #ffffff;
}

.timeline-labels {
    display: flex;
    height: 40px;
    position: relative;
    border-bottom: 1px solid #ddd;
}

.timeline-label {
    position: absolute;
    font-size: 11px;
    font-weight: 600;
    color: #1d2327;
    padding: 8px 4px;
    text-align: center;
    border-right: 1px solid #e0e0e0;
    min-width: 60px;
    background: #f8f9fa;
}

.timeline-label.hour-marker {
    color: #2271b1;
    font-weight: 700;
    background: #e8f4f8;
}

.timeline-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    pointer-events: none;
}

.timeline-grid-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #e0e0e0;
}

.timeline-grid-line.hour-line {
    background: #2271b1;
    width: 2px;
}

.timeline-machines {
    max-height: 400px;
    overflow-y: auto;
}

.timeline-machine-row {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    min-height: 50px;
    align-items: center;
}

.timeline-machine-row:last-child {
    border-bottom: none;
}

.timeline-machine-label {
    width: 120px;
    padding: 10px 15px;
    font-weight: 600;
    font-size: 12px;
    color: #1d2327;
    background: #f8f9fa;
    border-right: 2px solid #2271b1;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.timeline-machine-track {
    flex: 1;
    position: relative;
    height: 50px;
    background: #ffffff;
}

/* Timeline Sub-Order Blocks */
.timeline-sub-order-block {
    position: absolute;
    top: 5px;
    height: 40px;
    border-radius: 6px;
    border: 2px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 600;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    min-width: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.25);
    opacity: 0.9;
}

.timeline-sub-order-block:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
    z-index: 10;
    opacity: 1;
}

.timeline-sub-order-block.priority-high {
    background: linear-gradient(135deg, #dc3232 0%, #a02222 100%);
    border-color: #a02222;
}

.timeline-sub-order-block.priority-normal {
    background: linear-gradient(135deg, #2271b1 0%, #135e96 100%);
    border-color: #135e96;
}

.timeline-sub-order-block.priority-low {
    background: linear-gradient(135deg, #72aee6 0%, #4f94d4 100%);
    border-color: #4f94d4;
}

/* Timeline Order Blocks (fallback for orders without sub-orders) */
.timeline-order-block {
    position: absolute;
    top: 5px;
    height: 40px;
    border-radius: 4px;
    border: 2px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    min-width: 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.timeline-order-block:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    z-index: 10;
}

.timeline-order-block.priority-high {
    background: linear-gradient(135deg, #dc3232 0%, #a02222 100%);
    border-color: #a02222;
}

.timeline-order-block.priority-normal {
    background: linear-gradient(135deg, #2271b1 0%, #135e96 100%);
    border-color: #135e96;
}

.timeline-order-block.priority-low {
    background: linear-gradient(135deg, #72aee6 0%, #4f94d4 100%);
    border-color: #4f94d4;
}

/* Timeline hidden state */
.timeline-container.hidden {
    display: none;
}

/* Current time indicator */
.timeline-current-time {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #dc3232;
    z-index: 100;
    box-shadow: 0 0 4px rgba(220, 50, 50, 0.5);
}

.timeline-current-time::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    width: 13px;
    height: 13px;
    background: #dc3232;
    border-radius: 50%;
    border: 2px solid #ffffff;
}

/* Timeline highlight effects */
.order-card.timeline-highlight {
    box-shadow: 0 0 15px rgba(34, 113, 177, 0.6) !important;
    border-color: #2271b1 !important;
    transform: scale(1.02);
    z-index: 100;
    position: relative;
}

.timeline-order-block.selected,
.timeline-sub-order-block.selected {
    z-index: 20;
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}

/* Sub-order highlight from timeline */
.sub-order-block.timeline-sub-highlight {
    border: 3px solid #ffeb3b !important;
    box-shadow: 0 0 0 3px rgba(255, 235, 59, 0.4) !important;
    transform: scale(1.15);
    z-index: 15;
    position: relative;
    animation: timelineSubOrderPulse 1s ease-in-out infinite alternate;
}

@keyframes timelineSubOrderPulse {
    0% {
        box-shadow: 0 0 0 3px rgba(255, 235, 59, 0.4);
    }
    100% {
        box-shadow: 0 0 0 6px rgba(255, 235, 59, 0.8);
    }
}

/* Timeline loading state */
.timeline-loading {
    text-align: center;
    padding: 40px;
    color: #646970;
    font-style: italic;
}

/* Timeline empty state */
.timeline-empty {
    text-align: center;
    padding: 30px;
    color: #646970;
}

.timeline-empty .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #8c8f94;
    margin-bottom: 10px;
}

/* Responsive Design */
@media screen and (max-width: 1200px) {
    .order-card {
        min-width: 80px; /* Keep consistent with timeline scale */
        max-width: 600px; /* Reduce max width on smaller screens */
    }
    
    .timeline-machine-label {
        width: 100px;
        font-size: 11px;
    }
}

@media screen and (max-width: 768px) {
    .planning-board {
        gap: 15px;
    }
    
    .orders-container {
        flex-direction: column;
        overflow-x: visible; /* Allow normal wrapping on mobile */
    }
    
    .order-card {
        width: 100% !important;
        min-width: auto;
        max-width: none; /* Remove max-width constraint on mobile */
    }
    
    .legend-items {
        flex-direction: column;
        gap: 10px;
    }
    
    .timeline-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .timeline-controls {
        justify-content: center;
    }
    
    .timeline-machine-label {
        width: 80px;
        font-size: 10px;
        padding: 8px 10px;
    }
    
    .timeline-order-block,
    .timeline-sub-order-block {
        font-size: 8px;
        height: 35px;
        top: 7px;
        min-width: 15px;
    }
}

/* Selected for move state */
.order-card.selected-for-move {
    border-color: #e65100 !important;
    box-shadow: 0 0 0 4px rgba(230, 81, 0, 0.3) !important;
    transform: scale(1.02);
    z-index: 100;
    background: #fff8e1 !important;
}

.order-card.selected-for-move .order-handle {
    color: #e65100;
}

/* Move mode active state */
body.move-mode-active .orders-container {
    cursor: pointer;
    background: rgba(34, 113, 177, 0.05);
    border: 2px dashed #2271b1;
}

body.move-mode-active .orders-container:hover {
    background: rgba(34, 113, 177, 0.1);
}

body.move-mode-active .order-card:not(.selected-for-move) {
    opacity: 0.7;
    cursor: pointer;
}

body.move-mode-active .order-card:not(.selected-for-move):hover {
    opacity: 1;
    border-color: #e65100;
}

/* Utility classes */
.maschinenplanung-container .wrap h1 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.maschinenplanung-container .wrap h1 .dashicons {
    color: #2271b1;
}

/* Sub-Orders Styles */
.sub-orders-container {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid #ddd;
    overflow: visible; /* Ensure sub-orders are visible */
    z-index: 1; /* Keep above other content */
    position: relative;
}

.sub-orders-header {
    font-size: 11px;
    color: #666;
    margin-bottom: 5px;
    font-weight: 600;
}

.sub-orders-line {
    display: flex;
    gap: 3px;
    flex-wrap: nowrap;
    align-items: center;
    max-width: 100%; /* Prevent overflow beyond card width */
    overflow: hidden; /* Hide overflow */
}

.sub-order-block {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    max-width: 120px; /* Prevent blocks from getting too wide */
    flex-shrink: 1; /* Allow blocks to shrink */
    padding: 3px 5px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 9px; /* Slightly smaller for longer text */
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    position: relative;
    user-select: none;
    color: #ffffff; /* Default white text for contrast */
    text-shadow: 0 1px 2px rgba(0,0,0,0.3); /* Add text shadow for better readability */
    white-space: nowrap; /* Prevent text wrapping */
    overflow: hidden; /* Hide overflow */
    text-overflow: ellipsis; /* Show ... for long text */
    word-break: break-word; /* Allow breaking long words if needed */
}

.sub-order-block:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    border-color: rgba(0,0,0,0.2);
    filter: brightness(1.1);
}

.sub-order-block:active {
    transform: scale(0.95);
}

.sub-order-details {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    margin-top: 0;
    font-size: 9px;
    font-weight: 500;
    opacity: 0.95;
    line-height: 1;
}

.sub-order-per-piece {
    white-space: nowrap;
    font-weight: 600;
    line-height: 1;
}

.sub-order-total {
    white-space: nowrap;
    font-weight: 700;
    font-size: 10px;
    line-height: 1;
}

/* Completed State - Red with strikethrough */
.sub-order-block.completed {
    background: #dc3232 !important;
    color: #ffffff !important;
    position: relative;
}

.sub-order-block.completed::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: bold;
    opacity: 0.5;
}

.sub-order-block.completed:hover {
    background: #a02222 !important;
}

/* Selected State - When sub-order is clicked to show duration */
.sub-order-block.selected {
    border: 3px solid #2271b1 !important;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.3);
    transform: scale(1.1);
    z-index: 10;
    position: relative;
}

.sub-order-block.selected:hover {
    border-color: #135e96 !important;
}

/* Animation for status change */
@keyframes statusToggle {
    0% {
        transform: scale(1) rotate(0deg);
    }
    50% {
        transform: scale(1.3) rotate(180deg);
    }
    100% {
        transform: scale(1) rotate(360deg);
    }
}

.sub-order-block.status-changing {
    animation: statusToggle 0.4s ease;
}

/* Loading state */
.maschinenplanung-loading {
    text-align: center;
    padding: 40px;
    color: #646970;
}

.maschinenplanung-loading:before {
    content: '';
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2271b1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Duration Tooltip */
.duration-tooltip {
    position: absolute;
    background: rgba(0,0,0,0.9);
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    z-index: 1000;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    animation: tooltipFadeIn 0.2s ease;
}

@keyframes tooltipFadeIn {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Visual hints for interactive elements */
.order-card .sub-orders-header small::after {
    content: " (Klicken = Dauer, Doppelklick = Status)";
    color: #2271b1;
    font-style: italic;
    font-weight: normal;
    font-size: 9px;
}

.order-header .order-title::after {
    content: " ↻";
    opacity: 0;
    color: #2271b1;
    font-size: 10px;
    transition: opacity 0.2s ease;
    margin-left: 4px;
}

.order-header:hover .order-title::after {
    opacity: 1;
}

/* New Order Form Styles */
.maschinenplanung-form {
    background: #ffffff;
    padding: 0;
}

.form-container {
    max-width: 900px;
    margin: 20px 0;
}

.form-section {
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 20px;
}

.form-section h2 {
    margin-top: 0;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #2271b1;
    color: #1d2327;
    font-size: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #1d2327;
}

.form-group .required {
    color: #dc3232;
}

.form-group input[type="text"],
.form-group input[type="datetime-local"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.form-group input[readonly] {
    background: #f0f0f1;
    color: #646970;
    cursor: not-allowed;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 1px #2271b1;
}

.form-group .description {
    margin: 5px 0 0 0;
    color: #646970;
    font-size: 13px;
    font-style: italic;
}

/* Autocomplete */
.article-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #8c8f94;
    border-top: none;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f1;
    transition: background-color 0.2s;
}

.autocomplete-item:hover {
    background-color: #f6f7f7;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item-title {
    font-weight: 600;
    color: #1d2327;
    margin-bottom: 3px;
}

.autocomplete-item-meta {
    font-size: 12px;
    color: #646970;
}

.autocomplete-item-label {
    display: inline-block;
    background: #f0f0f1;
    padding: 2px 6px;
    border-radius: 3px;
    margin-right: 5px;
    font-size: 11px;
}

.autocomplete-no-results {
    padding: 10px 12px;
    color: #646970;
    font-style: italic;
}

/* Sub-Orders List */
.sub-orders-list {
    margin: 20px 0;
}

.sub-order-item {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
    position: relative;
    transition: all 0.2s ease;
}

.sub-order-item:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.sub-order-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ddd;
}

.sub-order-item-header h4 {
    margin: 0;
    font-size: 15px;
    color: #1d2327;
}

.remove-sub-order {
    color: #dc3232;
    cursor: pointer;
    padding: 5px 10px;
    border: 1px solid #dc3232;
    border-radius: 4px;
    background: #fff;
    transition: all 0.2s ease;
}

.remove-sub-order:hover {
    background: #dc3232;
    color: #fff;
}

.sub-order-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.sub-order-field {
    display: flex;
    flex-direction: column;
}

.sub-order-field label {
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 13px;
    color: #1d2327;
}

.sub-order-field select,
.sub-order-field input {
    padding: 8px 12px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 14px;
}

.sub-order-field select:focus,
.sub-order-field input:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 1px #2271b1;
}

.sub-order-summary {
    background: #e8f4f8;
    border: 1px solid #2271b1;
    border-radius: 4px;
    padding: 15px;
    margin-top: 20px;
    font-size: 16px;
    color: #1d2327;
}

.sub-order-summary strong {
    color: #2271b1;
}

.sub-order-summary #total-duration {
    font-weight: 700;
    font-size: 18px;
    color: #2271b1;
}

/* Empty State */
.sub-orders-empty {
    text-align: center;
    padding: 40px 20px;
    color: #646970;
    background: #f9f9f9;
    border: 2px dashed #ddd;
    border-radius: 6px;
}

.sub-orders-empty .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #8c8f94;
    margin-bottom: 10px;
}

/* Form Actions */
.form-actions {
    background: #f9f9f9;
    border-top: 1px solid #ddd;
    padding: 20px 25px;
    margin: 0 -20px -20px -20px;
    border-radius: 0 0 8px 8px;
    display: flex;
    gap: 10px;
}

.button-large {
    padding: 8px 20px;
    font-size: 14px;
    height: auto;
}

.button .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    margin-right: 5px;
    vertical-align: middle;
}

/* Article Number Validation */
input[name="article_number"]:invalid {
    border-color: #dc3232;
}

input[name="article_number"]:valid {
    border-color: #46b450;
}

/* Responsive Design for Form */
@media screen and (max-width: 768px) {
    .form-container {
        margin: 10px 0;
    }
    
    .form-section {
        padding: 15px;
    }
    
    .sub-order-fields {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .button-large {
        width: 100%;
    }
}
