/* =============================================
   GLOBAL BASE
   ============================================= */
:root {
    --brand:       #1d4ed8;
    --brand-dark:  #1e3a8a;
    --brand-soft:  #eff6ff;
    --ink:         #1e293b;
    --muted:       #64748b;
    --line:        #e2e8f0;
    --surface:     #ffffff;
    --page:        #f8fafc;
    --success:     #059669;
    --danger:      #dc2626;
    --warning:     #d97706;
}

html, body {
    background: var(--page);
    color: var(--ink);
    font-family: 'Sarabun', 'THSarabunNew', Tahoma, sans-serif;
    font-size: 18px;
    line-height: 1.6;
}

/* Font for form elements */
button, input, textarea, select,
.btn, .form-control, .form-select, .swal2-popup {
    font-family: 'Sarabun', 'THSarabunNew', Tahoma, sans-serif !important;
}

.app-shell { max-width: 1160px; }

/* =============================================
   HEADER
   ============================================= */
.site-header {
    position: sticky; top: 0; z-index: 100;
    background: var(--brand-dark);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 2px 12px rgba(30,58,138,0.15);
}

.header-inner {
    max-width: 1100px; margin: 0 auto;
    padding: 0 20px;
    display: flex; align-items: center;
    justify-content: space-between;
    height: 60px;
}

.brand-link {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none; flex-shrink: 0;
}

