/* =======================================================
   Movie Booking — Modern Responsive UI (clean merged)
   ======================================================= */

/* ---------- Theme ---------- */
:root {
    --bg: #0b1020;
    --bg-2: #0e152b;
    --panel: #121a36;
    --panel-2: #0f1731;
    --text: #e8ecf3;
    --muted: #9fb0c8;
    --border: #1f2b4d;
    --primary: #6c8cff;
    --primary-2: #2dd4bf;
    --ok: #22c55e;
    --warn: #f59e0b;
    --danger: #ef4444;
    --r: 16px;
    --shadow: 0 14px 40px rgba(2, 6, 23, .35);
    --shadow-sm: 0 8px 20px rgba(2, 6, 23, .25);
}


/* ---------- Base ---------- */
* {
    box-sizing: border-box
}

html,
body {
    height: 100%
}

body {
    margin: 0;
    font: 16px/1.65 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
    color: var(--text);
    background:
        radial-gradient(1000px 500px at 120% -10%, rgba(45, 212, 191, .06), transparent 60%),
        radial-gradient(900px 600px at -10% -10%, rgba(108, 140, 255, .10), transparent 65%),
        linear-gradient(180deg, var(--bg), var(--bg-2));
}

.container {
    width: min(1200px, 92%);
    margin: 20px auto 80px
}

h1,
h2,
h3 {
    margin: .2rem 0 .8rem;
    line-height: 1.2
}

.section-title {
    font-size: clamp(22px, 2.4vw, 28px);
    letter-spacing: .2px
}

/* ---------- Admin Dashboard ---------- */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
    margin-top: 20px;
}

.admin-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: linear-gradient(180deg, color-mix(in oklab, var(--panel) 90%, transparent), var(--panel-2));
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    color: var(--text);
    text-decoration: none;
    transition: all .2s ease;
}

.admin-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: color-mix(in oklab, var(--primary) 60%, var(--border));
    background: linear-gradient(135deg, rgba(108, 140, 255, .1), rgba(45, 212, 191, .08));
}

.admin-card .icon {
    font-size: 30px;
    color: var(--primary);
    flex-shrink: 0;
}

.admin-card h3 {
    margin: 0 0 4px;
    font-size: 1.05rem;
    font-weight: 800;
}

.admin-card p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--muted);
}

/* Responsive */
@media (max-width:640px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .admin-card {
        flex-direction: row;
        align-items: center;
    }

    .admin-card .icon {
        font-size: 26px;
    }
}

/* ---------- Appbar / Navbar ---------- */
.navbar {
  position: sticky;       /* ติดด้านบนเวลาเลื่อน */
  top: 0;
  z-index: 900;
  backdrop-filter: blur(10px);
  background: linear-gradient(
    180deg,
    rgba(5, 10, 25, 0.96),
    rgba(5, 10, 25, 0.90)
  );
  border-bottom: 1px solid var(--border);
}

.navbar .inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* โลโก้ / ชื่อเว็บ */
.brand {
  margin-right: auto;
  font-weight: 900;
  letter-spacing: 0.2px;
  color: var(--text);
  text-decoration: none;
  font-size: clamp(18px, 2.2vw, 22px);
}

/* ปุ่มเมนู (มือถือเท่านั้น – desktop จะถูกซ่อนไว้) */
.menu-toggle {
  display: none;        /* desktop ซ่อน */
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  width: 100px;
  height: 40px;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s ease, filter 0.15s ease;
}

.menu-toggle:hover {
  filter: brightness(1.05);
}

.menu-toggle:active {
  transform: translateY(1px);
}

.menu-toggle svg {
  width: 20px;
  height: 20px;
}

/* ลิงก์เมนูบน desktop = เรียงเป็นแถวขวาบน */
.nav-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links a {
  color: var(--text);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background 0.18s ease, border-color 0.18s ease,
              transform 0.06s ease;
}

.nav-links a:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-links a.active {
  background: rgba(108, 140, 255, 0.25);
}

/* ฉากหลังมืดเวลาเปิดเมนูในมือถือ */
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 10, 24, 0.55);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 800;
}

