:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #0dcaf0;
    --light-bg: #f8f9fa;
    --border-color: #dee2e6;
    --text-color: #212529;
    --text-muted: #6c757d;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
    --border-radius: 8px;
    --transition: all 0.2s ease-in-out;
}

/* External Order Form Container */
#fieldset-externe-bestellung {
    background: white;
    border: none !important;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 0;
    margin: 2rem 0;
    overflow: hidden;
}

#fieldset-externe-bestellung legend {
    background: linear-gradient(135deg, var(--info-color), #0aa6d6);
    color: white;
    margin: 0;
    padding: 1.5rem 2rem;
    width: 100%;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    border-radius: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Form Styling */
#externe-bestellung {
    padding: 2rem;
}

/* Form Groups */
#externe-bestellung .form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

#externe-bestellung .form-group:last-of-type {
    margin-bottom: 0;
    margin-top: 2rem;
}

/* Labels */
#externe-bestellung label {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    display: block;
    font-size: 0.9rem;
}

/* Required Field Indicator */
#externe-bestellung label[for="materialnr"]::after,
#externe-bestellung label[for="geschaeftsbereich"]::after,
#externe-bestellung label[for="beschreibung"]::after,
#externe-bestellung label[for="amount"]::after,
#kreditkarte-typ-group > label::after,
#wartungspool-typ-group > label::after {
    content: " *";
    color: var(--danger-color);
    font-weight: bold;
}

/* Form Controls */
#externe-bestellung .form-control,
#externe-bestellung select.form-control {
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    transition: var(--transition);
    background: white;
}

#externe-bestellung .form-control:focus,
#externe-bestellung select.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
    outline: none;
}

#externe-bestellung .form-control:invalid {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.15);
}

/* Textarea */
#externe-bestellung textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Amount Group Styling */
#amount-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

#amount-group select {
    flex: 0 0 100px;
}

#amount-group input {
    flex: 1;
    min-width: 120px;
}

#amount-group select:last-child {
    flex: 0 0 150px;
}

/* Chosen Select Styling */
.chosen-container {
    width: 100% !important;
}

.chosen-container-single .chosen-single {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    height: 50px;
    line-height: 46px;
    padding: 0 1rem;
    font-size: 0.95rem;
    transition: var(--transition);
}

.chosen-container-single .chosen-single:focus,
.chosen-container-active.chosen-with-drop .chosen-single {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.chosen-container-single .chosen-single div {
    width: 24px;
    height: 46px;
}

.chosen-container-single .chosen-single div b {
    background-position: 6px 50%;
}

.chosen-drop {
    border: 2px solid var(--primary-color);
    border-top: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    box-shadow: var(--shadow);
}

/* Checkbox Styling */
#externe-bestellung input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
    margin-right: 0.5rem;
}

#externe-bestellung label[for="preisanfrage"] {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
}

/* Button Styling */
#externe-bestellung .btn {
    padding: 0.75rem 2rem;
    font-weight: 600;
    border-radius: var(--border-radius);
    border: none;
    transition: var(--transition);
    text-transform: none;
    font-size: 0.95rem;
    cursor: pointer;
    margin-right: 1rem;
    margin-bottom: 0.5rem;
}

#externe-bestellung .btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
    color: white;
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}

#externe-bestellung .btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #0056b3, #004494);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(13, 110, 253, 0.4);
}

#externe-bestellung .btn-danger {
    background: var(--danger-color);
    color: white;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}

#externe-bestellung .btn-danger:hover:not(:disabled) {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.4);
}

#externe-bestellung .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Field Groups for Better Organization */
.field-section {
    background: var(--light-bg);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--info-color);
}

.field-section h4 {
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.field-section h4::before {
    content: "📋";
    font-size: 1.2rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    #externe-bestellung {
        padding: 1rem;
    }
    
    #fieldset-externe-bestellung legend {
        padding: 1rem;
        font-size: 1.25rem;
    }
    
    #amount-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    #amount-group select,
    #amount-group input {
        flex: none;
        width: 100%;
    }
    
    #externe-bestellung .btn {
        width: 100%;
        margin-right: 0;
    }
}

/* Loading State */
.form-loading {
    opacity: 0.7;
    pointer-events: none;
}

.form-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Help Text */
.help-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    display: block;
}

/* Validation Feedback */
.form-control.is-invalid {
    border-color: var(--danger-color);
}

.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--danger-color);
}
