File size: 33,821 Bytes
5aad2f7
 
 
 
 
8aba308
5aad2f7
404ee14
5aad2f7
 
0032c7c
5aad2f7
a851256
 
 
 
404ee14
7491d57
8aba308
 
7491d57
 
 
 
 
 
5aad2f7
 
 
 
8aba308
5aad2f7
4e49a00
9c7400b
5aad2f7
8aba308
 
 
 
 
 
 
 
027f66d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5aad2f7
8166b9e
8aba308
 
 
027f66d
8aba308
 
 
 
027f66d
8166b9e
 
8aba308
5aad2f7
027f66d
8aba308
 
8a5652e
9c7400b
8a5652e
 
 
027f66d
8a5652e
8aba308
8a5652e
 
 
 
8aba308
8a5652e
8aba308
8a5652e
 
 
 
8aba308
 
 
8a5652e
 
5aad2f7
8aba308
 
5aad2f7
8aba308
c089bfb
 
 
63dde70
c089bfb
 
 
 
 
 
 
 
 
 
 
 
 
 
8aba308
027f66d
 
 
 
 
8aba308
 
027f66d
 
acac3c3
 
 
 
 
8aba308
 
 
 
 
 
 
 
 
 
 
 
027f66d
8aba308
 
027f66d
 
8aba308
 
 
 
 
 
 
 
 
027f66d
 
8aba308
 
 
 
 
 
027f66d
 
8aba308
 
 
027f66d
8aba308
 
 
027f66d
 
acac3c3
 
027f66d
8aba308
 
 
e0dba13
 
 
 
 
 
 
 
 
 
 
8aba308
 
 
 
 
 
e0dba13
8166b9e
4492eda
 
 
 
 
 
 
 
 
 
 
8aba308
 
 
 
 
027f66d
8aba308
 
 
 
 
 
 
027f66d
8aba308
 
 
 
 
 
027f66d
8aba308
 
 
 
 
 
 
404ee14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8aba308
 
 
027f66d
 
8aba308
 
 
 
027f66d
8aba308
027f66d
8aba308
 
027f66d
 
8aba308
 
 
 
027f66d
8aba308
 
 
027f66d
8aba308
 
 
 
 
 
027f66d
8aba308
 
 
 
 
 
 
 
 
 
 
027f66d
8aba308
027f66d
8aba308
027f66d
8aba308
 
8166b9e
5aad2f7
8aba308
5aad2f7
8166b9e
5aad2f7
8aba308
027f66d
 
8aba308
 
5aad2f7
 
8aba308
 
 
 
706e560
 
5aad2f7
706e560
8aba308
 
 
 
 
 
93c7d2b
3dec39a
8aba308
027f66d
8aba308
 
 
 
 
 
 
 
5aad2f7
8aba308
 
 
 
 
 
5aad2f7
 
 
 
 
 
 
 
706e560
8aba308
 
706e560
5aad2f7
706e560
 
 
 
00fc179
706e560
 
 
 
57d9b6b
5aad2f7
 
00fc179
 
8166b9e
00fc179
5aad2f7
 
 
fb89637
027f66d
93c7d2b
 
fb89637
5aad2f7
 
404ee14
 
 
 
 
 
 
 
 
 
 
 
 
5aad2f7
8166b9e
 
706e560
29c5e2e
00fc179
57d9b6b
00fc179
8166b9e
5aad2f7
 
706e560
8166b9e
 
 
5aad2f7
00fc179
8166b9e
00fc179
5aad2f7
 
 
8166b9e
 
 
 
 
 
 
 
 
 
 
 
 
706e560
00fc179
706e560
 
34c1f5a
57d9b6b
8166b9e
00fc179
 
8166b9e
00fc179
8166b9e
 
 
 
4492eda
8166b9e
 
 
fb89637
 
8aba308
93c7d2b
 
 
4492eda
93c7d2b
 
fb89637
8166b9e
 
 
5aad2f7
 
d619e88
 
 
4492eda
d619e88
 
 
4492eda
d619e88
 
 
 
 
 
 
 
 
5aad2f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0032c7c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
027f66d
 
 
 
 
 
4492eda
027f66d
 
 
 
 
 
 
 
 
4492eda
027f66d
 
 
 
 
2cc3573
 
 
 
 
027f66d
 
 
8166b9e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5aad2f7
4e49a00
8aba308
 
5aad2f7
8166b9e
e0dba13
 
 
8aba308
e0dba13
 
 
 
 
8a5652e
 
 
 
706e560
 
8a5652e
 
706e560
 
 
8a5652e
 