/* ---------- Mobile Navbar (<= 640px) ---------- */
@media (max-width: 640px) {
  .navbar .inner {
    padding: 8px 12px;
  }

  /* โชว์ปุ่ม 3 ขีดบนมือถือ */
  .menu-toggle {
    display: flex;
  }

  /* เมนูหลักในมือถือ = กล่องลอยใต้ navbar */
  .nav-links {
    position: absolute;
    right: 12px;
    top: 60px;
    width: min(86vw, 360px);

    flex-direction: column;
    align-items: stretch;
    gap: 8px;

    padding: 12px;
    background: color-mix(in oklab, var(--panel) 88%, transparent);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);

    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    pointer-events: none;
    z-index: 1000;
  }

  .nav-links a {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    padding: 10px 12px;
    text-align: left;
  }

  .nav-links a:hover {
    background: rgba(255, 255, 255, 0.10);
    transform: translateY(-1px);
  }

  .nav-links a.active {
    border-color: color-mix(in oklab, var(--primary) 55%, var(--border));
    box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--primary) 35%, transparent);
  }

  /* เวลาเปิดเมนู (เพิ่ม .open บน <nav> จาก JS) */
  .navbar.open .nav-links {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
  }

  .navbar.open + .nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
}


/* ---------- Cards / Panels ---------- */
.card {
    background: linear-gradient(180deg, color-mix(in oklab, var(--panel) 90%, transparent), var(--panel-2));
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    padding: 18px;
    backdrop-filter: blur(6px);
}

/* ---------- Alerts ---------- */
.alert {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border)
}

.alert-success {
    background: rgba(34, 197, 94, .12)
}

.alert-error {
    background: rgba(239, 68, 68, .12)
}

.alert-warn {
    background: rgba(245, 158, 11, .12)
}

/* --- Legend แสดงราคาโซน --- */
.legend-row {
    display: flex;
    gap: 18px;
    align-items: center;
    flex-wrap: wrap;
    margin: 4px 0 10px;
}

.legend-item {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, .04)
}

.legend-item i {
    font-size: 22px
}

.legend-sofa {
    color: #22d3ee
}

.legend-premium {
    color: #6c8cff
}

.legend-classic {
    color: #94a3b8
}

/* --- โค้งจอหนัง --- */
.screen-wrap {
    position: relative;
    height: 48px;
    margin: 8px 0 18px;
}

.screen-curve {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: min(680px, 96%);
    text-align: center;
    color: #0f2344;
    font-weight: 800;
    padding: 10px 0;
    border-radius: 0 0 999px 999px;
    background: linear-gradient(180deg, #d8e7ff, #b4cffc);
    box-shadow: inset 0 -4px 10px rgba(2, 6, 23, .15);
}

/* --- Row labels + grid --- */
.row-line {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    margin: 6px 0
}

.row-label {
    color: var(--muted);
    font-weight: 800;
    width: 28px;
    text-align: center
}

.seats {
    display: grid;
    gap: 8px;
    padding: 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .03);
    border: 1px dashed var(--border)
}

/* --- Seat cell --- */
.seat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 0;
    border-radius: 10px;
    font-weight: 800;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .05);
    transition: transform .08s, background .2s, border-color .2s, box-shadow .2s;
}

.seat .seat-code {
    font-size: .8rem;
    color: var(--muted)
}

.seat.available:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm)
}

.seat.selected {
    background: linear-gradient(135deg, var(--primary-2), var(--primary));
    border-color: transparent;
    color: #051423;
}

.seat.taken {
    background: rgba(239, 68, 68, .22);
    color: #fee2e2;
    text-decoration: line-through
}


.legend-sofa {
    color: #22d3ee;
}

/* Sofa = ฟ้าอ่อน */
.legend-premium {
    color: #6c8cff;
}

/* Premium = ฟ้าน้ำเงิน */
.legend-classic {
    color: #94a3b8;
}

/* Classic = เทา */
.seat i {
    font-size: 20px;
}

/* สีไอคอน */
.legend-sofa {
    color: #22d3ee
}

.legend-premium {
    color: #6c8cff
}

.legend-classic {
    color: #94a3b8
}

.seat i {
    font-size: 20px
}

/* โซฟาคู่: แถว AA ให้ icon วางคู่ และคั่นทุกคู่ให้เห็นเป็นแพ็ก */
.sofa-icons {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center
}

.sofa-row .seat.pair-sep {
    margin-right: 14px;
}

/* คั่นทุก 2 ตัว */
@media (max-width:640px) {
    .sofa-row .seat.pair-sep {
        margin-right: 10px;
    }
}

/* ---------- Buttons ---------- */
button,
.btn {
    appearance: none;
    border: 0;
    cursor: pointer;
    font-weight: 800;
    color: #0a1024;
    padding: 12px 16px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #9aaeff);
    box-shadow: var(--shadow-sm);
    transition: transform .06s, filter .2s;
}

