/* ─── CSS Custom Properties ─── */
:root {
    --primary:        #7C3AED;
    --primary-dark:   #5B21B6;
    --primary-light:  #A855F7;
    --primary-bg:     #F5F3FF;
    --accent-grad:    linear-gradient(135deg, #7C3AED, #A855F7);
    --text-dark:      #1E1B4B;
    --text-mid:       #4B5563;
    --surface:        #FFFFFF;
    --page-bg:        #F8F7FF;
    --border:         #E5E7EB;
    --shadow-card:    0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(124,58,237,.06);
    --radius-card:    16px;
    --radius-btn:     999px;
    --radius-input:   10px;
    --nav-height:     60px;
}

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: 'Sarabun', sans-serif;
    background: var(--page-bg);
    margin: 0;
    color: var(--text-dark);
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }

/* ─── Animations ─── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInScale {
    from { opacity: 0; transform: scale(.94); }
    to   { opacity: 1; transform: scale(1); }
}

/* ─── Top Navigation ─── */
.app-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: var(--nav-height);
    padding: 0 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 4px rgba(124,58,237,.07);
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.nav-brand img {
    height: 36px;
    width: auto;
    border-radius: 6px;
}
.nav-title {
    font-weight: 700;
    font-size: 17px;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.nav-right {
    display: flex;
    gap: 10px;
    align-items: center;
}
.nav-user {
    font-size: 13px;
    color: var(--text-mid);
    font-weight: 600;
}

/* ─── Page Title ─── */
.page-title {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    margin: 28px 0 16px;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: none;
    border-radius: var(--radius-btn);
    padding: 9px 20px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    transition: transform .18s, box-shadow .18s, opacity .18s;
    white-space: nowrap;
    text-decoration: none;
}
.btn:hover { transform: translateY(-2px); }

.btn-primary {
    background: var(--accent-grad);
    color: #fff;
    box-shadow: 0 2px 10px rgba(124,58,237,.28);
}
.btn-primary:hover {
    box-shadow: 0 4px 18px rgba(124,58,237,.40);
    opacity: .93;
}

.btn-success {
    background: #059669;
    color: #fff;
    box-shadow: 0 2px 8px rgba(5,150,105,.25);
}
.btn-success:hover { box-shadow: 0 4px 14px rgba(5,150,105,.38); }

.btn-danger {
    background: #DC2626;
    color: #fff;
    box-shadow: 0 2px 8px rgba(220,38,38,.22);
}
.btn-danger:hover { box-shadow: 0 4px 14px rgba(220,38,38,.35); }

.btn-secondary {
    background: #F3F4F6;
    color: #374151;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.btn-secondary:hover { background: #E5E7EB; }

.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ─── Cards ─── */
.card {
    background: var(--surface);
    border-radius: var(--radius-card);
    padding: 30px 35px;
    box-shadow: var(--shadow-card);
    animation: fadeIn .4s ease;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
}
.card-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ─── Alerts ─── */
.alert {
    padding: 12px 18px;
    border-radius: 10px;
    font-weight: 600;
    margin-bottom: 18px;
    font-size: 14px;
    border-left: 4px solid;
}
.alert-success { background: #ECFDF5; color: #065F46; border-color: #10B981; }
.alert-warning  { background: #FFFBEB; color: #92400E; border-color: #F59E0B; }
.alert-error    { background: #FEF2F2; color: #991B1B; border-color: #EF4444; }
.alert-info     { background: var(--primary-bg); color: var(--primary-dark); border-color: var(--primary); }

/* ─── Tables ─── */
.table-wrap {
    width: 92%;
    margin: 0 auto 36px;
    background: var(--surface);
    border-radius: var(--radius-card);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    animation: fadeIn .45s ease;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table thead {
    background: var(--accent-grad);
}
.data-table th {
    padding: 13px 15px;
    text-align: center;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .02em;
}
.data-table td {
    padding: 12px 15px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-mid);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--primary-bg); }
.data-table .empty {
    text-align: center;
    color: #9CA3AF;
    font-style: italic;
    padding: 32px;
}

/* ─── Status Badges ─── */
.badge {
    padding: 4px 12px;
    border-radius: 999px;
    font-weight: 700;
    display: inline-block;
    font-size: 12px;
    letter-spacing: .03em;
}
.badge-WAIT_MANAGER { background: #FEF3C7; color: #92400E; }
.badge-WAIT_HR      { background: #EDE9FE; color: #5B21B6; }
.badge-APPROVED     { background: #D1FAE5; color: #065F46; }
.badge-REJECTED     { background: #FEE2E2; color: #991B1B; }
.badge-COMPLETED    { background: #F3F4F6; color: #6B7280; }

/* ─── Forms ─── */
.form-group { margin-top: 16px; }
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-dark);
    font-size: 14px;
}
.form-control {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid #D1D5DB;
    border-radius: var(--radius-input);
    background: #FAFAFA;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-dark);
    transition: border-color .2s, box-shadow .2s;
    outline: none;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124,58,237,.15);
    background: #fff;
}

/* ─── HR Menu Cards ─── */
.menu-grid {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 30px auto;
    flex-wrap: wrap;
    max-width: 900px;
    padding: 0 20px;
}
.menu-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-card);
    padding: 28px 22px;
    text-align: center;
    width: 220px;
    box-shadow: var(--shadow-card);
    transition: transform .22s, box-shadow .22s, border-color .22s;
    cursor: pointer;
    display: block;
    animation: fadeIn .4s ease;
}
.menu-card:hover {
    transform: translateY(-5px) scale(1.03);
    box-shadow: 0 8px 28px rgba(124,58,237,.18);
    border-color: var(--primary-light);
}
.menu-card .menu-icon {
    font-size: 36px;
    display: block;
    margin-bottom: 14px;
}
.menu-card h3 {
    color: var(--primary-dark);
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 700;
}
.menu-card p {
    color: var(--text-mid);
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
}

/* ─── Popup / Modal ─── */
.popup-overlay {
    display: none;
    position: fixed;
    z-index: 999;
    left: 0; top: 0; width: 100%; height: 100%;
    background: rgba(30, 27, 75, .55);
    justify-content: center;
    align-items: center;
    padding: 16px;
    backdrop-filter: blur(2px);
}
.popup-box {
    background: var(--surface);
    padding: 30px 28px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 12px 40px rgba(124,58,237,.22);
    width: 90%;
    max-width: 420px;
    animation: fadeInScale .3s ease;
}
.popup-box img {
    width: 200px;
    max-width: 65vw;
    height: auto;
    border: 4px solid var(--primary-light);
    border-radius: 14px;
    margin-bottom: 16px;
}
.popup-box h3 {
    margin: 0 0 12px;
    color: var(--text-dark);
    font-size: 18px;
}
.popup-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 18px;
}

/* ─── Filter Bar ─── */
.filter-bar {
    width: 92%;
    margin: 20px auto;
    background: var(--surface);
    padding: 16px 20px;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-items: center;
}
.filter-bar input[type="text"],
.filter-bar input[type="date"],
.filter-bar select {
    padding: 9px 13px;
    border: 1.5px solid #D1D5DB;
    border-radius: var(--radius-input);
    font-size: 14px;
    font-family: inherit;
    color: var(--text-dark);
    background: #FAFAFA;
    outline: none;
    transition: border-color .2s;
}
.filter-bar input:focus,
.filter-bar select:focus {
    border-color: var(--primary);
}

/* ─── Modal ─── */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0; top: 0; width: 100%; height: 100%;
    background: rgba(30, 27, 75, .45);
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}
.modal-box {
    background: var(--surface);
    padding: 28px 30px;
    border-radius: 18px;
    width: 460px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 36px rgba(124,58,237,.2);
    animation: fadeInScale .3s ease;
}
.modal-box h3 {
    text-align: center;
    margin: 0 0 18px;
    font-size: 18px;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ─── Employee Info Chip ─── */
#emp_info {
    text-align: center;
    margin-top: 8px;
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-dark);
    background: var(--primary-bg);
    padding: 8px 14px;
    border-radius: 8px;
    display: none;
    border-left: 3px solid var(--primary);
}

/* ─── Login Page ─── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: var(--page-bg);
}
.login-card {
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    width: 100%;
    max-width: 420px;
    padding: 40px 36px;
    border-radius: 24px;
    box-shadow: 0 8px 40px rgba(124,58,237,.14), 0 1px 3px rgba(0,0,0,.06);
    text-align: center;
    animation: fadeInScale .4s ease;
    border: 1px solid rgba(124,58,237,.1);
}
.login-logo-area {
    margin-bottom: 24px;
}
.login-logo-area img {
    height: 56px;
    width: auto;
    border-radius: 10px;
    margin-bottom: 12px;
}
.login-title {
    font-size: 22px;
    font-weight: 700;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}
.login-subtitle {
    font-size: 13px;
    color: var(--text-mid);
    margin: 6px 0 0;
}
.back-link {
    display: inline-block;
    margin-top: 18px;
    color: var(--primary);
    font-weight: 600;
    font-size: 14px;
    transition: opacity .18s;
}
.back-link:hover { opacity: .75; text-decoration: underline; }

/* ─── Section headings ─── */
.section-title {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    margin: 28px 0 12px;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .app-nav { padding: 0 16px; }
    .nav-title { font-size: 14px; }
    .table-wrap { width: 100%; border-radius: 0; }
    .data-table th, .data-table td { padding: 9px 8px; font-size: 12px; }
    .filter-bar { flex-direction: column; width: 100%; border-radius: 0; }
    .card { padding: 20px 16px; }
    .menu-grid { gap: 14px; }
    .menu-card { width: 100%; max-width: 320px; }
}
@media (max-width: 480px) {
    .login-card { padding: 28px 20px; }
    .nav-user { display: none; }
}

/* ─── Print ─── */
@media print {
    .app-nav, .filter-bar, .no-print { display: none !important; }
    .table-wrap { box-shadow: none; border: 1px solid #ccc; }
    .data-table thead { background: #ddd; }
    .data-table th { color: #000; }
}
