@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #8408CB;
    --primary-dark: #6200A3;
    --primary-light: #A030E0;
    --primary-ultra-light: #F3E5FF;
    --bg: #F0E6FF;
    --bg-card: #ffffff;
    --text-main: #1A0033;
    --text-sub: #5A3080;
    --border: #D4A8F0;
    --shadow: rgba(132, 8, 203, 0.15);
    --error: #E53935;
    --success: #2E7D32;
    --success-bg: #E8F5E9;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Sarabun', sans-serif;
    background-color: var(--bg);
    min-height: 100vh;
    color: var(--text-main);
}

/* HEADER */
.site-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
    padding: 18px 40px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: 0 4px 20px rgba(100, 0, 160, 0.3);
    position: relative;
    overflow: hidden;
}
.site-header::before {
    content: '';
    position: absolute;
    top: -40px; right: -40px;
    width: 200px; height: 200px;
    border-radius: 50%;
    background: rgba(255,255,255,0.07);
}
.site-header::after {
    content: '';
    position: absolute;
    bottom: -60px; left: 30%;
    width: 280px; height: 150px;
    border-radius: 50%;
    background: rgba(255,215,0,0.06);
}
.header-logo {
    width: 64px; height: 64px;
    object-fit: contain;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
    flex-shrink: 0; z-index: 1;
}
.header-text { z-index: 1; }
.header-text h1 {
    color: #fff; font-size: 1.35rem; font-weight: 700;
    line-height: 1.3; text-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.header-text p { color: rgba(255,255,255,0.8); font-size: 0.9rem; margin-top: 3px; }

/* LAYOUT */
.page-wrapper {
    display: flex; justify-content: center; align-items: flex-start;
    padding: 40px 20px 60px;
    min-height: calc(100vh - 100px);
}
.card {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: 0 8px 40px var(--shadow), 0 2px 8px rgba(0,0,0,0.06);
    width: 100%; max-width: 560px;
    overflow: hidden;
}
.card-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    padding: 22px 28px;
    display: flex; align-items: center; gap: 14px;
}
.card-header-icon {
    background: rgba(255,255,255,0.2);
    border-radius: 10px; padding: 10px;
    display: flex; align-items: center; justify-content: center;
}
.card-header-icon i { color: #fff; font-size: 1.3rem; }
.card-header-text h2 { color: #fff; font-size: 1.2rem; font-weight: 700; }
.card-header-text p { color: rgba(255,255,255,0.8); font-size: 0.85rem; margin-top: 2px; }
.card-body { padding: 28px; }

/* FORM */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 18px; }
.form-group label {
    display: flex; align-items: center; gap: 7px;
    font-size: 0.9rem; font-weight: 600;
    color: var(--text-sub); margin-bottom: 7px;
}
.form-group label i { color: var(--primary); font-size: 0.85rem; }
.required { color: var(--error); font-size: 0.8rem; }

input[type="text"], input[type="email"], input[type="tel"],
input[type="password"], textarea, select {
    width: 100%; padding: 11px 14px;
    border: 1.5px solid var(--border); border-radius: 8px;
    font-family: 'Sarabun', sans-serif; font-size: 0.95rem;
    color: var(--text-main); background: #FAFAFA;
    transition: all 0.2s ease; outline: none;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--primary); background: #fff;
    box-shadow: 0 0 0 3px rgba(132, 8, 203, 0.1);
}
textarea { resize: vertical; min-height: 110px; line-height: 1.6; }
select {
    cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238408CB' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
    padding-right: 36px;
}

/* BUTTONS */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white; padding: 13px 20px; border: none; border-radius: 8px;
    cursor: pointer; font-family: 'Sarabun', sans-serif;
    font-size: 1rem; font-weight: 700; width: 100%;
    display: flex; justify-content: center; align-items: center; gap: 10px;
    transition: all 0.25s ease; box-shadow: 0 4px 15px rgba(132, 8, 203, 0.35);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    transform: translateY(-2px); box-shadow: 0 6px 20px rgba(132, 8, 203, 0.45);
}
.btn-secondary {
    background: #F3E5FF; color: var(--primary);
    padding: 10px 18px; border: 1.5px solid var(--border); border-radius: 8px;
    cursor: pointer; font-family: 'Sarabun', sans-serif;
    font-size: 0.9rem; font-weight: 600;
    display: inline-flex; align-items: center; gap: 8px;
    text-decoration: none; transition: all 0.2s ease;
}
.btn-secondary:hover { background: var(--primary-ultra-light); border-color: var(--primary); }