button:hover,
.btn:hover {
    filter: brightness(1.05)
}

button:active,
.btn:active {
    transform: translateY(1px)
}

.btn-outline {
    background: transparent;
    color: #60a5fa;
    /* ฟ้าเด่น */
    border: 2px solid #3b82f6;
    /* ฟ้าเข้ม */
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
    transition: all 0.3s ease;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #f87171);
    color: #fff
}

.btn-success {
    background: linear-gradient(135deg, var(--ok), #34d399);
    color: #052014
}

.btn-block {
    width: 100%
}

/* ---------- Forms ---------- */
label {
    display: block;
    font-weight: 700;
    margin: .2rem 0
}

input,
select,
textarea {
    width: 100%;
    color: var(--text);
    background: rgba(255, 255, 255, .05);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(108, 140, 255, .25)
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px
}

@media (max-width:700px) {
    .form-row {
        grid-template-columns: 1fr
    }
}

/* ---------- Tables ---------- */
.table-wrap {
    overflow: auto;
    border-radius: 14px;
    border: 1px solid var(--border)
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0
}

th,
td {
    padding: 12px 14px;
    border: 1px solid var(--border);
    vertical-align: top
}

thead th {
    background: rgba(255, 255, 255, .06)
}

tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, .03)
}

tbody tr:hover {
    background: rgba(34, 211, 238, .06)
}

/* ---------- Movie Grid ---------- */
.movie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 18px;
    margin-top: 12px;
}

.movie-card {
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    background: #0a1024;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: transform .16s ease, box-shadow .2s ease, border-color .2s;
}

.movie-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: color-mix(in oklab, var(--primary) 50%, var(--border))
}

.movie-card .poster {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    display: block
}

.movie-card .overlay {
    position: absolute;
    inset: auto 0 0 0;
    padding: 12px;
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .7) 40%, rgba(0, 0, 0, .9));
    color: #fff;
}

.movie-card h3 {
    margin: 0 0 4px;
    font-size: 1.05rem
}

.movie-meta {
    color: #cbd5e1;
    font-size: .9rem
}

/* ---------- Detail Poster ---------- */
.poster-xl {
    width: 100%;
    max-width: 380px;
    border-radius: 16px;
    box-shadow: var(--shadow-sm)
}

/* ---------- Lists (cinemas/showtimes) ---------- */
.list {
    display: grid;
    gap: 12px;
    margin: 6px 0
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, .04);
}

.list-item:hover {
    background: rgba(255, 255, 255, .08)
}

.meta {
    color: var(--muted);
    font-size: .95rem
}

/* ---------- Seats ---------- */
.seat-legend {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin: 10px 0
}

.seat-legend .dot {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    display: inline-block
}

.seats {
    display: grid;
    gap: 8px;
    padding: 14px;
    border: 1px dashed var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, .03);
}

.seats.cols-8 {
    grid-template-columns: repeat(8, 1fr)
}

.seats.cols-10 {
    grid-template-columns: repeat(10, 1fr)
}

.seat {
    text-align: center;
    padding: 12px 0;
    border-radius: 10px;
    font-weight: 800;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .05);
    transition: transform .08s, background .2s, border-color .2s;
}

.seat.available {
    outline: 2px solid rgba(45, 212, 191, .25)
}

.seat.taken {
    background: rgba(239, 68, 68, .22);
    color: #fee2e2;
    text-decoration: line-through
}

.seat.selected {
    background: linear-gradient(135deg, var(--primary-2), var(--primary));
    color: #061227;
    border-color: transparent
}

.seat:hover {
    transform: translateY(-2px)
}

/* ---------- Utilities ---------- */
.center {
    text-align: center
}

.hidden {
    display: none !important
}

.mt-1 {
    margin-top: 6px
}

.mt-2 {
    margin-top: 10px
}

.mt-3 {
    margin-top: 14px
}

.mb-1 {
    margin-bottom: 6px
}

.mb-2 {
    margin-bottom: 10px
}

.mb-3 {
    margin-bottom: 14px
}

.form-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 70vh;
}

.form-card {
    width: 100%;
    max-width: 560px;
    background: linear-gradient(180deg, color-mix(in oklab, var(--panel) 90%, transparent), var(--panel-2));
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    padding: 32px 26px;
    backdrop-filter: blur(8px);
}

.register-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 700;
    color: var(--text);
}

.register-form .form-row.single {
    grid-template-columns: 1fr;
}


.register-form input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    color: var(--text);
    transition: all 0.25s ease;
}

