/* ══════════════════════════════════════════════════════════════════
   index.css — ระบบแจ้งซ่อม วพช.
   ธีม: Navy #1e2d5a · Red #8B1C1C · Dark mode: #2C2C2C / #FFD369
══════════════════════════════════════════════════════════════════ */

:root {
    --navy:      #1e2d5a;
    --navy-deep: #14203f;
    --navy-mid:  #263875;
    --red:       #8B1C1C;
    --red-light: #a02020;
    --red-glow:  rgba(139,28,28,.35);
    --gold:      #FFD369;
    --white:     #ffffff;
    --text:      #e8ecf4;
    --text-muted:#8a9dc8;
    --border:    rgba(255,255,255,.1);
    --card-bg:   rgba(30,45,90,.55);
    --radius:    12px;
    --radius-sm: 8px;
    --transition: .25s cubic-bezier(.4,0,.2,1);
}

[data-theme="light"] {
    --navy-deep: #f0f4ff;
    --red-glow:  rgba(139,28,28,.15);
    --text:      #1a1f36;
    --text-muted:#5a6282;
    --border:    rgba(30,45,90,.15);
    --card-bg:   rgba(255,255,255,.85);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Kanit', 'Sarabun', sans-serif; }

body {
    background: var(--navy-deep);
    color: var(--text);
    min-height: 100dvh;
    transition: background var(--transition), color var(--transition);
    overflow-x: hidden;
}

[data-theme="light"] body { background: #f0f4ff; }

/* ── Particle Canvas ── */
#bgCanvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: .5;
}

/* ── Grain overlay ── */
.grain {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
    opacity: .4;
}

/* ══════════════════════════════════════════
   NAVBAR
══════════════════════════════════════════ */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    background: rgba(20,32,63,.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    transition: box-shadow var(--transition), background var(--transition);
}

[data-theme="light"] .navbar { background: rgba(30,45,90,.92); }

.navbar.nav-scrolled {
    box-shadow: 0 4px 32px rgba(0,0,0,.3);
    background: rgba(14,22,48,.96);
}

.nav-inner {
    max-width: 1100px;
    margin: auto;
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: .625rem;
    text-decoration: none;
}
.nav-logo {
    width: 50px; height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid rgba(255,255,255,.25);
    background: #fff;
    flex-shrink: 0;
}
.nav-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.nav-title  { font-size: 15px; font-weight: 600; color: #fff; }
.nav-sub    { font-size: 10px; color: var(--text-muted); }

.nav-actions { display: flex; align-items: center; gap: .5rem; }

.theme-btn {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.theme-btn:hover { background: rgba(255,255,255,.1); color: #fff; }

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    padding: .45rem .85rem;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    font-family: 'Kanit', sans-serif;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}
.nav-btn i { font-size: 15px; }

.nav-btn-ghost {
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border);
}
.nav-btn-ghost:hover { background: rgba(255,255,255,.08); color: #fff; }

[data-theme="light"] .nav-btn-ghost {
    color: #fff;
    border-color: rgba(255,255,255,.45);
}
[data-theme="light"] .nav-btn-ghost:hover {
    background: rgba(255,255,255,.18);
    color: #fff;
}

.nav-btn-primary {
    background: var(--red);
    color: #fff;
    border: none;
}
.nav-btn-primary:hover { background: var(--red-light); }

/* ══════════════════════════════════════════
   HERO
══════════════════════════════════════════ */
.hero {
    position: relative;
    overflow: hidden;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--navy-deep) 0%, #0e1628 40%, #3a0a0a 100%);
    z-index: 2;
}
[data-theme="light"] .hero { background: linear-gradient(160deg, #dce6ff 0%, #eef2ff 40%, #fde8e8 100%); }

/* Gear decorations */
.gear {
    position: absolute;
    color: rgba(139,28,28,.12);
    pointer-events: none;
}
.gear-1 {
    right: -60px; top: 50%;
    transform: translateY(-50%);
    animation: gearSpin1 40s linear infinite;
}
.gear-2 {
    left: -40px; bottom: -40px;
    color: rgba(30,45,90,.4);
    animation: gearSpin2 28s linear infinite reverse;
}
@keyframes gearSpin1 {
    from { transform: translateY(-50%) rotate(0deg); }
    to   { transform: translateY(-50%) rotate(360deg); }
}
@keyframes gearSpin2 {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Cityscape */
.cityscape {
    position: absolute;
    bottom: 0; left: 0;
    color: rgba(139,28,28,.18);
    pointer-events: none;
}

.hero-inner {
    position: relative;
    z-index: 3;
    text-align: center;
    padding: 7rem 1.5rem 5rem;
    max-width: 720px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

/* RMP badge */
.hero-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 90px; height: 90px;
    border-radius: 50%;
    border: 2px solid rgba(139,28,28,.5);
    box-shadow: 0 0 0 6px rgba(139,28,28,.1), 0 0 0 12px rgba(139,28,28,.05);
    margin-bottom: .5rem;
    animation: badgePulse 3s ease-in-out infinite;
}
@keyframes badgePulse {
    0%,100% { box-shadow: 0 0 0 6px rgba(139,28,28,.1), 0 0 0 12px rgba(139,28,28,.05); }
    50%      { box-shadow: 0 0 0 10px rgba(139,28,28,.18), 0 0 0 20px rgba(139,28,28,.08); }
}

.rmp-text {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -2px;
    line-height: 1;
}
.rmp-text span { font-size: 20px; color: #c84040; }
[data-theme="light"] .rmp-text { color: #1e2d5a; }
[data-theme="light"] .rmp-text span { color: #8B1C1C; }

.hero-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    color: #fff;
    line-height: 1.15;
    letter-spacing: -.02em;
}
[data-theme="light"] .hero-title { color: #1a1f36; }

.hero-sub {
    font-size: clamp(.85rem, 2vw, 1.05rem);
    color: var(--text-muted);
    font-weight: 300;
}
[data-theme="light"] .hero-sub { color: #3a4466; }

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .75rem;
    margin-top: .5rem;
}

.btn-primary-lg {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1.75rem;
    background: var(--red);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: 'Kanit', sans-serif;
    text-decoration: none;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    box-shadow: 0 4px 20px var(--red-glow);
}
.btn-primary-lg:hover {
    background: var(--red-light);
    transform: translateY(-2px);
    box-shadow: 0 8px 28px var(--red-glow);
}
.btn-primary-lg i { font-size: 18px; }

.btn-ghost-lg {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1.75rem;
    background: transparent;
    color: rgba(255,255,255,.7);
    border: 1px solid rgba(255,255,255,.25);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    font-family: 'Kanit', sans-serif;
    text-decoration: none;
    transition: background var(--transition), color var(--transition), transform var(--transition);
}
.btn-ghost-lg:hover {
    background: rgba(255,255,255,.1);
    color: #fff;
    transform: translateY(-2px);
}
.btn-ghost-lg i { font-size: 18px; }

[data-theme="light"] .btn-ghost-lg {
    color: #1e2d5a;
    border-color: rgba(30,45,90,.4);
}
[data-theme="light"] .btn-ghost-lg:hover {
    background: rgba(30,45,90,.08);
    color: #14203f;
}

/* Scroll hint */
.scroll-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .2rem;
    margin-top: 1rem;
    color: rgba(255,255,255,.35);
    font-size: 11px;
    font-weight: 300;
    animation: scrollBounce 1.8s ease-in-out infinite;
}
[data-theme="light"] .scroll-hint { color: rgba(30,45,90,.45); }
.scroll-hint i { font-size: 20px; }
@keyframes scrollBounce {
    0%,100% { transform: translateY(0); opacity: .5; }
    50%      { transform: translateY(6px); opacity: 1; }
}

/* ══════════════════════════════════════════
   REVEAL ANIMATIONS
══════════════════════════════════════════ */
.reveal-up {
    opacity: 0;
    transform: translateY(22px);
    animation: revealUp .6s cubic-bezier(.22,1,.36,1) forwards;
    animation-delay: var(--d, 0s);
}
@keyframes revealUp {
    to { opacity: 1; transform: translateY(0); }
}

.reveal-section {
    opacity: 0;
    transform: translateY(32px);
    transition: opacity .55s ease, transform .55s cubic-bezier(.22,1,.36,1);
}
.reveal-section.revealed { opacity: 1; transform: translateY(0); }

/* ══════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════ */
.main-wrap {
    position: relative;
    z-index: 2;
    max-width: 1100px;
    margin: auto;
    padding: 3rem 1.5rem 5rem;
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.section-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--red-light);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.section-label::before {
    content: '';
    display: inline-block;
    width: 18px; height: 2px;
    background: var(--red);
    border-radius: 1px;
}

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
}

.stat-card {
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    overflow: hidden;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.stat-card:hover {
    transform: translateY(-3px);
    border-color: rgba(255,255,255,.2);
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
}

[data-theme="light"] .stat-card {
    background: rgba(255,255,255,.9);
    border-color: rgba(30,45,90,.12);
    box-shadow: 0 2px 12px rgba(30,45,90,.08);
}
[data-theme="light"] .stat-card:hover {
    border-color: rgba(30,45,90,.22);
    box-shadow: 0 8px 28px rgba(30,45,90,.14);
}

.stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 22px;
}

.stat-card[data-color="blue"]  .stat-icon { background: rgba(59,130,246,.18); color: #60a5fa; }
.stat-card[data-color="amber"] .stat-icon { background: rgba(245,158,11,.18); color: #fbbf24; }
.stat-card[data-color="green"] .stat-icon { background: rgba(34,197,94,.18);  color: #4ade80; }
.stat-card[data-color="red"]   .stat-icon { background: rgba(239,68,68,.18);  color: #f87171; }

[data-theme="light"] .stat-card[data-color="blue"]  .stat-icon { background: rgba(59,130,246,.12); color: #2563eb; }
[data-theme="light"] .stat-card[data-color="amber"] .stat-icon { background: rgba(245,158,11,.12); color: #d97706; }
[data-theme="light"] .stat-card[data-color="green"] .stat-icon { background: rgba(34,197,94,.12);  color: #16a34a; }
[data-theme="light"] .stat-card[data-color="red"]   .stat-icon { background: rgba(239,68,68,.12);  color: #dc2626; }

.stat-body { flex: 1; min-width: 0; }
.stat-label { font-size: 12px; color: var(--text-muted); line-height: 1.4; margin-bottom: .25rem; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--text); line-height: 1; }

[data-theme="light"] .stat-value { color: #1a1f36; }
[data-theme="light"] .stat-label { color: #5a6282; }

/* Glow */
.stat-glow {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s;
}
.stat-card[data-color="blue"]  .stat-glow { background: radial-gradient(circle at 85% 50%, rgba(59,130,246,.12), transparent 65%); }
.stat-card[data-color="amber"] .stat-glow { background: radial-gradient(circle at 85% 50%, rgba(245,158,11,.12), transparent 65%); }
.stat-card[data-color="green"] .stat-glow { background: radial-gradient(circle at 85% 50%, rgba(34,197,94,.12),  transparent 65%); }
.stat-card[data-color="red"]   .stat-glow { background: radial-gradient(circle at 85% 50%, rgba(239,68,68,.12),  transparent 65%); }
.stat-card:hover .stat-glow { opacity: 1; }

/* ── Skeleton ── */
.skeleton-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,.06) 25%, rgba(255,255,255,.12) 50%, rgba(255,255,255,.06) 75%);
    background-size: 200% 100%;
    animation: skeletonPulse 1.4s ease-in-out infinite;
    border-radius: 6px;
}
[data-theme="light"] .skeleton {
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: skeletonPulse 1.4s ease-in-out infinite;
}
@keyframes skeletonPulse {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.sk-icon  { width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0; }
.skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: .5rem; }
.sk-line  { height: 12px; border-radius: 4px; }
.sk-short { width: 60%; }
.sk-tall  { height: 28px; width: 40%; }

/* ── Tickets Card ── */
.tickets-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
[data-theme="light"] .tickets-card { background: rgba(255,255,255,.9); border-color: rgba(30,45,90,.12); }

.tickets-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.tickets-hd-info { display: flex; align-items: center; gap: .75rem; }
.tickets-hd-icon { font-size: 24px; color: var(--red-light); }
.tickets-hd-name { font-size: 14px; font-weight: 600; color: var(--text); }
.tickets-hd-tel  { font-size: 12px; color: var(--text-muted); margin-top: .1rem; }

[data-theme="light"] .tickets-hd-name { color: #1a1f36; }
[data-theme="light"] .tickets-hd-tel  { color: #5a6282; }

.logout-btn {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    padding: .4rem .85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 12.5px;
    font-family: 'Kanit', sans-serif;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.logout-btn:hover { background: rgba(239,68,68,.12); color: #f87171; border-color: rgba(239,68,68,.3); }
.logout-btn i { font-size: 15px; }

.table-wrap { overflow-x: auto; }

.tickets-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tickets-table thead tr { background: rgba(255,255,255,.04); }
[data-theme="light"] .tickets-table thead tr { background: rgba(30,45,90,.04); }
.tickets-table th {
    padding: .65rem 1.1rem;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.tickets-table td {
    padding: .75rem 1.1rem;
    color: var(--text);
    border-bottom: 1px solid rgba(255,255,255,.04);
    vertical-align: middle;
}
[data-theme="light"] .tickets-table td { color: #1a1f36; border-bottom-color: rgba(30,45,90,.06); }
.tickets-table tbody tr:last-child td { border-bottom: none; }
.tickets-table tbody tr { transition: background var(--transition); }
.tickets-table tbody tr:hover { background: rgba(255,255,255,.03); }
[data-theme="light"] .tickets-table tbody tr:hover { background: rgba(30,45,90,.03); }

.sk-row td { padding: 1.5rem; }

/* ── Toast ── */
#toast {
    position: fixed;
    top: 20px; right: 20px;
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #1e2d5a;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,.4);
    min-width: 280px;
    max-width: 420px;
    color: #fff;
}
[data-theme="light"] #toast { background: #fff; color: #1a1a1a; border-color: rgba(0,0,0,.1); box-shadow: 0 2px 12px rgba(0,0,0,.12); }
#toast.toast-show    { animation: toastSlideIn  .22s cubic-bezier(.34,1.56,.64,1) forwards; }
#toast.toast-hidden  { animation: toastSlideOut .18s ease forwards; pointer-events: none; }
@keyframes toastSlideIn  { from { opacity:0; transform:translateX(24px); } to { opacity:1; transform:translateX(0); } }
@keyframes toastSlideOut { from { opacity:1; transform:translateX(0); } to { opacity:0; transform:translateX(24px); } }

/* ── Footer ── */
.site-footer {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 1.5rem;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}
[data-theme="light"] .site-footer { border-color: rgba(30,45,90,.1); color: #5a6282; }

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 680px) {
    .nav-sub { display: none; }
    .nav-btn-ghost { display: none; }
    .hero-inner { padding: 6rem 1rem 4rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .tickets-table th, .tickets-table td { padding: .6rem .75rem; }
}
@media (max-width: 420px) {
    .stats-grid { grid-template-columns: 1fr; }
    .hero-badge { width: 72px; height: 72px; }
    .rmp-text { font-size: 22px; }
    .rmp-text span { font-size: 16px; }
    .hero-actions { flex-direction: column; width: 100%; }
    .btn-primary-lg, .btn-ghost-lg { width: 100%; justify-content: center; }
    .tickets-hd { flex-direction: column; align-items: flex-start; }
}