/* ALERTS */
.alert-success {
    background: var(--success-bg); border: 1px solid #A5D6A7;
    color: var(--success); border-radius: 10px; padding: 14px 18px;
    margin-bottom: 22px; display: flex; align-items: center; gap: 10px;
    font-weight: 600; font-size: 0.95rem;
}
.alert-error {
    background: #FFEBEE; border: 1px solid #FFCDD2; color: var(--error);
    border-radius: 10px; padding: 14px 18px; margin-bottom: 22px;
    display: flex; align-items: center; gap: 10px; font-weight: 600;
}

/* FOOTER */
.site-footer {
    text-align: center; padding: 20px;
    color: var(--text-sub); font-size: 0.82rem; opacity: 0.7;
}

/* ADMIN TABLE */
.admin-wrapper { padding: 30px 24px; max-width: 1200px; margin: 0 auto; }
.admin-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-title { font-size: 1.4rem; font-weight: 700; color: var(--text-main); display: flex; align-items: center; gap: 10px; }
.page-title i { color: var(--primary); }
.stat-badge {
    background: var(--primary-ultra-light); color: var(--primary);
    border: 1px solid var(--border); border-radius: 20px;
    padding: 5px 14px; font-size: 0.85rem; font-weight: 600;
}
.table-card { background: #fff; border-radius: 14px; box-shadow: 0 4px 24px var(--shadow); overflow: hidden; }

table { width: 100%; border-collapse: collapse; }
thead { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); }
thead th {
    color: #fff; font-weight: 600; padding: 14px 16px;
    text-align: left; font-size: 0.88rem; white-space: nowrap;
}
tbody tr { border-bottom: 1px solid #F0E6FF; transition: background 0.15s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #FAF0FF; }
tbody td { padding: 12px 16px; font-size: 0.9rem; color: var(--text-main); vertical-align: middle; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-view {
    background: #E3F2FD; color: #1565C0; border: 1px solid #BBDEFB;
    padding: 5px 12px; border-radius: 6px; font-size: 0.82rem; font-weight: 600;
    text-decoration: none; display: inline-flex; align-items: center; gap: 5px;
    transition: all 0.2s; white-space: nowrap;
}
.btn-view:hover { background: #BBDEFB; }
.btn-edit {
    background: #FFF8E1; color: #E65100; border: 1px solid #FFE082;
    padding: 5px 12px; border-radius: 6px; font-size: 0.82rem; font-weight: 600;
    text-decoration: none; display: inline-flex; align-items: center; gap: 5px;
    transition: all 0.2s; white-space: nowrap;
}
.btn-edit:hover { background: #FFE082; }
.btn-del {
    background: #FFEBEE; color: #C62828; border: 1px solid #FFCDD2;
    padding: 5px 12px; border-radius: 6px; font-size: 0.82rem; font-weight: 600;
    text-decoration: none; display: inline-flex; align-items: center; gap: 5px;
    transition: all 0.2s; white-space: nowrap;
}
.btn-del:hover { background: #FFCDD2; }

/* STATUS */
.status-badge { padding: 4px 10px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; display: inline-block; }
.status-pending { background: #FFF8E1; color: #F57F17; border: 1px solid #FFE082; }
.status-processing { background: #E3F2FD; color: #1565C0; border: 1px solid #90CAF9; }
.status-done { background: var(--success-bg); color: var(--success); border: 1px solid #A5D6A7; }

/* DETAIL */
.detail-grid { display: grid; gap: 14px; }
.detail-item { background: #FAFAFA; border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; }
.detail-item .detail-label {
    font-size: 0.82rem; font-weight: 600; color: var(--text-sub);
    margin-bottom: 5px; display: flex; align-items: center; gap: 7px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.detail-item .detail-label i { color: var(--primary); }
.detail-item .detail-value { font-size: 0.95rem; color: var(--text-main); line-height: 1.6; }

/* LOGIN */
.login-page {
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #F3E5FF 0%, #E8D5FF 50%, #F0E6FF 100%);
}
.login-card {
    background: #fff; border-radius: 20px;
    box-shadow: 0 20px 60px rgba(132, 8, 203, 0.2), 0 4px 16px rgba(0,0,0,0.08);
    padding: 40px 36px; width: 100%; max-width: 380px;
}
.login-logo-wrap { text-align: center; margin-bottom: 28px; }
.login-logo { width: 80px; height: 80px; object-fit: contain; margin-bottom: 12px; }
.login-title { font-size: 1.2rem; font-weight: 700; color: var(--primary); }
.login-subtitle { font-size: 0.85rem; color: var(--text-sub); margin-top: 4px; }

@media (max-width: 600px) {
    .site-header { padding: 14px 20px; }
    .header-text h1 { font-size: 1.05rem; }
    .header-logo { width: 50px; height: 50px; }
    .form-row { grid-template-columns: 1fr; gap: 0; }
    .card-body { padding: 20px; }
    .admin-wrapper { padding: 16px 12px; }
    .actions { flex-direction: column; }
}
