<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>@yield('title', 'Student Portal') &middot; {{ config('app.name') }}</title>
    <link href="https://fonts.googleapis.com/css2?family=Public+Sans:wght@400;500;600;700&display=swap" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">
    <link href="{{ asset('css/sms.css') }}?v={{ @filemtime(public_path('css/sms.css')) ?: '1' }}" rel="stylesheet">
    @stack('styles')
</head>
<body style="background:var(--sms-body-bg)">
@php $me = auth()->user()->student; @endphp
<nav class="sms-topbar px-3 px-lg-4" style="box-shadow:0 1px 4px rgba(20,30,60,.05)">
    <a href="{{ route('student.dashboard') }}" class="d-flex align-items-center gap-2 text-decoration-none">
        <span class="logo" style="width:34px;height:34px;border-radius:9px;background:var(--sms-primary);color:#fff;display:grid;place-items:center"><i class="bi bi-mortarboard-fill"></i></span>
        <span class="fw-bold text-dark d-none d-sm-block">{{ config('app.name') }} <span class="text-muted fw-normal small">Student Portal</span></span>
    </a>
    <div class="ms-auto d-flex align-items-center gap-2">
        @php
            $nav = [
                'student.dashboard' => ['Dashboard', 'bi-speedometer2'],
                'student.attendance' => ['Attendance', 'bi-calendar2-check'],
                'student.results' => ['Results', 'bi-journal-text'],
                'student.homework' => ['Homework', 'bi-journal-arrow-up'],
                'student.fees' => ['Fees', 'bi-cash-coin'],
                'student.notices' => ['Notices', 'bi-megaphone'],
            ];
        @endphp
        @foreach($nav as $route => [$label, $icon])
            <a href="{{ route($route) }}" class="btn btn-sm {{ request()->routeIs($route) ? 'btn-primary' : 'btn-light border' }} d-none d-md-inline-flex align-items-center gap-1">
                <i class="bi {{ $icon }}"></i><span class="d-none d-lg-inline">{{ $label }}</span>
            </a>
        @endforeach
        <div class="dropdown">
            <a href="#" class="d-flex align-items-center gap-2 text-decoration-none dropdown-toggle" data-bs-toggle="dropdown">
                <span class="sms-avatar sm">{{ auth()->user()->initials }}</span>
                <span class="d-none d-sm-block small fw-semibold text-dark">{{ auth()->user()->name }}</span>
            </a>
            <ul class="dropdown-menu dropdown-menu-end shadow">
                <li><span class="dropdown-item-text small text-muted">{{ $me?->admission_number }}</span></li>
                <li><a class="dropdown-item" href="{{ route('student.profile') }}"><i class="bi bi-person me-2"></i>My Profile</a></li>
                <li><hr class="dropdown-divider"></li>
                <li><form method="POST" action="{{ route('logout') }}">@csrf<button class="dropdown-item text-danger"><i class="bi bi-box-arrow-right me-2"></i>Logout</button></form></li>
            </ul>
        </div>
    </div>
</nav>

<div class="d-md-none bg-white border-bottom px-2 py-1 d-flex gap-1 overflow-auto">
    @foreach($nav as $route => [$label, $icon])
        <a href="{{ route($route) }}" class="btn btn-sm {{ request()->routeIs($route) ? 'btn-primary' : 'btn-light border' }} text-nowrap"><i class="bi {{ $icon }} me-1"></i>{{ $label }}</a>
    @endforeach
</div>

<main class="container-xl py-4">
    <div class="page-head mb-3"><h1>@yield('page_title', 'Student Portal')</h1></div>
    @include('layouts.partials.flash')
    @yield('content')
</main>

<footer class="text-center text-muted small py-3">&copy; {{ date('Y') }} {{ config('app.name') }} — Student Portal</footer>

<script src="https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="{{ asset('js/sms.js') }}"></script>
@stack('scripts')
</body>
</html>
