<!DOCTYPE html>
<html lang="bn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ক্লাস রুটিন - {{ $class->class_name_bn }} {{ $section }}</title>
    <style>
        body {
            font-family: 'SolaimanLipi', Arial, sans-serif;
            margin: 30px;
        }
        .header {
            text-align: center;
            margin-bottom: 30px;
        }
        .header h1 {
            color: #1e4a6d;
            margin: 5px 0;
        }
        .header h3 {
            color: #666;
            margin: 5px 0;
        }
        .routine-table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }
        .routine-table th {
            background-color: #1e4a6d;
            color: white;
            padding: 10px;
            text-align: center;
            border: 1px solid #1e4a6d;
        }
        .routine-table td {
            border: 1px solid #ddd;
            padding: 8px;
            vertical-align: top;
        }
        .routine-table tr:nth-child(even) {
            background-color: #f9f9f9;
        }
        .period-time {
            font-weight: bold;
            color: #1e4a6d;
        }
        .break-cell {
            background-color: #fff3cd;
            text-align: center;
            padding: 5px;
        }
        .class-cell {
            padding: 5px;
        }
        .subject {
            font-weight: bold;
            color: #333;
        }
        .teacher {
            font-size: 12px;
            color: #666;
        }
        .room {
            font-size: 11px;
            color: #999;
        }
        .footer {
            margin-top: 30px;
            text-align: center;
            font-size: 12px;
            color: #666;
        }
        @media print {
            .no-print {
                display: none;
            }
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>আদর্শ উচ্চ বিদ্যালয়</h1>
        <h3>উত্তরা, ঢাকা-১২৩০</h3>
        <h2>ক্লাস রুটিন</h2>
        <h4>{{ $class->class_name_bn }} - {{ $section }} শাখা</h4>
        <p>কার্যকরী: {{ date('d F, Y') }}</p>
    </div>

    <table class="routine-table">
        <thead>
            <tr>
                <th style="width: 80px;">পিরিয়ড</th>
                <th style="width: 120px;">সময়</th>
                <th>শনিবার</th>
                <th>রবিবার</th>
                <th>সোমবার</th>
                <th>মঙ্গলবার</th>
                <th>বুধবার</th>
                <th>বৃহস্পতিবার</th>
            </tr>
        </thead>
        <tbody>
            @for($p = 1; $p <= 8; $p++)
            <tr>
                <td class="text-center font-weight-bold">পিরিয়ড {{ $p }}</td>
                <td class="period-time">
                    @php
                        $firstDay = $routine['saturday']->where('period', $p)->first();
                    @endphp
                    @if($firstDay)
                        {{ date('h:i A', strtotime($firstDay->start_time)) }} - 
                        {{ date('h:i A', strtotime($firstDay->end_time)) }}
                    @else
                        --
                    @endif
                </td>
                
                @foreach(['saturday', 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday'] as $day)
                <td>
                    @php
                        $period = $routine[$day]->where('period', $p)->first();
                    @endphp
                    
                    @if($period)
                        @if($period->is_break)
                            <div class="break-cell">
                                <strong>বিরতি</strong><br>
                                <small>{{ $period->break_name ?? 'বিরতি' }}</small>
                            </div>
                        @else
                            <div class="class-cell">
                                <div class="subject">{{ $period->subject }}</div>
                                <div class="teacher">{{ $period->teacher->name_bn ?? '' }}</div>
                                <div class="room">রুম: {{ $period->room_number ?? '-' }}</div>
                            </div>
                        @endif
                    @else
                        <div class="text-center text-muted">--</div>
                    @endif
                </td>
                @endforeach
            </tr>
            @endfor
        </tbody>
    </table>

    <div class="footer">
        <p>সফটওয়্যার জেনারেটেড রুটিন - স্বাক্ষরের প্রয়োজন নেই</p>
        <p>প্রিন্টের তারিখ: {{ date('d F, Y h:i A') }}</p>
    </div>

    <div class="no-print text-center mt-3">
        <button onclick="window.print()" class="btn btn-primary">প্রিন্ট করুন</button>
        <button onclick="window.close()" class="btn btn-secondary">বন্ধ করুন</button>
    </div>
</body>
</html>