@extends('layouts.app')

@section('title', 'Edit Veneer')

@section('sidebar')
<ul class="sidebar-menu">
    <li><a href="{{ route('superadmin.dashboard') }}">📊 Dashboard</a></li>
    <li><a href="{{ route('superadmin.buyers.index') }}">👥 Buyers</a></li>
    <li><a href="{{ route('superadmin.products.index') }}">📦 Products</a></li>
    <li><a href="{{ route('superadmin.materials.index') }}">🪵 Materials</a></li>
    <li><a href="{{ route('superadmin.veneers.index') }}" class="active">🎨 Veneers</a></li>
    <li><a href="{{ route('superadmin.components.index') }}">🔧 Components</a></li>
    <li><a href="{{ route('superadmin.dimensions.index') }}">📐 Dimensions</a></li>
</ul>
@endsection

@section('content')
<div style="margin-bottom: 30px;">
    <h1 style="font-size: 28px; color: var(--gray-800); margin-bottom: 10px;">Edit Veneer</h1>
    <p style="color: var(--gray-600);">Update informasi veneer</p>
</div>

<div class="card" style="max-width: 800px;">
    <form action="{{ route('superadmin.veneers.update', $veneer->id) }}" method="POST">
        @csrf
        @method('PUT')

        <div class="form-group">
            <label for="name">Nama Veneer *</label>
            <input type="text" id="name" name="name" class="form-control" value="{{ old('name', $veneer->name) }}" required>
            @error('name')
                <span class="error-message">{{ $message }}</span>
            @enderror
        </div>

        <div class="form-group">
            <label for="thickness">Tebal (mm) *</label>
            <input type="number" id="thickness" name="thickness" class="form-control" value="{{ old('thickness', $veneer->thickness) }}" step="0.01" required>
            @error('thickness')
                <span class="error-message">{{ $message }}</span>
            @enderror
        </div>

        <div class="form-group">
            <label for="pattern">Pattern *</label>
            <select id="pattern" name="pattern" class="form-control" required>
                <option value="">Pilih Pattern</option>
                <option value="lurus" {{ old('pattern', $veneer->pattern) == 'lurus' ? 'selected' : '' }}>Lurus</option>
                <option value="motif" {{ old('pattern', $veneer->pattern) == 'motif' ? 'selected' : '' }}>Motif</option>
            </select>
            @error('pattern')
                <span class="error-message">{{ $message }}</span>
            @enderror
        </div>

        <div class="form-group">
            <label for="price_per_m2">Harga per M² (Rp) *</label>
            <input type="number" id="price_per_m2" name="price_per_m2" class="form-control" value="{{ old('price_per_m2', $veneer->price_per_m2) }}" step="0.01" required>
            @error('price_per_m2')
                <span class="error-message">{{ $message }}</span>
            @enderror
        </div>

        <div class="form-group">
            <label style="display: flex; align-items: center; cursor: pointer;">
                <input type="checkbox" name="is_active" value="1" {{ old('is_active', $veneer->is_active) ? 'checked' : '' }} style="width: auto; margin-right: 8px;">
                <span>Status Aktif</span>
            </label>
        </div>

        <div style="display: flex; gap: 10px; margin-top: 30px;">
            <button type="submit" class="btn btn-primary">Update</button>
            <a href="{{ route('superadmin.veneers.index') }}" class="btn btn-secondary">Batal</a>
        </div>
    </form>
</div>
@endsection

@push('styles')
<style>
    .form-group {
        margin-bottom: 20px;
    }

    .form-group label {
        display: block;
        margin-bottom: 8px;
        color: var(--gray-700);
        font-weight: 600;
        font-size: 14px;
    }

    .error-message {
        color: #ef4444;
        font-size: 12px;
        margin-top: 5px;
        display: block;
    }

    select.form-control {
        cursor: pointer;
    }
</style>
@endpush