.register-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(108, 140, 255, 0.25);
    outline: none;
}

/* จัดช่องเป็น 2 คอลัมน์ให้ดูเนียบ */
.register-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 12px;
}

/* ให้ row ที่มีช่องเดียว (เช่น confirm password) ปรับให้ auto */
.register-form .form-row.single {
    grid-template-columns: 1fr;
}

/* Responsive */
@media (max-width: 640px) {
    .register-form .form-row {
        grid-template-columns: 1fr;
    }
}




/* ---------- Footer ---------- */
footer {
    color: var(--muted);
    text-align: center;
    padding: 26px 0
}


/* ---------- Chips ---------- */
.chip {
    display: inline-block;
    padding: 4px 10px;
    font-size: 0.85rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, .08);
    border: 1px solid var(--border);
    color: var(--text);
    margin-right: 4px;
}

.chip.ok {
    background: rgba(34, 197, 94, .18);
    color: #86efac
}

.chip.warn {
    background: rgba(245, 158, 11, .18);
    color: #facc15
}

.chip.bad {
    background: rgba(239, 68, 68, .18);
    color: #fca5a5
}

/* ลบเส้นใต้ และปรับสไตล์ลิงก์ให้หรู */
a {
    text-decoration: none;
    color: inherit;
    transition: color .2s ease, opacity .2s ease;
}

a:hover {
    color: var(--primary);
    opacity: .9;
}

/* สำหรับปุ่มลิงก์ที่ใช้ใน .btn */
.btn,
.btn:link,
.btn:visited {
    text-decoration: none;
    color: #fff;
}


/* ---------- Button small ---------- */
.btn-sm {
    padding: 6px 12px;
    font-size: .88rem;
    border-radius: 8px;
}



/* ---------- Responsive Tweaks ---------- */
@media (max-width:640px) {
    html {
        font-size: 17px
    }

    .container {
        width: 94%;
        margin: 14px auto 70px
    }

    .movie-grid {
        grid-template-columns: 1fr
    }

    .movie-card .poster {
        height: 132vw;
        max-height: 520px
    }

    .form-row {
        grid-template-columns: 1fr
    }

    button,
    .btn {
        width: 100%
    }
}

@media (min-width:641px) and (max-width:880px) {
    .movie-grid {
        grid-template-columns: repeat(2, 1fr)
    }
}

/* ============ Responsive for Seats Page ============ */
@media (max-width: 768px) {

    /* Card wrap ให้เต็มจอมากขึ้น */
    .section {
        padding: 16px 12px;
    }

    /* ปรับ legend ให้แสดงแนวตั้งแทน */
    .legend-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .legend-item {
        justify-content: flex-start;
        font-size: 0.9rem;
    }

    /* จอภาพยนตร์โค้งให้เล็กลง */
    .screen-wrap {
        height: 36px;
        margin: 8px 0 14px;
    }

    .screen-curve {
        font-size: 0.9rem;
        padding: 6px 0;
        width: 90%;
    }

    /* ปรับ grid ของที่นั่งให้ขนาดเล็กลง */
    .seats {
        gap: 4px;
        padding: 6px;
    }

    .seat {
        padding: 6px 0;
        border-radius: 8px;
    }

    .seat i {
        font-size: 16px;
    }

    .seat .seat-code {
        font-size: 0.7rem;
    }

    /* ให้ container สามารถ scroll ได้แนวนอนถ้าผังยาว */
    .row-line {
        overflow-x: auto;
        margin: 4px 0;
        padding-bottom: 6px;
    }

    .row-line::-webkit-scrollbar {
        height: 6px;
    }

    .row-line::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.2);
        border-radius: 4px;
    }

    /* ป้ายชื่อแถว */
    .row-label {
        font-size: 0.8rem;
        width: 24px;
    }

    /* ปรับขนาดปุ่ม */
    button.btn,
    .btn.btn-block {
        font-size: 1rem;
        padding: 12px;
    }

    /* ชิปสรุป */
    .chips {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .chip {
        font-size: 0.85rem;
    }

    /* Legend และผังที่นั่งรวมกันใน layout เดียวกัน */
    .card.section {
        overflow-y: auto;
        max-height: 85vh;
    }
}

/* ปรับเพิ่มความสวยเล็กน้อยสำหรับจอเล็กกว่า 480px */
@media (max-width: 480px) {
    .screen-curve {
        width: 100%;
        border-radius: 0 0 800px 800px;
    }

    .legend-item i {
        font-size: 20px;
    }

    .legend-item div {
        line-height: 1.3;
    }
}