/* ============================================================
   TALAS Admin panel
   ============================================================ */
:root {
    --navy:   #0a2a66;
    --navy-2: #103a86;
    --blue:   #1f6fe0;
    --ink:    #2b3445;
    --muted:  #6b7689;
    --line:   #e4e9f1;
    --bg:     #f1f5fb;
    --sidebar:#0b1f48;
    --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Poppins','Sarabun',system-ui,sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; }
a { color: var(--blue); text-decoration: none; }
h1,h2,h3,h4 { color: var(--navy); }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(120deg, #07235a, #103a86); padding: 20px; }
.login-card { background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 30px 60px rgba(0,0,0,.3); }
.login-card .brand-mini { text-align: center; margin-bottom: 18px; }
.login-card .brand-mini img { width: 60px; border-radius: 50%; display: inline-block; }
.login-card h1 { text-align: center; font-size: 22px; margin: 8px 0 4px; }
.login-card p.muted { text-align: center; color: var(--muted); margin: 0 0 24px; font-size: 14px; }

/* Layout */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar { width: 250px; background: var(--sidebar); color: #c7d3ec; flex-shrink: 0; display: flex; flex-direction: column; }
.sidebar .logo { display: flex; align-items: center; gap: 10px; padding: 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .logo img { width: 38px; border-radius: 50%; }
.sidebar .logo span { font-weight: 800; font-size: 20px; color: #fff; letter-spacing: 1px; }
.sidebar nav { padding: 14px 0; flex: 1; }
.sidebar nav .group-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #6f82ad; padding: 16px 22px 6px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 11px 22px; color: #c7d3ec; font-size: 14px; border-left: 3px solid transparent; }
.sidebar nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar nav a.active { background: rgba(31,111,224,.18); border-left-color: var(--blue); color: #fff; }
.sidebar .ico { width: 18px; text-align: center; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 14px 28px; display: flex; align-items: center; justify-content: space-between; }
.topbar .who { display: flex; align-items: center; gap: 12px; }
.topbar .who .avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.topbar .who small { color: var(--muted); display: block; }
.content { padding: 28px; flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { font-size: 26px; margin: 0; }

/* Cards / stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 18px; margin-bottom: 28px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.stat-card .n { font-size: 32px; font-weight: 800; color: var(--navy); }
.stat-card .l { color: var(--muted); font-size: 14px; }
.stat-card .ico-big { float: right; font-size: 26px; opacity: .25; }

.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 22px; }
.card h2, .card h3 { margin-top: 0; }

/* Tables */
table.data { width: 100%; border-collapse: collapse; background: #fff; }
table.data th, table.data td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
table.data th { background: #f6f9fd; color: #41506b; font-weight: 600; }
table.data tr:hover td { background: #fafcff; }
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }

/* Badges */
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag-green { background: #e3f6ea; color: #1d7a43; }
.tag-amber { background: #fff2da; color: #9a6b12; }
.tag-red   { background: #fde8e8; color: #b42323; }
.tag-grey  { background: #eef1f6; color: #5a667a; }
.tag-blue  { background: #e6f0fd; color: #1d5bb0; }

/* Buttons */
.btn { display: inline-block; padding: 9px 18px; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; border: 1px solid transparent; transition: .15s; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1860c8; }
.btn-light { background: #eef2f8; color: #36425a; }
.btn-light:hover { background: #e2e9f3; }
.btn-danger { background: #e23b3b; color: #fff; }
.btn-danger:hover { background: #c92e2e; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-success { background: #1d9a52; color:#fff; }

.actions { white-space: nowrap; }
.actions .btn, .actions .inline-form { margin-right: 8px; }
.actions .btn:last-child, .actions .inline-form:last-child { margin-right: 0; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 16px; }
.form-group.full { grid-column: 1 / -1; }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
input[type=text],input[type=email],input[type=tel],input[type=password],input[type=date],input[type=number],input[type=file],select,textarea {
    width: 100%; padding: 10px 12px; border: 1px solid #cdd7e6; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
input:focus,select:focus,textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31,111,224,.15); }
textarea { min-height: 160px; resize: vertical; }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.inline-form { display: inline; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 16px; }
.checkbox-item { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; }
.checkbox-item input[type=checkbox] { width: auto; margin: 0; }

/* Read-only detail views */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.detail-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.detail-value { display: block; font-size: 15px; color: var(--ink); }
.detail-note { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.detail-note p { margin: 6px 0 0; white-space: pre-line; }
.pw-field { position: relative; display: block; }
.pw-field input[type=password], .pw-field input[type=text] { padding-right: 44px; }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; justify-content: center; background: none; border: 0; padding: 4px; cursor: pointer; color: #8a96aa; }
.pw-toggle:hover { color: var(--blue); }

/* Pagination */
.pagination { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 18px; }
.pagination .page-link { display: inline-block; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: #41506b; font-size: 14px; font-weight: 600; text-decoration: none; }
.pagination a.page-link:hover { border-color: var(--blue); color: var(--blue); }
.pagination .page-link.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.pagination .page-link.disabled { color: #aab3c2; background: #f6f8fb; cursor: default; }
.pagination .page-ellipsis { padding: 0 4px; color: var(--muted); }
.list-meta { color: var(--muted); font-size: 13px; margin: 14px 0 0; }

/* Rich text editor (Quill) */
.rich-editor { background: #fff; border-radius: 0 0 8px 8px; }
.rich-editor .ql-editor { height: auto; min-height: 240px; max-height: 480px; overflow-y: auto; font-size: 14.5px; font-family: inherit; }
.rich-editor .ql-editor img { max-width: 100%; height: auto; border-radius: 6px; }
.rich-editor.ql-container { height: auto; border: 1px solid #cdd7e6; border-top: 0; max-width: 100%; }
.ql-toolbar.ql-snow { border: 1px solid #cdd7e6; border-radius: 8px 8px 0 0; background: #f7f9fc; }
.ql-snow .ql-picker { font-family: inherit; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.alert-success { background: #e7f7ed; color: #1d7a43; border: 1px solid #b8e6c9; }
.alert-error { background: #fdeaea; color: #b42323; border: 1px solid #f3c4c4; }
.alert-info { background: #e8f1fd; color: #1d5bb0; border: 1px solid #c3dcf7; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input, .filters select { width: auto; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px; }
.thumb-sm { width: 54px; height: 42px; object-fit: cover; border-radius: 6px; }

@media (max-width: 800px) {
    .sidebar { position: fixed; left: -260px; top: 0; bottom: 0; z-index: 100; transition: .25s; }
    .sidebar.open { left: 0; }
    .form-grid { grid-template-columns: 1fr; }
    .menu-toggle { display: inline-block !important; }
}
.menu-toggle { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; }
