{% extends "base.html" %}

{% block title %}Drucker-Einstellungen - Mercedes-Benz MYP Platform{% endblock %}

{% block head %}
{{ super() }}
<meta name="csrf-token" content="{{ csrf_token() }}">
{% endblock %}

{% block content %}
<div class="min-h-screen bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50 dark:from-slate-900 dark:via-slate-800 dark:to-slate-900">
    <div class="max-w-2xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
        
        <!-- Header -->
        <div class="mb-8">
            <div class="flex items-center justify-between">
                <div>
                    <h1 class="text-3xl font-bold text-slate-900 dark:text-white">{{ printer.name }} - Einstellungen</h1>
                    <p class="text-slate-600 dark:text-slate-400 mt-2">Konfiguration und Einstellungen des Druckers</p>
                </div>
                <a href="{{ url_for('admin_manage_printer_page', printer_id=printer.id) }}" class="inline-flex items-center px-4 py-2 bg-slate-200 dark:bg-slate-700 text-slate-700 dark:text-slate-300 rounded-xl hover:bg-slate-300 dark:hover:bg-slate-600 transition-all duration-300">
                    <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"/>
                    </svg>
                    Zurück zur Verwaltung
                </a>
            </div>
        </div>

        <!-- Form -->
        <div class="bg-white dark:bg-slate-800 rounded-2xl shadow-xl p-8">
            <form method="POST" action="{{ url_for('admin_update_printer_form', printer_id=printer.id) }}" class="space-y-6">
                <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
                <input type="hidden" name="_method" value="PUT"/>
                
                <!-- Name -->
                <div>
                    <label for="name" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
                        Drucker-Name
                    </label>
                    <input type="text" name="name" id="name" required
                           value="{{ printer.name }}"
                           class="w-full px-4 py-3 border border-slate-300 dark:border-slate-600 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-slate-700 dark:text-white"
                           placeholder="Prusa i3 MK3S+">
                </div>

                <!-- IP-Adresse -->
                <div>
                    <label for="ip_address" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
                        IP-Adresse
                    </label>
                    <input type="text" name="ip_address" id="ip_address" required
                           value="{{ printer.ip_address }}"
                           class="w-full px-4 py-3 border border-slate-300 dark:border-slate-600 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-slate-700 dark:text-white"
                           placeholder="192.168.1.100"
                           pattern="^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$">
                </div>

                <!-- Modell -->
                <div>
                    <label for="model" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
                        Drucker-Modell
                    </label>
                    <input type="text" name="model" id="model"
                           value="{{ printer.model or '' }}"
                           class="w-full px-4 py-3 border border-slate-300 dark:border-slate-600 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-slate-700 dark:text-white"
                           placeholder="Prusa i3 MK3S+">
                </div>

                <!-- Standort -->
                <div>
                    <label for="location" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
                        Standort
                    </label>
                    <input type="text" name="location" id="location"
                           value="{{ printer.location or '' }}"
                           class="w-full px-4 py-3 border border-slate-300 dark:border-slate-600 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-slate-700 dark:text-white"
                           placeholder="Werkstatt A, Regal 3">
                </div>

                <!-- Beschreibung -->
                <div>
                    <label for="description" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
                        Beschreibung
                    </label>
                    <textarea name="description" id="description" rows="3"
                              class="w-full px-4 py-3 border border-slate-300 dark:border-slate-600 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-slate-700 dark:text-white"
                              placeholder="Zusätzliche Informationen zum Drucker...">{{ printer.description or '' }}</textarea>
                </div>

                <!-- Status -->
                <div>
                    <label for="status" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
                        Status
                    </label>
                    <select name="status" id="status" 
                            class="w-full px-4 py-3 border border-slate-300 dark:border-slate-600 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-slate-700 dark:text-white">
                        <option value="available" {% if printer.status == 'available' %}selected{% endif %}>Verfügbar</option>
                        <option value="maintenance" {% if printer.status == 'maintenance' %}selected{% endif %}>Wartung</option>
                        <option value="offline" {% if printer.status == 'offline' %}selected{% endif %}>Offline</option>
                    </select>
                </div>

                <!-- Buttons -->
                <div class="flex items-center justify-end space-x-4 pt-4">
                    <a href="{{ url_for('admin_manage_printer_page', printer_id=printer.id) }}" 
                       class="px-6 py-3 border border-slate-300 dark:border-slate-600 text-slate-700 dark:text-slate-300 rounded-xl hover:bg-slate-50 dark:hover:bg-slate-700 transition-all duration-300">
                        Abbrechen
                    </a>
                    <button type="submit" 
                            class="px-6 py-3 bg-gradient-to-r from-blue-500 to-blue-600 text-white rounded-xl hover:from-blue-600 hover:to-blue-700 transition-all duration-300 shadow-lg">
                        Einstellungen speichern
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %} 