<!doctype html>
<html lang="id">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{{ $title ?? 'DMS' }}</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    
    <style>
        /* ========== GLOBAL STYLE ========== */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background: #f8f9fa;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            min-height: 100vh;
        }

        /* ========== NAVBAR MERAH MODERN ========== */
        .navbar-custom {
            background: linear-gradient(135deg, #dc3545 0%, #c0392b 100%);
            padding: 15px 0;
            box-shadow: 0 4px 20px rgba(220, 53, 69, 0.3);
            position: sticky;
            top: 0;
            z-index: 1000;
            transition: all 0.3s ease;
        }

        .navbar-custom .navbar-brand {
            font-weight: 700;
            font-size: 24px;
            letter-spacing: 2px;
            color: white !important;
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .navbar-custom .navbar-brand i {
            font-size: 28px;
            background: rgba(255, 255, 255, 0.2);
            padding: 10px;
            border-radius: 12px;
            transition: all 0.3s ease;
        }

        .navbar-custom .navbar-brand:hover i {
            transform: rotate(-10deg) scale(1.1);
            background: rgba(255, 255, 255, 0.3);
        }

        .navbar-custom .btn-logout {
            background: rgba(255, 255, 255, 0.2);
            color: white;
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 50px;
            padding: 8px 20px;
            font-weight: 600;
            font-size: 14px;
            transition: all 0.3s ease;
            backdrop-filter: blur(10px);
        }

        .navbar-custom .btn-logout:hover {
            background: white;
            color: #dc3545;
            border-color: white;
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
        }

        .navbar-custom .btn-logout i {
            margin-right: 8px;
        }

        /* ========== CONTAINER ========== */
        .main-container {
            padding: 30px 20px;
            max-width: 1200px;
            margin: 0 auto;
        }

        /* ========== ALERT STYLING ========== */
        .alert-custom {
            border-radius: 16px;
            padding: 16px 20px;
            border: none;
            font-weight: 500;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
            display: flex;
            align-items: center;
            gap: 12px;
            animation: slideDown 0.5s ease-out;
        }

        .alert-custom i {
            font-size: 20px;
        }

        .alert-custom.alert-success {
            background: linear-gradient(135deg, #d4edda 0%, #b7e4c7 100%);
            color: #155724;
            border-left: 5px solid #28a745;
        }

        .alert-custom.alert-danger {
            background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
            color: #721c24;
            border-left: 5px solid #dc3545;
        }

        /* ========== ANIMATIONS ========== */
        @keyframes slideDown {
            from {
                opacity: 0;
                transform: translateY(-20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: scale(0.95);
            }
            to {
                opacity: 1;
                transform: scale(1);
            }
        }

        /* ========== RESPONSIVE ========== */
        @media (max-width: 768px) {
            .navbar-custom .navbar-brand {
                font-size: 20px;
            }

            .navbar-custom .navbar-brand i {
                font-size: 22px;
                padding: 8px;
            }

            .navbar-custom .btn-logout {
                padding: 6px 16px;
                font-size: 13px;
            }

            .main-container {
                padding: 20px 15px;
            }

            .alert-custom {
                padding: 14px 16px;
                font-size: 14px;
            }
        }

        @media (max-width: 480px) {
            .navbar-custom .navbar-brand {
                font-size: 17px;
                gap: 8px;
            }

            .navbar-custom .navbar-brand i {
                font-size: 18px;
                padding: 6px;
            }

            .navbar-custom .btn-logout {
                padding: 5px 12px;
                font-size: 12px;
            }

            .main-container {
                padding: 15px 10px;
            }
        }

        /* ========== SCROLLBAR STYLING ========== */
        ::-webkit-scrollbar {
            width: 8px;
        }

        ::-webkit-scrollbar-track {
            background: #f1f1f1;
        }

        ::-webkit-scrollbar-thumb {
            background: linear-gradient(135deg, #dc3545, #c0392b);
            border-radius: 10px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: #c0392b;
        }

        /* ========== CARD RED THEME ========== */
        .card-red-theme {
            background: white;
            border-radius: 20px;
            border: none;
            box-shadow: 0 10px 40px rgba(220, 53, 69, 0.15);
            transition: all 0.3s ease;
            overflow: hidden;
        }

        .card-red-theme:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 50px rgba(220, 53, 69, 0.25);
        }

        .card-red-theme .card-header {
            background: linear-gradient(135deg, #dc3545 0%, #c0392b 100%);
            color: white;
            padding: 20px 25px;
            border: none;
            font-weight: 700;
            letter-spacing: 1px;
        }

        .card-red-theme .card-header i {
            margin-right: 10px;
        }

        .card-red-theme .card-body {
            padding: 30px 25px;
        }

        /* ========== FORM RED THEME ========== */
        .form-red-theme .form-control {
            border: 2px solid #e2e8f0;
            border-radius: 12px;
            padding: 12px 15px;
            font-size: 14px;
            transition: all 0.3s ease;
            background: #f7fafc;
        }

        .form-red-theme .form-control:focus {
            border-color: #dc3545;
            box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.15);
            background: white;
        }

        .form-red-theme .form-label {
            font-weight: 600;
            color: #2d3748;
            font-size: 14px;
            margin-bottom: 8px;
        }

        .form-red-theme .input-group-text {
            background: #f7fafc;
            border: 2px solid #e2e8f0;
            border-right: none;
            border-radius: 12px 0 0 12px;
            color: #718096;
        }

        .form-red-theme .input-group .form-control {
            border-radius: 0 12px 12px 0;
            border-left: none;
        }

        .form-red-theme .input-group .form-control:focus {
            border-left: none;
        }

        /* ========== BUTTON RED THEME ========== */
        .btn-red-gradient {
            background: linear-gradient(135deg, #dc3545 0%, #c0392b 100%);
            color: white;
            border: none;
            border-radius: 12px;
            padding: 14px 30px;
            font-weight: 700;
            font-size: 16px;
            letter-spacing: 1px;
            transition: all 0.3s ease;
            box-shadow: 0 4px 20px rgba(220, 53, 69, 0.4);
            width: 100%;
        }

        .btn-red-gradient:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 30px rgba(220, 53, 69, 0.6);
            color: white;
        }

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

        .btn-red-gradient:disabled {
            opacity: 0.7;
            cursor: not-allowed;
            transform: none;
        }

        /* ========== CHECKBOX RED THEME ========== */
        .form-check-red .form-check-input {
            width: 18px;
            height: 18px;
            border: 2px solid #e2e8f0;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .form-check-red .form-check-input:checked {
            background-color: #dc3545;
            border-color: #dc3545;
        }

        .form-check-red .form-check-input:focus {
            box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25);
        }

        .form-check-red .form-check-label {
            color: #4a5568;
            font-weight: 500;
            margin-left: 8px;
            cursor: pointer;
        }

        /* ========== LINK RED THEME ========== */
        .link-red {
            color: #dc3545;
            text-decoration: none;
            font-weight: 600;
            transition: all 0.3s ease;
        }

        .link-red:hover {
            color: #c0392b;
            text-decoration: underline;
        }
    </style>
</head>

<body>
    <!-- ========== NAVBAR MERAH ========== -->
    <nav class="navbar-custom">
        <div class="container">
            <span class="navbar-brand">
                <i class="fas fa-folder-open"></i>
                DMS
                <span style="font-size: 14px; font-weight: 300; opacity: 0.8; margin-left: 5px;">
                    Document Management System
                </span>
            </span>

            @auth
            <form action="{{ route('logout') }}" method="POST" class="m-0">
                @csrf
                <button class="btn-logout" type="submit">
                    <i class="fas fa-sign-out-alt"></i>
                    Logout
                </button>
            </form>
            @endauth
        </div>
    </nav>

    <!-- ========== MAIN CONTENT ========== -->
    <div class="main-container">
        <!-- Alert Messages -->
        @if(session('success'))
            <div class="alert-custom alert-success mb-4">
                <i class="fas fa-check-circle"></i>
                {{ session('success') }}
            </div>
        @endif

        @if(session('error'))
            <div class="alert-custom alert-danger mb-4">
                <i class="fas fa-exclamation-circle"></i>
                {{ session('error') }}
            </div>
        @endif

        @if($errors->any())
            <div class="alert-custom alert-danger mb-4">
                <i class="fas fa-exclamation-triangle"></i>
                <ul class="m-0" style="list-style: none; padding-left: 0;">
                    @foreach($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div>
        @endif

        @yield('content')
    </div>

    <!-- ========== SCRIPTS ========== -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js"></script>
    
    <script>
        // ========== AUTO HIDE ALERT ==========
        document.addEventListener('DOMContentLoaded', function() {
            const alerts = document.querySelectorAll('.alert-custom');
            alerts.forEach(alert => {
                setTimeout(() => {
                    alert.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
                    alert.style.opacity = '0';
                    alert.style.transform = 'translateY(-20px)';
                    setTimeout(() => {
                        alert.style.display = 'none';
                    }, 500);
                }, 5000);
            });
        });

        // ========== NAVBAR SCROLL EFFECT ==========
        window.addEventListener('scroll', function() {
            const navbar = document.querySelector('.navbar-custom');
            if (window.scrollY > 50) {
                navbar.style.boxShadow = '0 8px 30px rgba(220, 53, 69, 0.4)';
                navbar.style.padding = '10px 0';
            } else {
                navbar.style.boxShadow = '0 4px 20px rgba(220, 53, 69, 0.3)';
                navbar.style.padding = '15px 0';
            }
        });

        // ========== BUTTON LOADING STATE ==========
        document.querySelectorAll('form').forEach(form => {
            form.addEventListener('submit', function(e) {
                const submitBtn = this.querySelector('button[type="submit"]');
                if (submitBtn) {
                    const originalText = submitBtn.innerHTML;
                    submitBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Memproses...';
                    submitBtn.disabled = true;
                    
                    // Optional: Reset after 10 seconds if something goes wrong
                    setTimeout(() => {
                        submitBtn.innerHTML = originalText;
                        submitBtn.disabled = false;
                    }, 10000);
                }
            });
        });
    </script>
</body>

</html>