d619e88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5aad2f7
404ee14
5aad2f7
404ee14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5aad2f7
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
<!doctype html>
<html lang="ja">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
  <meta name="theme-color" content="#0f172a">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
  <meta name="apple-mobile-web-app-title" content="SDU-Shift">
  <meta name="csrf-token" content="{{ csrf_token() }}">
  <link rel="manifest" href="/static/manifest.json">
  <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
  <link rel="icon" type="image/png" sizes="32x32" href="/static/icons/favicon-32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/static/icons/favicon-16.png">
  <link rel="apple-touch-icon" href="/static/icons/apple-touch-icon.png">
  {% include "pwa/_splash_links.html" %}
  <!-- Noto Sans JP (ノンブロッキング読み込み) -->
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link rel="preload" as="style"
        href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;600;700&display=swap"
        onload="this.rel='stylesheet'">
  <noscript>
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;600;700&display=swap" rel="stylesheet">
  </noscript>
  <title>{% block title %}SDU-Shift{% endblock %}</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
  <style>
    /* ── デザイントークン ─────────────────────────────── */
    :root {
      --nav-h: 68px;
      --safe-top: env(safe-area-inset-top, 0px);
      --safe-bottom: env(safe-area-inset-bottom, 0px);
      --primary:       #0ea5e9;
      --primary-dark:  #0284c7;
      --primary-light: #38bdf8;
      --accent:        #38bdf8;
      --radius-xl:     20px;
      --radius-lg:     14px;
      --radius-md:     10px;
      --radius-sm:     7px;
      --transition:    .25s cubic-bezier(.4, 0, .2, 1);
    }

    [data-theme="light"] {
      --bg:            linear-gradient(165deg, #e0f2fe 0%, #f0f9ff 35%, #f8fafc 75%);
      --bg-card:       rgba(255, 255, 255, 0.75);
      --border:        rgba(226, 232, 240, 0.8);
      --text:          #0f172a;
      --text-muted:    #475569;
      --shadow-xs:     0 1px 2px rgba(0, 0, 0, 0.03);
      --shadow-sm:     0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
      --shadow-md:     0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
      --shadow-lg:     0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
      --glass-bg:      rgba(255, 255, 255, 0.7);
      --glass-border:  rgba(255, 255, 255, 0.5);
      --sidebar-bg:    linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
      --dark-card-bg:  linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
      --dark-card-text:#f8fafc;
      --header-bg:     linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #0f172a 100%);
      --grid-bg:       #ffffff;
    }

    [data-theme="dark"] {
      --bg:            linear-gradient(165deg, #020617 0%, #0f172a 45%, #1e293b 100%);
      --bg-card:       rgba(30, 41, 59, 0.65);
      --border:        rgba(51, 65, 85, 0.5);
      --text:          #f8fafc;
      --text-muted:    #94a3b8;
      --shadow-xs:     0 1px 2px rgba(0, 0, 0, 0.2);
      --shadow-sm:     0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
      --shadow-md:     0 10px 15px -3px rgba(0, 0, 0, 0.35), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
      --shadow-lg:     0 20px 25px -5px rgba(0, 0, 0, 0.55), 0 10px 10px -5px rgba(0, 0, 0, 0.25);
      --glass-bg:      rgba(15, 23, 42, 0.65);
      --glass-border:  rgba(255, 255, 255, 0.05);
      --sidebar-bg:    linear-gradient(180deg, #020617 0%, #0f172a 100%);
      --dark-card-bg:  linear-gradient(135deg, #0f172a 0%, #020617 100%);
      --dark-card-text:#e2e8f0;
      --header-bg:     linear-gradient(135deg, #020617 0%, #0f172a 60%, #1e293b 100%);
      --grid-bg:       #0f172a;
    }

    /* ── ベース ──────────────────────────────────────── */
    body {
      padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
      background: var(--bg);
      min-height: 100vh;
      font-family: 'Noto Sans JP', system-ui, -apple-system, sans-serif;
      -webkit-font-smoothing: antialiased;
      color: var(--text);
      transition: background var(--transition), color var(--transition);
    }

    /* ── ページヘッダー ──────────────────────────────── */
    .page-header {
      background: var(--header-bg);
      border-bottom: 1px solid rgba(148,163,184,.15);
      box-shadow: 0 2px 20px rgba(0,0,0,.3);
      color: white;
      padding: calc(.7rem + var(--safe-top)) 1rem .7rem;
      position: sticky; top: 0; z-index: 100;
      display: flex; align-items: center; gap: .65rem;
      min-height: 54px;
      transition: background var(--transition);
    }
    .page-header h1, .page-header .fw-semibold {
      font-size: 1rem; margin: 0; font-weight: 700; letter-spacing: .02em;
    }
    .page-header .header-brand-logo {
      width: 30px; height: 30px; object-fit: contain;
      border-radius: 7px; flex-shrink: 0; opacity: .9;
    }
    @media (min-width: 768px) { .page-header .header-brand-logo { display: none; } }
    @media (min-width: 768px) {
      .page-header::after {
        content: 'SKY DINING UOMAN';
        margin-left: auto;
        font-size: .58rem; letter-spacing: .15em;
        color: rgba(148,163,184,.3); font-weight: 600;
        white-space: nowrap; text-transform: uppercase; pointer-events: none;
      }
      .page-header:has(.ms-auto)::after { display: none; }
    }

    /* ── コンテンツ ──────────────────────────────────── */
    .content { padding: 1rem; }

    /* ── モバイル共通 UI 修正 ──────────────────────────── */
    @media (max-width: 767px) {
      .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
      .table-responsive table th, .table-responsive table td { white-space: nowrap; }
      .mobile-label { min-width: 0 !important; width: 100%; margin-bottom: .3rem; }
      .mobile-stack { flex-direction: column !important; align-items: stretch !important; }
      .mobile-stack > * { width: 100% !important; max-width: 100% !important; }
      .mobile-btn-wrap { flex-wrap: wrap !important; }
      .mobile-btn-wrap > .btn { flex: 1 1 auto; min-width: 0; }
      input[type="number"].form-control-sm { width: 52px !important; }
      input[type="time"].form-control-sm { max-width: 100% !important; }
      .card-body { padding: .75rem; }
      .page-header { flex-wrap: wrap; min-height: auto; gap: .4rem; }
      .page-header .ms-auto { margin-left: auto !important; }
      input, select, textarea { font-size: 16px !important; }
      input.form-control-sm, select.form-select-sm { font-size: 14px !important; }
    }

    /* ── カード ──────────────────────────────────────── */
    .card, .db-card {
      border: 1px solid var(--border);
      background: var(--glass-bg);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      box-shadow: var(--shadow-sm);
      border-radius: var(--radius-lg);
      transition: all var(--transition);
    }
    @media (hover: hover) {
      .card:hover, .db-card:hover {
        box-shadow: var(--shadow-md);
        transform: translateY(-2px);
      }
    }

    /* ── ボタン ──────────────────────────────────────── */
    .btn { border-radius: var(--radius-md); font-weight: 500; transition: all var(--transition); }
    .btn-primary {
      background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
      border: none;
      box-shadow: 0 2px 8px rgba(14,165,233,.28);
    }
    .btn-primary:hover {
      background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%);
      box-shadow: 0 4px 14px rgba(14,165,233,.4);
      transform: translateY(-2px); border: none;
    }
    .btn-primary:active { transform: translateY(0); }
    .btn-outline-secondary { border-color: var(--border); color: var(--text-muted); background: transparent; }
    .btn-outline-secondary:hover { background: rgba(100, 116, 139, 0.08); border-color: var(--text-muted); color: var(--text); }
    .btn-sm { border-radius: var(--radius-sm); }

    /* ── フォーム ─────────────────────────────────────── */
    .form-control, .form-select {
      border-radius: var(--radius-md);
      border: 1.5px solid var(--border);
      padding: .5rem .85rem;
      font-size: .9rem;
      transition: border-color var(--transition), box-shadow var(--transition);
      background: var(--bg-card);
      color: var(--text);
      font-family: inherit;
    }
    .form-control:focus, .form-select:focus {
      border-color: var(--primary);
      box-shadow: 0 0 0 3px rgba(14,165,233,.12);
      outline: none;
      background: var(--bg-card);
      color: var(--text);
    }
    .form-control-sm, .form-select-sm { border-radius: var(--radius-sm); }
    .form-label { font-size: .85rem; font-weight: 600; color: var(--text-muted); }
    .input-group-text { border-color: var(--border); background: var(--bg-card); color: var(--text-muted); }

    /* ── バッジ ──────────────────────────────────────── */
    .badge { border-radius: var(--radius-sm); font-weight: 600; }
    .badge-hall    { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
    .badge-kitchen { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
    [data-theme="dark"] .badge-hall    { color: #60a5fa; }
    [data-theme="dark"] .badge-kitchen { color: #4ade80; }
    .bg-secondary  { background: var(--text-muted) !important; color: var(--bg-card) !important; }
    .bg-success    { background: linear-gradient(135deg,#22c55e,#16a34a) !important; }

    /* ── トースト ─────────────────────────────────────── */
    .toast-container {
      position: fixed; top: 1rem; right: 1rem; z-index: 9999;
    }
    @media (max-width: 767px) {
      .toast-container {
        top: auto; right: auto; left: 50%;
        bottom: calc(var(--nav-h) + var(--safe-bottom) + .75rem);
        transform: translateX(-50%);
        min-width: min(320px, 90vw);
      }
    }
    .toast {
      border-radius: var(--radius-md) !important;
      box-shadow: var(--shadow-md) !important;
      border: none !important;
      font-size: .88rem;
    }
    .btn-loading { pointer-events: none; opacity: .75; }

    /* ── モーダル ─────────────────────────────────────── */
    .modal-content {
      background: var(--bg-card);
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
      color: var(--text);
      border: 1.5px solid var(--border);
      border-radius: var(--radius-lg) !important;
      box-shadow: var(--shadow-lg);
    }

    /* ── ボトムナビ ───────────────────────────────────── */
    .bottom-nav {
      position: fixed; bottom: 0; left: 0; right: 0;
      height: calc(var(--nav-h) + var(--safe-bottom));
      padding-bottom: var(--safe-bottom);
      background: rgba(15, 23, 42, 0.9);
      backdrop-filter: blur(24px) saturate(180%);
      -webkit-backdrop-filter: blur(24px) saturate(180%);
      border-top: 1px solid rgba(255,255,255,.06);
      display: flex; z-index: 1000;
    }
    .bottom-nav a, .bottom-nav button.nav-btn {
      flex: 1; display: flex; flex-direction: column; align-items: center;
      justify-content: center; color: #94a3b8; text-decoration: none;
      font-size: 10px; gap: 3px; transition: color var(--transition);
      min-height: 44px; background: none; border: none; padding: 0;
      cursor: pointer; position: relative; font-family: inherit;
    }
    .bottom-nav a i, .bottom-nav button.nav-btn i { font-size: 22px; }
    .bottom-nav a.active, .bottom-nav button.nav-btn.active { color: var(--accent); }
    .bottom-nav a:hover, .bottom-nav button.nav-btn:hover  { color: #cbd5e1; }
    /* アクティブ上部インジケーター */
    .bottom-nav a.active::before, .bottom-nav button.nav-btn.active::before {
      content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
      width: 28px; height: 2.5px; border-radius: 0 0 3px 3px;
      background: var(--accent);
    }

    /* ── ホーム画面に追加バナー ───────────────────────── */
    .pwa-install-banner {
      display: none;
      position: fixed; left: .75rem; right: .75rem;
      bottom: calc(var(--nav-h) + var(--safe-bottom) + .75rem);
      z-index: 1000;
      align-items: center; gap: .75rem;
      background: var(--bg-card);
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
      border: 1.5px solid var(--border);
      border-radius: var(--radius-lg);
      box-shadow: var(--shadow-lg);
      padding: .75rem;
      color: var(--text);
    }
    .pwa-install-banner.show { display: flex; }
    .pwa-install-banner img { width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; }
    .pwa-install-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
    .pwa-install-text strong { font-size: .85rem; }
    .pwa-install-text span { font-size: .75rem; color: var(--text-muted); }
    .pwa-install-action {
      background: var(--primary); color: #fff; border: none; border-radius: var(--radius-md);
      padding: .4rem .9rem; font-size: .8rem; font-weight: 600; white-space: nowrap;
      font-family: inherit;
    }
    .pwa-install-close {
      background: none; border: none; color: var(--text-muted); font-size: 1.1rem;
      padding: .25rem; line-height: 1; flex-shrink: 0; cursor: pointer;
    }
    @media (min-width: 768px) {
      .pwa-install-banner { left: auto; right: 1.5rem; bottom: 1.5rem; max-width: 360px; }
    }

    /* ── ハンバーガードロワー ─────────────────────────── */
    .drawer-backdrop {
      display: none; position: fixed; inset: 0;
      background: rgba(0,0,0,.65); z-index: 1100;
      backdrop-filter: blur(4px);
    }
    .drawer-backdrop.open { display: block; }
    .drawer {
      position: fixed; bottom: 0; left: 0; right: 0;
      background: #0f172a;
      border: 1px solid rgba(255,255,255,.06);
      border-radius: 24px 24px 0 0;
      z-index: 1200; padding-bottom: var(--safe-bottom);
      transform: translateY(100%);
      transition: transform .3s cubic-bezier(.4,0,.2,1);
      box-shadow: 0 -10px 40px rgba(0,0,0,.6);
    }
    .drawer.open { transform: translateY(0); }
    .drawer-handle {
      width: 40px; height: 4px;
      background: rgba(255,255,255,.15);
      border-radius: 2px; margin: 12px auto 6px;
    }
    .drawer-title {
      color: #64748b; font-size: .7rem; font-weight: 700;
      text-transform: uppercase; letter-spacing: .08em;
      padding: .25rem 1.25rem .5rem;
    }
    .drawer a {
      display: flex; align-items: center; gap: .9rem;
      color: #e2e8f0; text-decoration: none;
      padding: .9rem 1.25rem; font-size: .95rem; font-weight: 500;
      border-bottom: 1px solid rgba(255,255,255,.04);
      transition: background var(--transition);
    }
    .drawer a:last-child { border-bottom: none; }
    .drawer a:hover, .drawer a.active { background: rgba(255,255,255,.05); color: var(--accent); }
    .drawer a i { font-size: 20px; width: 26px; color: #64748b; }
    .drawer a:hover i, .drawer a.active i { color: var(--accent); }
    .drawer-close {
      display: flex; align-items: center; justify-content: center;
      margin: .75rem 1rem 1rem; padding: .7rem;
      background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08);
      border-radius: var(--radius-md); color: #94a3b8;
      font-size: .88rem; cursor: pointer; width: calc(100% - 2rem);
      transition: all var(--transition); font-family: inherit;
    }
    .drawer-close:hover { background: rgba(255,255,255,.1); color: #e2e8f0; }

    /* ── デスクトップサイドバー ─────────────────────── */
    .sidebar { display: none; }
    @media (min-width: 768px) {
      body { padding-bottom: 0; padding-left: 210px; }
      .bottom-nav { display: none; }
      .drawer-backdrop, .drawer { display: none !important; }
      .sidebar {
        display: flex; position: fixed; left: 0; top: 0; bottom: 0; width: 210px;
        background: var(--sidebar-bg);
        border-right: 1px solid var(--border);
        flex-direction: column; padding: 1rem 0; z-index: 100;
        box-shadow: 2px 0 20px rgba(0,0,0,.2);
      }
      .sidebar .brand {
        display: flex; align-items: center; gap: .6rem;
        padding: .5rem 1rem 1rem;
        border-bottom: 1px solid rgba(255,255,255,.06);
        margin-bottom: .5rem;
        text-decoration: none;
        transition: opacity var(--transition);
      }
      .sidebar .brand:hover { opacity: .8; }
      .sidebar .brand img {
        width: 34px; height: 34px; border-radius: 8px; object-fit: contain;
        flex-shrink: 0;
      }
      .sidebar .brand span {
        color: white; font-weight: 700; font-size: .95rem; letter-spacing: .02em;
      }
      .sidebar a {
        display: flex; align-items: center; gap: .7rem;
        color: #94a3b8; text-decoration: none;
        padding: .55rem 1rem; margin: 1px .75rem;
        font-size: .88rem; font-weight: 500;
        border-radius: var(--radius-md);
        transition: all var(--transition);
      }
      .sidebar a.active {
        color: var(--accent);
        background: rgba(56,189,248,.1);
      }
      .sidebar a:hover:not(.logout-btn) { color: #94a3b8; background: rgba(255,255,255,.04); }
      .sidebar a i { font-size: 17px; width: 20px; }
      .sidebar .logout-btn {
        margin-top: auto; margin-bottom: 0; color: #475569;
      }
      .sidebar .logout-btn:hover { color: #f87171 !important; background: rgba(248,113,113,.08) !important; }
    }
  </style>
  {% block head %}{% endblock %}
</head>
<body>

<!-- Desktop Sidebar -->
<nav class="sidebar">
  <a href="{{ url_for('dashboard.index') }}" class="brand" style="text-decoration:none">
    <img src="/static/icons/apple-touch-icon.png" alt="SDU-Shift">
    <span>SDU-Shift</span>
  </a>
  {% set nav_items = [
    ('dashboard.index',       'bi-house-fill',     'ホーム'),
    ('shifts.index',          'bi-pencil-square',  '希望シフト'),
    ('generate.index',        'bi-lightning-fill', '自動生成'),
    ('schedule.list_periods', 'bi-calendar3',      'シフト表'),
    ('schedule.stats_multi',  'bi-bar-chart-fill', '勤務統計'),
    ('customers.list_periods','bi-cup-hot-fill',   '客数管理'),
    ('employees.index',       'bi-people-fill',    'スタッフ管理'),
    ('settings.index',        'bi-gear-fill',      '設定'),
    ('help.index',            'bi-question-circle','ヘルプ'),
    ('feedback.index',        'bi-chat-square-text','フィードバック'),
  ] %}
  {% for endpoint, icon, label in nav_items %}
  {% set active = (request.endpoint == endpoint) if endpoint == 'schedule.stats_multi'
                  else (request.endpoint and request.endpoint.startswith(endpoint.split('.')[0]) and request.endpoint != 'schedule.stats_multi') %}
  <a href="{{ url_for(endpoint) }}"
     class="{{ 'active' if active else '' }}">
    <i class="bi {{ icon }}"></i>{{ label }}
  </a>
  {% endfor %}
  {% if auth_enabled %}
  <a href="{{ url_for('auth.logout') }}" class="logout-btn" style="margin: 1px .75rem;">
    <i class="bi bi-box-arrow-right"></i>ログアウト
  </a>
  {% endif %}
</nav>

<!-- ホーム画面に追加バナー -->
<div class="pwa-install-banner" id="pwa-install-banner">
  <img src="/static/icons/icon-192.png" alt="">
  <div class="pwa-install-text">
    <strong>ホーム画面に追加</strong>
    <span id="pwa-install-desc">アプリのように使えます</span>
  </div>
  <button type="button" class="pwa-install-action d-none" id="pwa-install-action">追加</button>
  <button type="button" class="pwa-install-close" id="pwa-install-close" aria-label="閉じる">
    <i class="bi bi-x-lg"></i>
  </button>
</div>

<!-- Mobile Bottom Nav -->
{% set _in_drawer = request.endpoint and (
    request.endpoint.startswith('customers') or
    request.endpoint.startswith('employees') or
    request.endpoint.startswith('settings') or
    request.endpoint.startswith('help') or
    request.endpoint.startswith('feedback') or
    request.endpoint == 'schedule.stats_multi'
) %}
<div class="bottom-nav">
  {% for endpoint, icon, label in [
    ('dashboard.index',       'bi-house-fill',     'ホーム'),
    ('shifts.index',          'bi-pencil-square',  'シフト入力'),
    ('generate.index',        'bi-lightning-fill', '自動生成'),
    ('schedule.list_periods', 'bi-calendar3',      'シフト表'),
  ] %}
  {% set active = request.endpoint and request.endpoint.startswith(endpoint.split('.')[0]) and request.endpoint != 'schedule.stats_multi' %}
  <a href="{{ url_for(endpoint) }}"
     class="{{ 'active' if active else '' }}">
    <i class="bi {{ icon }}"></i>{{ label }}
  </a>
  {% endfor %}
  <button class="nav-btn {{ 'active' if _in_drawer else '' }}"
          onclick="openDrawer()" aria-label="メニュー">
    <i class="bi bi-grid-fill"></i>
    <span>メニュー</span>
  </button>
</div>

<!-- ハンバーガードロワー -->
<div class="drawer-backdrop" id="drawer-backdrop" onclick="closeDrawer()"></div>
<div class="drawer" id="drawer">
  <div class="drawer-handle"></div>
  <div class="drawer-title">メニュー</div>
  {% for endpoint, icon, label, desc in [
    ('customers.list_periods', 'bi-cup-hot-fill',    '客数管理',    '予約客数の入力'),
    ('schedule.stats_multi',   'bi-bar-chart-fill',  '勤務統計',    '複数期間の勤務時間集計'),
    ('employees.index',        'bi-people-fill',     'スタッフ管理','スタッフの登録・編集'),
    ('settings.index',         'bi-gear-fill',       '設定',        'シフト制約・アプリ設定'),
    ('help.index',             'bi-question-circle', 'ヘルプ',      '各機能の使い方'),
    ('feedback.index',         'bi-chat-square-text','フィードバック','不具合報告・機能要望を送る'),
  ] %}
  {% set active = (request.endpoint == endpoint) if endpoint == 'schedule.stats_multi'
                  else (request.endpoint and request.endpoint.startswith(endpoint.split('.')[0])) %}
  <a href="{{ url_for(endpoint) }}"
     class="{{ 'active' if active else '' }}"
     onclick="closeDrawer()">
    <i class="bi {{ icon }}"></i>
    <div>
      <div>{{ label }}</div>
      <div style="font-size:.73rem;color:#94a3b8;font-weight:400;margin-top:1px">{{ desc }}</div>
    </div>
  </a>
  {% endfor %}
  {% if auth_enabled %}
  <a href="{{ url_for('auth.logout') }}" onclick="closeDrawer()"
     style="border-top:1px solid rgba(255,255,255,.06)">
    <i class="bi bi-box-arrow-right" style="color:#f87171"></i>
    <div>
      <div style="color:#f87171">ログアウト</div>
      <div style="font-size:.73rem;color:#94a3b8;font-weight:400;margin-top:1px">アクセスを終了する</div>
    </div>
  </a>
  {% endif %}
  <button class="drawer-close" onclick="closeDrawer()">
    <i class="bi bi-x-lg me-2"></i>閉じる
  </button>
</div>

<!-- 未保存離脱ガードモーダル(全ページ共通) -->
<div class="modal fade" id="unsavedModal" tabindex="-1">
  <div class="modal-dialog modal-dialog-centered modal-sm">
    <div class="modal-content">
      <div class="modal-body p-4 text-center">
        <i class="bi bi-exclamation-triangle-fill text-warning d-block mb-2" style="font-size:2.2rem"></i>
        <div class="fw-semibold mb-1">未保存の変更があります</div>
        <div class="text-muted small mb-3">保存せずに移動しますか?</div>
        <div class="d-flex gap-2">
          <button class="btn btn-secondary flex-grow-1" data-bs-dismiss="modal">戻る</button>
          <button class="btn btn-danger flex-grow-1" id="unsaved-proceed-btn">移動する</button>
        </div>
      </div>
    </div>
  </div>
</div>

<!-- Flash Messages -->
<div class="toast-container">
  {% for cat, msg in get_flashed_messages(with_categories=true) %}
  <div class="toast show align-items-center text-bg-{{ 'success' if cat == 'success' else 'danger' if cat == 'error' else 'warning' if cat == 'warning' else 'info' }} border-0" role="alert">
    <div class="d-flex">
      <div class="toast-body">{{ msg }}</div>
      <button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button>
    </div>
  </div>
  {% endfor %}
</div>

{% block content %}{% endblock %}

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script>
  // ── CSRF対策(fetchによるPOST/PUT/PATCH/DELETEに自動でトークンを付与) ──────
  (function() {
    const token = document.querySelector('meta[name="csrf-token"]').content;
    const origFetch = window.fetch;
    window.fetch = function(input, init) {
      init = init || {};
      const method = (init.method || 'GET').toUpperCase();
      if (!['GET', 'HEAD', 'OPTIONS', 'TRACE'].includes(method)) {
        const headers = new Headers(init.headers || {});
        if (!headers.has('X-CSRFToken')) headers.set('X-CSRFToken', token);
        init = Object.assign({}, init, { headers });
      }
      return origFetch(input, init);
    };
  })();

  // ── テーマ管理 ──────────────────────────────────────────
  (function() {
    const savedTheme = localStorage.getItem('theme');
    const systemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
    const initialTheme = savedTheme || (systemDark ? 'dark' : 'light');
    document.documentElement.setAttribute('data-theme', initialTheme);
    document.documentElement.setAttribute('data-bs-theme', initialTheme);
    
    window.addEventListener('DOMContentLoaded', () => {
      updateThemeUI(initialTheme);
    });

    window.toggleTheme = function() {
      const current = document.documentElement.getAttribute('data-theme');
      const next = current === 'dark' ? 'light' : 'dark';
      document.documentElement.setAttribute('data-theme', next);
      document.documentElement.setAttribute('data-bs-theme', next);
      localStorage.setItem('theme', next);
      updateThemeUI(next);
    };

    function updateThemeUI(theme) {
      // 設定画面のトグルスイッチの同期
      const switchEl = document.getElementById('theme-switch');
      if (switchEl) {
        switchEl.checked = (theme === 'dark');
      }
    }
  })();

  function openDrawer() {
    document.getElementById('drawer').classList.add('open');
    document.getElementById('drawer-backdrop').classList.add('open');
    document.body.style.overflow = 'hidden';
  }
  function closeDrawer() {
    document.getElementById('drawer').classList.remove('open');
    document.getElementById('drawer-backdrop').classList.remove('open');
    document.body.style.overflow = '';
  }
  (function() {
    const drawer = document.getElementById('drawer');
    let startY = 0;
    drawer.addEventListener('touchstart', e => { startY = e.touches[0].clientY; }, {passive:true});
    drawer.addEventListener('touchend', e => {
      if (e.changedTouches[0].clientY - startY > 60) closeDrawer();
    }, {passive:true});
  })();

  document.querySelectorAll('.toast').forEach(t => {
    const len = t.querySelector('.toast-body')?.textContent.length || 0;
    setTimeout(() => bootstrap.Toast.getOrCreateInstance(t).hide(),
               Math.min(7000, Math.max(5000, len * 50)));
  });

  document.querySelectorAll('[data-loading]').forEach(btn => {
    const form = btn.form || btn.closest('form');
    if (form) form.addEventListener('submit', () => {
      btn.disabled = true; btn.classList.add('btn-loading');
      btn.innerHTML = '<span class="spinner-border spinner-border-sm me-1"></span>'
                    + (btn.dataset.loading || '処理中…');
    });
  });

  (function() {
    if (window.innerWidth >= 768) return;
    const hdr = document.querySelector('.page-header');
    if (!hdr) return;
    const a = document.createElement('a');
    a.href = '/'; a.style.display = 'flex'; a.style.flexShrink = '0';
    const img = document.createElement('img');
    img.src = '/static/icons/apple-touch-icon.png';
    img.alt = 'ホーム'; img.className = 'header-brand-logo';
    a.appendChild(img);
    hdr.insertBefore(a, hdr.firstChild);
  })();

  // ── 未保存離脱ガード(全ページ共通) ────────────────────────────
  (function() {
    window._formDirty = false;
    let _pendingNav = null;
    let _guardModal = null;
    function _getModal() {
      return _guardModal || (_guardModal = new bootstrap.Modal(document.getElementById('unsavedModal')));
    }
    // data-dirty-form を持つフォームを自動監視
    document.querySelectorAll('form[data-dirty-form]').forEach(form => {
      form.querySelectorAll('input, select, textarea').forEach(el => {
        el.addEventListener('change', () => { window._formDirty = true; });
        if (['text','number','time','search'].includes(el.type) || el.tagName === 'TEXTAREA') {
          el.addEventListener('input', () => { window._formDirty = true; });
        }
      });
      form.addEventListener('submit', () => { window._formDirty = false; });
    });
    // 「移動する」ボタン
    document.getElementById('unsaved-proceed-btn').addEventListener('click', () => {
      window._formDirty = false;
      _getModal().hide();
      if (_pendingNav) location.href = _pendingNav;
    });
    // 全リンクのクリックを監視(ページ内アンカー・javascript: は除外)
    document.addEventListener('click', e => {
      if (!window._formDirty) return;
      const a = e.target.closest('a[href]');
      if (!a) return;
      const href = a.getAttribute('href');
      if (!href || href.startsWith('#') || href.startsWith('javascript:')) return;
      e.preventDefault();
      e.stopPropagation();
      _pendingNav = a.href;
      _getModal().show();
    }, true);
    // ブラウザの戻る・リロード
    window.addEventListener('beforeunload', e => {
      if (!window._formDirty) return;
      e.preventDefault();
      e.returnValue = '';
    });
  })();

  if ('serviceWorker' in navigator) {
    navigator.serviceWorker.register('/sw.js').catch(() => {});
  }

  // ── ホーム画面に追加バナー ──────────────────────────
  (() => {
    const KEY = 'pwaInstallDismissedUntil';
    const banner = document.getElementById('pwa-install-banner');
    const desc = document.getElementById('pwa-install-desc');
    const actionBtn = document.getElementById('pwa-install-action');
    const closeBtn = document.getElementById('pwa-install-close');
    if (!banner) return;

    // 既にホーム画面から起動している場合は表示しない
    const isStandalone = window.matchMedia('(display-mode: standalone)').matches
      || window.navigator.standalone === true;
    if (isStandalone) return;

    // 閉じてから14日以内は再表示しない
    const dismissedUntil = Number(localStorage.getItem(KEY) || 0);
    if (Date.now() < dismissedUntil) return;

    const DISMISS_MS = 14 * 24 * 60 * 60 * 1000;
    const show = () => banner.classList.add('show');
    const hide = () => banner.classList.remove('show');

    const isIOS = /iphone|ipad|ipod/i.test(navigator.userAgent);
    let deferredPrompt = null;

    if (isIOS) {
      // iOS Safariはbeforeinstallpromptに対応していないため案内文のみ表示
      desc.textContent = '共有ボタン →「ホーム画面に追加」';
      show();
    } else {
      window.addEventListener('beforeinstallprompt', e => {
        e.preventDefault();
        deferredPrompt = e;
        actionBtn.classList.remove('d-none');
        show();
      });
    }

    actionBtn.addEventListener('click', async () => {
      if (!deferredPrompt) return;
      hide();
      await deferredPrompt.prompt();
      deferredPrompt = null;
    });

    closeBtn.addEventListener('click', () => {
      hide();
      localStorage.setItem(KEY, String(Date.now() + DISMISS_MS));
    });

    window.addEventListener('appinstalled', () => {
      hide();
      localStorage.setItem(KEY, String(Date.now() + DISMISS_MS));
    });
  })();
</script>
{% block scripts %}{% endblock %}
</body>
</html>