/* GMHS Admin — Polished, smooth, Vietnamese-ready (Be Vietnam Pro) */
* { box-sizing: border-box; }
:root {
  --header: #0b2545;
  --header-light: #13315c;
  --accent: #a3c1ad;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #0b2545;
  --primary-hover: #13315c;
  --success: #059669;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15,23,42,0.08), 0 4px 12px rgba(15,23,42,0.06);
  --shadow-lg: 0 8px 24px rgba(15,23,42,0.12);
}
.layout { display:flex; min-height:100vh; }
.sidebar { width:240px; min-width:240px; background: var(--header); color:#fff; display:flex; flex-direction:column; position:sticky; top:0; height:100vh; overflow:auto; }
.sidebar-header { padding:16px; border-bottom:1px solid rgba(255,255,255,0.1); font-weight:800; }
.sidebar-nav { padding:12px 8px; display:flex; flex-direction:column; gap:4px; flex:1; }
.nav-item { width:100%; text-align:left; padding:8px 12px; border:none; background: transparent; color: rgba(255,255,255,0.85); border-radius:8px; cursor:pointer; font-size:13px; font-weight:600; transition: all 0.15s; }
.nav-item:hover { background: rgba(255,255,255,0.1); color:#fff; }
.nav-item.active { background:#fff; color: var(--primary); }
.nav-item.sub { padding-left:24px; font-size:12px; }
.nav-group .nav-sub { display:flex; flex-direction:column; gap:4px; margin-top:4px; }
.nav-group.collapsed .nav-sub { display:none; }
.sidebar-footer { padding:12px; border-top:1px solid rgba(255,255,255,0.1); display:flex; flex-direction:column; gap:8px; }
.main-wrap { flex:1; display:flex; flex-direction:column; min-width:0; }
.topbar { position:sticky; top:0; z-index:5; }
@media (max-width:900px){ .sidebar{ position:fixed; left:-240px; transition:left 0.2s; z-index:20; } .sidebar.open{ left:0; } .main-wrap{ margin-left:0; } }

html { scroll-behavior: smooth; }
html, body { margin:0; padding:0; background: var(--bg); color: var(--text); font-family: 'Be Vietnam Pro', Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; font-size:15px; line-height:1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; transition: opacity 0.15s; }
a:hover { opacity:0.8; }

/* login — centered card with soft gradient */
.login-view { min-height:100vh; display:flex; align-items:center; justify-content:center; background: radial-gradient(1200px 600px at 20% -10%, #dbeafe 0%, transparent 60%), radial-gradient(1000px 500px at 90% 110%, #a3c1ad33 0%, transparent 60%), var(--bg); padding:24px; }
.login-card { background: var(--card); border:1px solid var(--border); border-radius: 16px; padding:32px 28px; width:380px; box-shadow: var(--shadow-lg); display:flex; flex-direction:column; gap:14px; animation: cardIn 0.35s ease; }
@keyframes cardIn { from { opacity:0; transform: translateY(8px) scale(0.98); } to { opacity:1; transform:none; } }
.login-card h2 { margin:0; color: var(--primary); font-size:20px; font-weight:800; letter-spacing:-0.2px; }
.login-card input { padding:11px 14px; border:1px solid var(--border); border-radius:10px; font-size:14px; width:100%; background:#f8fafc; transition: border-color 0.2s, box-shadow 0.2s, background 0.2s; }
.login-card input:focus { outline:none; border-color: var(--primary); background:#fff; box-shadow: 0 0 0 3px rgba(11,37,69,0.12); }
.login-card button { padding:11px; background: var(--primary); color:#fff; border:none; border-radius:10px; cursor:pointer; font-weight:700; font-size:14px; transition: background 0.2s, transform 0.08s, box-shadow 0.2s; box-shadow: 0 2px 8px rgba(11,37,69,0.2); }
.login-card button:hover { background: var(--primary-hover); box-shadow: 0 4px 12px rgba(11,37,69,0.25); }
.login-card button:active { transform: scale(0.98); }
.err { color: var(--danger); min-height:1.2em; margin:0; font-size:13px; font-weight:500; }

/* topbar — dark, sticky, blur */
.topbar { display:flex; align-items:center; gap:14px; padding:12px 20px; background: linear-gradient(180deg, var(--header) 0%, var(--header-light) 100%); color:#fff; position:sticky; top:0; z-index:10; box-shadow: 0 2px 12px rgba(11,37,69,0.25); backdrop-filter: blur(8px); }
.brand { font-size:15px; font-weight:800; letter-spacing:0.3px; color:#fff; display:flex; align-items:center; gap:8px; }
.brand::before { content:"◈"; color: var(--accent); font-size:14px; }
.tabs { display:flex; gap:6px; flex-wrap:wrap; }
.tabs button { padding:7px 14px; border:1px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.9); border-radius:999px; cursor:pointer; font-size:13px; font-weight:600; transition: all 0.2s ease; backdrop-filter: blur(4px); }
.tabs button:hover { background: rgba(255,255,255,0.16); border-color: rgba(255,255,255,0.28); transform: translateY(-1px); }
.tabs button.active { background: #fff; color: var(--primary); border-color:#fff; box-shadow: 0 2px 8px rgba(0,0,0,0.15); transform:none; }
.live-link { padding:7px 12px; background: rgba(255,255,255,0.12); border:1px solid rgba(255,255,255,0.2); border-radius:8px; color:#fff; font-size:13px; font-weight:600; transition: all 0.2s; }
.live-link:hover { background:#fff; color: var(--primary); text-decoration:none; }
.btn { padding:7px 14px; border:1px solid var(--border); background: var(--card); border-radius:8px; cursor:pointer; font-size:13px; font-weight:600; transition: all 0.18s ease; }
.btn:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: none; }
.btn-primary { background: var(--primary); color:#fff; border-color: var(--primary); box-shadow: 0 2px 8px rgba(11,37,69,0.2); }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 12px rgba(11,37,69,0.25); }
.btn-ghost { background: rgba(255,255,255,0.12); color:#fff; border-color: rgba(255,255,255,0.2); }
.btn-ghost:hover { background:#fff; color: var(--primary); }
.btn-danger { background:#fff; color: var(--danger); border-color:#fecaca; }
.btn-danger:hover { background: var(--danger); color:#fff; border-color: var(--danger); }
.btn-small { padding:5px 10px; font-size:12px; border-radius:6px; }

.main { padding:20px; max-width:none; width:100%; }
.toolbar { display:flex; align-items:center; gap:12px; margin-bottom:16px; flex-wrap:wrap; }
.toolbar h2 { margin:0; font-size:17px; font-weight:800; color: var(--primary); letter-spacing:-0.2px; }
.toolbar input[type="date"], .toolbar input[type="time"], .toolbar select { padding:8px 12px; border:1px solid var(--border); border-radius:8px; background:#fff; font-size:13px; transition: border-color 0.2s, box-shadow 0.2s; }
.toolbar input:focus, .toolbar select:focus { outline:none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(11,37,69,0.08); }

/* table — card style */
table { width:100%; border-collapse:separate; border-spacing:0; background: var(--card); border:1px solid var(--border); border-radius: var(--radius); overflow:hidden; box-shadow: var(--shadow); }
th, td { padding:10px 12px; border-bottom:1px solid #f1f5f9; border-right:1px solid #f1f5f9; text-align:left; font-size:13px; transition: background 0.15s; }
th { background:#f8fafc; color: #334155; font-weight:700; font-size:12px; letter-spacing:0.2px; text-transform:uppercase; white-space:nowrap; }
th:last-child, td:last-child { border-right:none; }
tr:last-child td { border-bottom:none; }
tbody tr { transition: background 0.15s; }
tbody tr:hover td { background:#f8fafc; }
tbody tr:hover td.cell-empty { background:#f1f5f9; }
.cell-empty { background: #f8fafc; }
.badge { display:inline-flex; align-items:center; gap:4px; padding:3px 10px; border-radius:999px; font-size:12px; font-weight:600; border:1px solid var(--border); }
.badge-on { background:#ecfdf5; color:#065f46; border-color:#a7f3d0; }
.badge-off { background:#fef2f2; color:#991b1b; border-color:#fecaca; }

/* dialog — smooth scale */
dialog { border:none; border-radius:16px; padding:0; max-width:580px; width:90vw; box-shadow: var(--shadow-lg); animation: dialogIn 0.22s ease; }
@keyframes dialogIn { from { opacity:0; transform: scale(0.96) translateY(6px); } to { opacity:1; transform:none; } }
dialog::backdrop { background: rgba(15,23,42,0.45); backdrop-filter: blur(4px); animation: backdropIn 0.2s ease; }
@keyframes backdropIn { from { opacity:0; } to { opacity:1; } }
#dlgForm { padding:24px; display:flex; flex-direction:column; gap:14px; }
#dlgForm h3 { margin:0 0 2px; color: var(--primary); font-size:16px; font-weight:800; }
.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.form-field { display:flex; flex-direction:column; gap:6px; }
.form-field.full { grid-column:1 / -1; }
.form-field label { font-size:11px; color: var(--muted); font-weight:700; letter-spacing:0.3px; text-transform:uppercase; }
.form-field input, .form-field select { padding:9px 12px; border:1px solid var(--border); border-radius:8px; font-size:13px; background:#fff; transition: border-color 0.2s, box-shadow 0.2s; font-family: 'Be Vietnam Pro', Inter, system-ui, sans-serif; }
.form-field input:focus, .form-field select:focus { outline:none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(11,37,69,0.08); }
.form-field input[type="checkbox"] { width:18px; height:18px; accent-color: var(--primary); }
.form-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:4px; }

/* pagination */
.pagination { display:flex; align-items:center; gap:6px; justify-content:flex-end; padding:12px; background:#fff; border-top:1px solid #f1f5f9; font-size:13px; }
.pagination .info { color: var(--muted); margin-right:auto; font-size:12px; }
.pagination button { padding:6px 12px; border:1px solid var(--border); background:#fff; border-radius:8px; cursor:pointer; font-size:12px; font-weight:600; transition: all 0.15s; }
.pagination button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination button:disabled { opacity:0.4; cursor:not-allowed; }
.pagination button.active { background: var(--primary); color:#fff; border-color: var(--primary); }
.pagination .pages { display:flex; gap:4px; }

tr.locked td{ opacity:0.6; background:#f8fafc; }
.timeline{ display:flex; flex-direction:column; gap:12px; border-left:2px solid #e2e8f0; padding-left:16px; margin-left:8px; }
.timeline-item{ position:relative; display:flex; gap:12px; }
.timeline-dot{ width:12px; height:12px; border-radius:50%; position:absolute; left:-23px; top:4px; border:2px solid #fff; box-shadow:0 0 0 2px currentColor; }

/* toast */
#toast { position:fixed; bottom:20px; right:20px; display:flex; flex-direction:column; gap:8px; z-index:100; pointer-events:none; }
.toast { padding:12px 16px; border-radius:10px; font-size:13px; font-weight:600; box-shadow: var(--shadow-lg); animation: toastIn 0.25s ease; pointer-events:auto; }
.toast.success { background:#065f46; color:#fff; }
.toast.error { background:#991b1b; color:#fff; }
.toast.info { background: var(--primary); color:#fff; }
@keyframes toastIn { from { opacity:0; transform: translateY(10px) scale(0.98); } to { opacity:1; transform:none; } }

.card { background: var(--card); border:1px solid var(--border); border-radius: var(--radius); padding:16px; box-shadow: var(--shadow); }
.dashboard-grid { display:grid; grid-template-columns: repeat(3,1fr); gap:12px; margin-bottom:16px; }
.dashboard-grid-2 { display:grid; grid-template-columns: 1fr 1fr; gap:12px; }
.dashboard-grid .card, .dashboard-grid-2 .card{ background: var(--card); border:1px solid var(--border); border-radius: var(--radius); padding:16px; box-shadow: var(--shadow); }

/* Mobile optimizations */
@media (max-width: 768px){
  .sidebar{ width:280px; min-width:280px; }
  .topbar{ padding:10px 12px; gap:8px; }
  .topbar .brand{ font-size:14px; }
  .main{ padding:12px; }
  .toolbar{ flex-direction:column; align-items:stretch; }
  .toolbar h2{ font-size:16px; }
  .toolbar input, .toolbar select, .toolbar button{ width:100%; }
  table{ display:block; max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; white-space:nowrap; }
  th, td{ padding:8px 8px; font-size:12px; }
  .btn, .btn-small{ padding:8px 12px; min-height:44px; }
  dialog{ width:95vw; max-width:none; margin:10px auto; }
  #toast{ left:12px; right:12px; bottom:12px; }
  .pagination{ flex-wrap:wrap; justify-content:center; }
  .pagination .info{ width:100%; text-align:center; margin-bottom:6px; }
  .login-card{ width:90vw; max-width:360px; padding:24px 20px; }
  .dashboard-grid, .dashboard-grid-2{ grid-template-columns:1fr; }
  .form-grid{ grid-template-columns:1fr; }
}
@media (max-width: 480px){
  .topbar{ gap:8px; padding:10px 12px; }
  .sidebar{ width:100vw; min-width:100vw; left:-100vw; }
  .sidebar.open{ left:0; }
  th, td{ font-size:11px; padding:6px 6px; }
  .card{ padding:12px; }
  .brand::before{ display:none; }
}
/* Overlay for mobile drawer */
.sidebar-overlay{ display:none; position:fixed; inset:0; background:rgba(15,23,42,0.4); backdrop-filter:blur(2px); z-index:15; }
.sidebar.open ~ .sidebar-overlay{ display:block; }
@media (min-width: 901px){ .sidebar-overlay{ display:none !important; } }
.bottom-nav{ display:none; position:fixed; bottom:0; left:0; right:0; height:56px; background:#fff; border-top:1px solid #e2e8f0; justify-content:space-around; align-items:center; z-index:10; }
.bottom-item{ flex:1; display:flex; flex-direction:column; align-items:center; gap:2px; background:none; border:none; font-size:10px; font-weight:600; color:#64748b; cursor:pointer; padding:4px; }
.bottom-item.active{ color:#0b2545; }
.bottom-item.active span:first-child{ background:#0b2545; color:#fff; border-radius:50%; width:24px; height:24px; display:flex; align-items:center; justify-content:center; }
.fab{ position:fixed; right:16px; bottom:72px; width:56px; height:56px; border-radius:50%; background:#0b2545; color:#fff; border:none; font-size:24px; box-shadow:0 4px 12px rgba(0,0,0,0.2); cursor:pointer; display:flex; align-items:center; justify-content:center; z-index:9; }
@media (max-width:900px){ .bottom-nav{ display:flex; } .main{ padding-bottom:72px; } }
@media (min-width:901px){ .bottom-nav, .fab{ display:none !important; } }
.card-list{ display:none; flex-direction:column; gap:8px; }
.lich-card{ background:#fff; border:1px solid #e2e8f0; border-radius:12px; padding:12px; box-shadow:0 1px 3px rgba(0,0,0,0.06); display:flex; flex-direction:column; gap:6px; }
.lich-card .row1{ display:flex; justify-content:space-between; align-items:center; font-size:13px; font-weight:700; }
.lich-card .row2{ font-size:13px; color:#334155; }
.lich-card .row3{ display:flex; gap:6px; }
.lich-card .row3 .btn{ flex:1; min-height:40px; }
@media (max-width:900px){ table{ display:none; } .card-list{ display:flex; } }
@media (min-width:901px){ .card-list{ display:none !important; } }
@media (max-width:900px){
  dialog{ width:100vw; max-width:none; height:90vh; max-height:90vh; margin:0; border-radius:16px 16px 0 0; position:fixed; bottom:0; top:auto; animation: slideUp 0.25s ease; }
  @keyframes slideUp{ from{ transform:translateY(100%); } to{ transform:none; } }
  #dlgForm{ max-height:85vh; overflow:auto; }
}

/* Heartbeat pulse for Đang mổ — gentle 1 beat, subtle */
.heartbeat{ animation: heartbeat 1.6s ease-in-out infinite; }
@keyframes heartbeat{
  0%, 100%{ transform:scale(1); }
  25%{ transform:scale(1.05); box-shadow:0 0 6px rgba(5,150,105,0.4); }
  50%{ transform:scale(1); box-shadow:0 0 0 rgba(5,150,105,0); }
}