.brand-logo-img {
    width: 44px; height: 44px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.brand-logo-img img {
    width: 44px; height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.25);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name  { color: #fff; font-weight: 700; font-size: 15px; }
.brand-org   { color: #93c5fd; font-size: 12px; }

.main-nav {
    display: flex; align-items: center; gap: 4px;
}

.nav-item {
    color: #cbd5e1; text-decoration: none;
    padding: 7px 14px; border-radius: 8px;
    font-size: 15px; font-weight: 500;
    transition: background 0.18s, color 0.18s;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.1); }

.nav-item-btn {
    background: #2563eb; color: #fff !important;
    margin-left: 6px; font-weight: 600;
}
.nav-item-btn:hover { background: #1d4ed8; }

.nav-toggle {
    display: none; background: none; border: none;
    color: #fff; padding: 6px; cursor: pointer;
}

.mobile-nav {
    display: none; flex-direction: column;
    background: #1e3a8a; border-top: 1px solid rgba(255,255,255,0.08);
    padding: 8px 16px 12px;
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
    color: #e2e8f0; text-decoration: none;
    padding: 12px 8px; border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 16px; font-weight: 500;
}
.mobile-nav a:last-child { border-bottom: none; }

/* =============================================
   HOME PAGE
   ============================================= */
.home-wrap {
    min-height: calc(100vh - 60px - 80px);
    display: flex; align-items: center; justify-content: center;
    padding: 40px 16px;
}

.home-container {
    width: 100%; max-width: 560px;
    display: flex; flex-direction: column; align-items: center; gap: 32px;
}

/* Brand block on home */
.home-brand {
    display: flex; align-items: center; gap: 16px;
    background: var(--brand-dark);
    border-radius: 16px;
    padding: 20px 28px;
    width: 100%;
    box-shadow: 0 4px 20px rgba(30,58,138,0.18);
}

.home-brand-icon {
    width: 56px; height: 56px; border-radius: 14px;
    background: rgba(255,255,255,0.15);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.home-brand-title {
    color: #fff; font-size: 20px; font-weight: 700; line-height: 1.3;
}
.home-brand-sub { color: #93c5fd; font-size: 15px; }

/* Action Grid */
.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
    width: 100%;
}

.action-card {
    display: flex; flex-direction: column; align-items: center;
    text-align: center; gap: 10px;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    padding: 24px 12px;
    text-decoration: none; color: var(--ink);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    cursor: pointer;
}

.action-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(30,58,138,0.12);
    border-color: #93c5fd;
    color: var(--ink);
}

.action-primary { border-color: #bfdbfe; background: #f0f7ff; }
.action-primary:hover { border-color: #2563eb; }

.action-icon-wrap {
    width: 60px; height: 60px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
}

.action-label {
    font-size: 16px; font-weight: 700; color: var(--ink);
    line-height: 1.3;
}
.action-desc { font-size: 13px; color: var(--muted); }

/* Info Note */
.home-note {
    display: flex; align-items: flex-start; gap: 8px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 16px;
    color: #475569; font-size: 14px; line-height: 1.6;
    width: 100%;
}

/* =============================================
   FORM PAGES (other pages keep existing styles)
   ============================================= */
.page-heading { margin-bottom: 18px; }
.page-heading h1 { margin: 0; font-size: 24px; font-weight: 700; color: var(--ink); }
.page-heading p  { margin: 4px 0 0; color: var(--muted); }

.form-section {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 22px;
    box-shadow: 0 2px 12px rgba(30,58,138,0.05);
}

.section-title {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 16px; color: var(--brand); font-size: 17px; font-weight: 700;
}
.section-title::before {
    content: ""; width: 4px; height: 20px;
    border-radius: 999px; background: var(--brand);
}

.form-label  { color: #334155; font-weight: 600; font-size: 15px; }
.required::after { content: " *"; color: var(--danger); }

.form-control, .form-select {
    min-height: 42px; border-color: #cbd5e1; border-radius: 8px;
    font-size: 16px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.btn { border-radius: 8px; font-weight: 600; font-size: 16px; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }

/* Status Pills */
.status-pill {
    display: inline-flex; align-items: center; min-height: 28px;
    padding: 3px 12px; border-radius: 999px;
    background: var(--brand-soft); color: var(--brand);
    font-weight: 700; font-size: 14px; white-space: nowrap;
}
.status-success { background: #d1fae5; color: #065f46; }
.status-warning { background: #fef3c7; color: #92400e; }
.status-danger  { background: #fee2e2; color: #991b1b; }
.status-muted   { background: #f1f5f9; color: #475569; }
.status-info    { background: var(--brand-soft); color: var(--brand); }

/* Workflow */
.workflow {
    display: grid; grid-template-columns: repeat(3,1fr); gap: 10px;
}
.workflow-step {
    border: 1px solid var(--line); border-radius: 8px;
    padding: 12px; background: #f8fafc;
}
.workflow-step.is-done   { border-color: #6ee7b7; background: #ecfdf5; }
.workflow-step.is-active { border-color: #fbbf24; background: #fffbeb; }
.workflow-step-title { color: var(--ink); font-weight: 700; }
.workflow-step-meta  { color: var(--muted); font-size: 13px; margin-top: 3px; }

/* Stats */
.stat-grid {
    display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 14px;
}
.stat-tile { padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--brand); }
.stat-label { color: var(--muted); font-size: 13px; }

/* Tables */
.table { margin-bottom: 0; }
.table thead th { background: #f8fafc; color: #475569; font-size: 15px; border-bottom: 1px solid var(--line); }
.table td { border-color: #e5e7eb; font-size: 15px; }

/* Login */
.login-panel { max-width: 520px; }
.helper-note { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; color: #475569; }

/* =============================================
   VEHICLE STATUS BOARD
   ============================================= */
.vehicle-board {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

.vcard {
    border-radius: 14px;
    border: 2px solid;
    padding: 16px 14px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    transition: transform 0.18s, box-shadow 0.18s;
    position: relative;
    overflow: hidden;
}
.vcard:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.10); }

.vcard-free {
    border-color: #bbf7d0;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    color: #166534;
}
.vcard-busy {
    border-color: #fca5a5;
    background: linear-gradient(135deg, #fff1f2 0%, #fee2e2 100%);
    color: #991b1b;
}

.vcard-icon {
    opacity: 1;
    display: flex; align-items: center; justify-content: center;
    height: 52px;
}

.vcard-body { width: 100%; }

.vcard-name {
    font-size: 13px; font-weight: 700; line-height: 1.3;
    margin-bottom: 2px;
}
.vcard-plate {
    font-size: 13px; font-weight: 600;
    background: rgba(0,0,0,0.06);
    border-radius: 6px; padding: 2px 8px; display: inline-block;
    margin-bottom: 6px; letter-spacing: 0.5px;
}

.vcard-status-badge {
    display: inline-block; font-size: 12px; font-weight: 700;
    border-radius: 99px; padding: 2px 10px;
}
.badge-free { background: #16a34a; color: #fff; }
.badge-busy { background: #dc2626; color: #fff; }

.vcard-info {
    margin-top: 8px; text-align: left;
    border-top: 1px solid rgba(0,0,0,0.08);
    padding-top: 6px;
}
.vcard-info-row {
    display: flex; align-items: flex-start; gap: 4px;
    font-size: 12px; color: inherit; opacity: 0.85;
    margin-bottom: 2px;
}
.vcard-info-icon { flex-shrink: 0; }

@media (max-width: 640px) {
    .vehicle-board { grid-template-columns: 1fr 1fr; gap: 10px; }
    .vcard { padding: 12px 10px; }
}

/* =============================================
   FOOTER
   ============================================= */
.site-footer {
    background: var(--brand-dark);
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 20px 16px;
    text-align: center;
}
.footer-inner { max-width: 1100px; margin: 0 auto; }
.footer-dept {
    color: #93c5fd; font-size: 15px; font-weight: 600; margin: 0 0 4px;
}
.footer-copy { color: #475569; font-size: 13px; margin: 0; }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 640px) {
    .main-nav   { display: none; }
    .nav-toggle { display: block; }

    .home-brand { padding: 16px 18px; gap: 12px; }
    .home-brand-title { font-size: 17px; }

    .action-grid { grid-template-columns: 1fr; gap: 10px; }
    .action-card { flex-direction: row; text-align: left; padding: 16px 18px; gap: 14px; }
    .action-icon-wrap { width: 50px; height: 50px; flex-shrink: 0; }

    .workflow, .stat-grid { grid-template-columns: 1fr; }
}
