/* สไตล์ส่วนหลังบ้าน */
:root {
    --primary: #2563eb;
    --primary-light: #eff6ff;
    --text: #1f2937;
    --muted: #6b7280;
    --bg: #f1f5f9;
    --card: #ffffff;
    --border: #e2e8f0;
    --radius: 12px;
}
* { box-sizing: border-box; }
body { font-family: 'Prompt', sans-serif; background: var(--bg); color: var(--text); margin: 0; }
a { text-decoration: none; }

.admin-layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px; background: #0f172a; color: #cbd5e1; flex-shrink: 0;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.side-brand { padding: 22px 20px; font-weight: 600; font-size: 1.05rem; color: #fff; border-bottom: 1px solid #1e293b; display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 30px; width: auto; border-radius: 6px; background: #fff; padding: 2px; }
.side-nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; }
.side-nav a {
    color: #cbd5e1; padding: 11px 16px; border-radius: 10px; font-size: .92rem; font-weight: 500;
    display: flex; align-items: center; gap: 12px; transition: all .15s;
}
.side-nav a:hover { background: #1e293b; color: #fff; }
.side-nav a.active { background: var(--primary); color: #fff; }
.side-nav a i { width: 18px; text-align: center; }

.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.admin-topbar {
    height: 64px; background: var(--card); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 28px;
    position: sticky; top: 0; z-index: 10;
}
.page-title { font-weight: 600; font-size: 1.1rem; }
.admin-user { color: var(--muted); font-size: .9rem; }
.admin-content { padding: 28px; flex: 1; }
.admin-footer { text-align: center; padding: 18px; color: var(--muted); font-size: .82rem; border-top: 1px solid var(--border); }

/* Cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 28px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: 0 2px 10px rgba(0,0,0,.04); display: flex; align-items: center; gap: 16px; }
.stat-card .ic { width: 52px; height: 52px; border-radius: 14px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-card .num { font-size: 1.7rem; font-weight: 600; line-height: 1; }
.stat-card .lbl { color: var(--muted); font-size: .88rem; margin-top: 4px; }

.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: 0 2px 10px rgba(0,0,0,.04); margin-bottom: 24px; }
.panel h3 { margin: 0 0 18px; font-size: 1.1rem; font-weight: 600; }

/* Tables */
.table-custom { width: 100%; border-collapse: collapse; }
.table-custom th, .table-custom td { padding: 13px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: .9rem; }
.table-custom th { color: var(--muted); font-weight: 500; background: #f8fafc; }
.table-custom tr:hover td { background: #f8fafc; }
.table-custom .col-no { width: 76px; white-space: nowrap; }
.table-custom .col-book { width: 160px; white-space: nowrap; font-family: monospace; font-size: .85rem; }
.badge-soft { background: var(--primary-light); color: var(--primary); padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 500; }

/* Pagination */
.admin-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 24px 0 0;
}
.admin-pagination a,
.admin-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    padding: 9px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
    font-size: .9rem;
    line-height: 1;
}
.admin-pagination a:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}
.admin-pagination .active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Buttons */
.btn-add { display: inline-flex; align-items: center; gap: 8px; background: var(--primary); color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 500; font-size: .9rem; border: none; cursor: pointer; transition: all .15s; }
.btn-add:hover { background: #1d4ed8; color: #fff; }
.btn-sm-edit { color: var(--primary); }
.btn-sm-del { color: #dc2626; }
.action-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }

/* Forms */
.form-label { font-weight: 500; font-size: .9rem; margin-bottom: 6px; display: block; }
.form-control, .form-select { width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px; font-family: inherit; font-size: .92rem; }
.form-control:focus, .form-select:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-light); }
.form-text { color: var(--muted); font-size: .8rem; margin-top: 5px; }
.mb-3 { margin-bottom: 18px; }
.attach-row { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; padding: 12px; border: 1px dashed var(--border); border-radius: 10px; }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#1e3a8a,#2563eb); padding: 20px; }
.login-box { width: 100%; max-width: 340px; }
.login-brand { text-align: center; margin-bottom: 18px; color: #fff; }
.login-logo { height: 46px; width: auto; border-radius: 12px; background: #fff; padding: 5px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.login-brand-name { font-size: 1.15rem; font-weight: 600; margin-top: 10px; text-shadow: 0 2px 10px rgba(0,0,0,.2); letter-spacing: .3px; }
.login-brand-sub { font-size: .8rem; opacity: .85; margin-top: 2px; }
.login-card-body { background: rgba(255,255,255,.98); border-radius: 20px; padding: 28px 26px; box-shadow: 0 24px 70px rgba(0,0,0,.28); backdrop-filter: blur(4px); }
.login-title { text-align: center; margin: 0 0 22px; font-size: 1.05rem; font-weight: 600; color: var(--text); }
.login-card-body .form-control { padding: 10px 14px; font-size: .9rem; }
.login-divider { display: flex; align-items: center; text-align: center; margin: 16px 0; color: var(--muted); font-size: .82rem; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.login-divider span { padding: 0 12px; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#1e3a8a,#2563eb); padding: 20px; }
.login-wrapper { width: 100%; max-width: 420px; }
.login-panel { background: #fff; border-radius: 16px; padding: 40px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.login-panel h3 { text-align: center; margin: 0 0 26px; font-weight: 600; }
.login-card { background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.login-card h2 { text-align: center; margin: 0 0 6px; font-weight: 600; }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 26px; font-size: .9rem; }
.login-card .btn-login { width: 100%; background: var(--primary); color: #fff; border: none; padding: 12px; border-radius: 10px; font-weight: 500; font-size: 1rem; cursor: pointer; }
.login-card .btn-login:hover { background: #1d4ed8; }

@media (max-width: 768px) {
    .sidebar { width: 64px; }
    .side-brand { font-size: 0; padding: 18px 0; text-align: center; }
    .side-brand i { font-size: 1.3rem; }
    .side-nav a span { display: none; }
    .side-nav a { justify-content: center; }
    .admin-content { padding: 16px; }
}
