/* ============================================================
   INPATIENTS TURNOVER — STYLES
   ============================================================ */

body { margin:0; padding:0; font-family:'Segoe UI',Tahoma,Geneva,Verdana,sans-serif; background:#f5f5f5; }
.page-wrapper { padding:20px; min-height:100vh; }
.header { text-align:center; margin-bottom:16px; }
.header h1 { font-size:24px; color:#2c3e50; margin:0; }
.header h2 { font-size:18px; color:#34495e; margin:6px 0 0 0; }
.controls { text-align:center; margin:16px 0; display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }

/* Buttons */
.btn { padding:10px 20px; border:none; border-radius:5px; cursor:pointer; font-weight:bold; color:white; }
.btn-export  { background:#2196F3; }
.btn-nav     { background:#4CAF50; }
.btn-calendar{ background:#FF9800; }
.btn-block   { background:#F44336; }
.btn-logout  { background:#7f8c8d; }
.btn:hover   { opacity:0.9; }
.btn-cancel  { background:#7f8c8d; }

/* Table */
.table-container { background:white; padding:20px; border-radius:8px; box-shadow:0 2px 4px rgba(0,0,0,0.1); overflow-x:auto; position:relative; }
table { width:100%; border-collapse:collapse; border:3px solid #2c5f2d; }
th { background:#2c5f2d; color:white; padding:12px 8px; text-align:center; cursor:default; user-select:none; }
td { padding:8px; border:1px solid #d0d0d0; text-align:center; }
td:first-child { background:#dae8fc; text-align:left; padding-left:12px; font-weight:500; }
td:nth-child(2),td:nth-child(3),td:nth-child(4),td:nth-child(5) { background:#fff4e6; }
td:nth-child(6) { background:#ffe6f0; }
td:nth-child(7) { background:#ffeb99; font-weight:bold; }
.total-row td { background:#e8f5e9 !important; font-weight:bold; }
.total-row td:first-child { background:#c8e6c9 !important; }
.editable { cursor:pointer; }
.editable:hover { outline:2px solid #4CAF50; outline-offset:-2px; }
.editable input { width:100%; border:2px solid #4CAF50; padding:4px; text-align:center; box-sizing:border-box; }

/* Calendar */
.calendar-container { display:flex; flex-wrap:wrap; gap:20px; justify-content:center; }
.month { background:white; padding:15px; border-radius:8px; box-shadow:0 2px 4px rgba(0,0,0,0.1); width:300px; }
.month h3 { text-align:center; margin:0 0 10px 0; }
.month table { width:100%; border-collapse:collapse; border:2px solid #3498db; }
.month th { background:#3498db; color:white; padding:6px; cursor:default; }
.month td { padding:8px; border:1px solid #ddd; cursor:pointer; text-align:center; }
.month td.empty { background:#f5f5f5; cursor:default; }
.today { background:red !important; color:white; font-weight:bold; }

/* Status / indicators */
.statusline { text-align:center; color:#666; font-size:12px; margin:6px 0 0 0; }
.pill { display:inline-flex; align-items:center; gap:8px; padding:6px 10px; border-radius:999px; background:#fff; box-shadow:0 1px 2px rgba(0,0,0,0.08); }
.dot  { width:10px; height:10px; border-radius:50%; background:#FF9800; }
.ok   { background:#4CAF50 !important; }
.bad  { background:#F44336 !important; }
.overlay { position:absolute; inset:0; background:rgba(255,255,255,0.7); display:none; align-items:center; justify-content:center; font-weight:700; color:#2c3e50; }
.overlay.show { display:flex; }
.save-indicator { margin-top:8px; font-size:12px; color:#666; text-align:center; }
.save-indicator strong { color:#2c3e50; }

/* Extra fields */
.extra-fields { margin-top:20px; padding:20px; background:#f9f9f9; border-radius:8px; }
.extra-fields textarea { width:100%; height:80px; padding:10px; border:1px solid #ddd; border-radius:4px; resize:vertical; box-sizing:border-box; }

/* ============================================================
   ADMIN PANEL
   ============================================================ */
.admin-panel { max-width:1100px; margin:0 auto 16px auto; background:white; border-radius:10px; box-shadow:0 2px 4px rgba(0,0,0,0.1); padding:16px; display:none; }
.admin-panel-header { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; margin-bottom:12px; }
.admin-panel-title { font-weight:800; color:#2c3e50; font-size:16px; }
.admin-panel-controls { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.select { padding:10px 12px; border:1px solid #ddd; border-radius:8px; background:white; font-weight:600; color:#2c3e50; cursor:pointer; }
.stats-grid { display:grid; grid-template-columns:repeat(3,minmax(180px,1fr)); gap:12px; }
.stat-card { border:1px solid #eee; border-radius:10px; padding:14px; background:#fafafa; }
.stat-label { color:#666; font-size:12px; margin-bottom:6px; }
.stat-value { font-size:28px; font-weight:800; color:#2c3e50; }
.stat-sub   { margin-top:6px; color:#888; font-size:12px; }
.small-note { color:#777; font-size:12px; margin-top:10px; }

/* Admin tabs */
.admin-tabs { display:flex; gap:4px; margin-bottom:14px; border-bottom:2px solid #eee; padding-bottom:4px; }
.admin-tab-btn { padding:8px 18px; border:none; border-radius:6px 6px 0 0; background:#f0f0f0; color:#555; font-weight:600; cursor:pointer; font-size:14px; }
.admin-tab-btn.active { background:#2c5f2d; color:white; }
.admin-tab-pane { display:none; }
.admin-tab-pane.active { display:block; }

/* User management table */
.user-mgmt-toolbar { display:flex; gap:8px; align-items:center; margin-bottom:12px; flex-wrap:wrap; }
.user-table { width:100%; border-collapse:collapse; font-size:13px; }
.user-table th { background:#2c5f2d; color:white; padding:8px 10px; text-align:left; }
.user-table td { padding:7px 10px; border:1px solid #e0e0e0; vertical-align:middle; }
.user-table tr:hover td { background:#f5f5f5; }
.badge { display:inline-block; padding:2px 8px; border-radius:10px; font-size:11px; font-weight:700; }
.badge-active   { background:#e8f5e9; color:#2e7d32; }
.badge-inactive { background:#ffebee; color:#c62828; }
.badge-temp     { background:#fff3e0; color:#e65100; }
.badge-perm     { background:#e3f2fd; color:#1565c0; }
.btn-sm         { padding:4px 10px; font-size:12px; border:none; border-radius:4px; cursor:pointer; color:white; font-weight:600; }
.btn-sm-edit    { background:#1976d2; }
.btn-sm-pass    { background:#f57c00; }
.btn-sm-toggle  { background:#7b1fa2; }
.btn-sm-del     { background:#c62828; }
.dept-user-info { background:#e8f4fd; border:1px solid #b3d7f0; border-radius:6px; padding:8px 14px; margin-bottom:12px; font-size:13px; color:#1565c0; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-backdrop { position:fixed; inset:0; background:rgba(0,0,0,0.45); display:none; align-items:center; justify-content:center; z-index:2000; padding:16px; }
.modal-backdrop.show { display:flex; }
.modal-card { width:100%; max-width:520px; background:#fff; border-radius:10px; box-shadow:0 20px 50px rgba(0,0,0,0.25); padding:18px; }
.modal-card h3 { margin:0 0 14px 0; color:#2c3e50; }
.modal-card p  { color:#555; font-size:14px; margin:0 0 14px 0; }
.modal-grid { display:grid; gap:10px; }
.modal-grid label  { font-size:14px; color:#2c3e50; font-weight:600; }
.modal-grid select,
.modal-grid input  { width:100%; border:1px solid #d0d0d0; border-radius:6px; padding:9px 10px; font-size:14px; box-sizing:border-box; }
.modal-actions { margin-top:14px; display:flex; gap:8px; justify-content:flex-end; flex-wrap:wrap; }
.temp-pw-display { background:#fff3e0; border:1px solid #ffcc80; border-radius:6px; padding:12px; margin-top:10px; text-align:center; }
.temp-pw-display .pw-value { font-size:22px; font-weight:800; color:#e65100; letter-spacing:2px; margin:6px 0; }
.temp-pw-display p { color:#795548; font-size:13px; margin:0; }

/* ============================================================
   AUTH VIEW (login page)
   ============================================================ */
body.auth-mode { background:#edf2fb; color:#1a365d; overflow-x:hidden; }
body.auth-mode .page-wrapper { padding-left:0; padding-right:0; }
body.auth-mode::before,
body.auth-mode::after { content:''; position:fixed; pointer-events:none; border-radius:50%; filter:blur(56px); z-index:0; }
body.auth-mode::before { width:640px; height:640px; right:-200px; top:-220px; background:rgba(147,197,253,0.45); animation:decorPulse 7s ease-in-out infinite; }
body.auth-mode::after  { width:560px; height:560px; left:-180px; bottom:-200px; background:rgba(129,140,248,0.35); }
@keyframes decorPulse { 0%,100%{transform:scale(1);opacity:0.7} 50%{transform:scale(1.08);opacity:0.45} }

#authView {
  width:100%; max-width:448px; margin:0 auto;
  height:calc(100vh - 40px); min-height:calc(100vh - 40px);
  padding:10px 0 28px 0; box-sizing:border-box;
  position:relative; z-index:1;
  display:flex; flex-direction:column; justify-content:flex-start; gap:16px;
  text-align:center; background:transparent; box-shadow:none; border-radius:0;
}
#logo { max-width:300px; width:min(300px,100%); height:auto; margin:0 auto 10px auto; display:block; object-fit:contain; }
.auth-brand { text-align:center; margin-bottom:2px; }
.auth-card {
  position:relative; text-align:left;
  background:rgba(255,255,255,0.94); border-radius:2.5rem;
  padding:40px; border:1px solid rgba(255,255,255,0.95);
  box-shadow:0 30px 52px rgba(30,64,175,0.14); overflow:hidden;
}
.auth-card-corner { position:absolute; top:0; right:0; width:126px; height:126px; border-bottom-left-radius:92px; background:rgba(219,234,254,0.65); pointer-events:none; }
.auth-card-title { margin:0 0 22px 0; font-size:clamp(26px,4vw,34px); color:#1e3a8a; font-weight:800; letter-spacing:-0.01em; display:flex; align-items:center; gap:10px; }
.auth-card-title-icon { width:30px; height:30px; stroke:#3b82f6; flex:0 0 30px; }
.auth-label { display:block; margin:0 0 10px 6px; color:rgba(30,64,175,0.72); font-weight:700; letter-spacing:0.01em; font-size:14px; }

#authView #username,
#authView #password {
  width:100%; margin:0; height:56px; padding:0 18px;
  border-radius:16px; border:2px solid transparent;
  background:rgba(239,246,255,0.86); color:#1e3a8a;
  font-size:18px; font-weight:700; box-sizing:border-box; outline:none;
  transition:border-color .2s, background-color .2s;
}
#authView #username { letter-spacing:0.01em; margin-bottom:14px; }
#authView #username:focus,
#authView #password:focus { border-color:#60a5fa; background:#fff; }

.auth-login-btn {
  width:100%; margin-top:18px; height:56px; border-radius:16px; padding:0 20px;
  background:linear-gradient(135deg,#2563eb,#1d4ed8);
  box-shadow:0 14px 22px rgba(37,99,235,0.35); font-size:18px;
  transition:transform .2s, box-shadow .2s, filter .2s;
  display:inline-flex; align-items:center; justify-content:center; gap:10px;
}
.auth-login-btn:hover { transform:translateY(-2px); box-shadow:0 18px 24px rgba(37,99,235,0.4); filter:brightness(1.03); }
.auth-login-arrow { display:inline-block; font-size:22px; transition:transform .25s; }
.auth-login-btn:hover .auth-login-arrow { transform:translateX(4px); }
.auth-statusline { margin-top:16px; text-align:center; font-size:13px; }
.auth-statusline .pill { border:1px solid rgba(191,219,254,0.9); background:rgba(255,255,255,0.95); box-shadow:0 6px 14px rgba(30,64,175,0.08); }

/* Phonebook card */
.phonebook-link { text-decoration:none; color:inherit; display:block; margin-top:auto; padding-top:54px; width:100%; transition:transform .3s; }
.phonebook-link:hover { transform:translateY(-5px); }
.phonebook-card { position:relative; border-radius:32px; overflow:hidden; background:linear-gradient(135deg,#2563eb,#4338ca); border:1px solid rgba(255,255,255,0.2); box-shadow:0 24px 42px rgba(37,99,235,0.3); width:100%; max-width:410px; margin:0 auto; padding:20px; box-sizing:border-box; display:flex; align-items:center; gap:12px; text-align:left; isolation:isolate; }
.phonebook-ring { position:absolute; left:-44px; bottom:-40px; width:170px; height:170px; border:16px solid rgba(255,255,255,0.42); border-radius:50%; pointer-events:none; z-index:0; animation:ringPulse 4s ease-in-out infinite; }
@keyframes ringPulse { 0%,100%{transform:scale(1);opacity:0.1} 50%{transform:scale(1.5);opacity:0.32} }
.phonebook-icon-wrap { position:relative; z-index:1; width:58px; height:58px; flex:0 0 58px; border-radius:16px; background:rgba(255,255,255,0.22); border:1px solid rgba(255,255,255,0.32); display:flex; align-items:center; justify-content:center; backdrop-filter:blur(4px); transition:transform .3s; }
.phonebook-link:hover .phonebook-icon-wrap { transform:scale(1.1); }
.phonebook-icon-wrap svg { width:30px; height:30px; stroke:#fff; }
.phonebook-copy { position:relative; z-index:1; flex:1; min-width:0; }
.phonebook-copy h3 { margin:0; color:#fff; font-size:24px; line-height:1.1; font-weight:800; }
.phonebook-copy p  { margin:8px 0 0 0; color:rgba(219,234,254,0.9); font-size:13px; font-weight:500; }
.phonebook-arrow-wrap { position:relative; z-index:1; width:40px; height:40px; flex:0 0 40px; border-radius:50%; background:rgba(255,255,255,0.18); border:1px solid rgba(255,255,255,0.28); display:flex; align-items:center; justify-content:center; }
.phonebook-arrow-wrap svg { width:20px; height:20px; stroke:#fff; animation:arrowSlide 1.5s ease-in-out infinite; }
@keyframes arrowSlide { 0%,100%{transform:translateX(0)} 50%{transform:translateX(5px)} }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width:700px) {
  #authView { min-height:auto; padding:14px 0; }
  .auth-card { border-radius:30px; padding:26px 18px 22px; }
  .auth-card-title { font-size:clamp(22px,7vw,30px); margin-bottom:18px; }
  .auth-login-btn { font-size:17px; }
  .phonebook-card { border-radius:24px; padding:16px; }
  .phonebook-copy h3 { font-size:clamp(18px,5vw,22px); }
  .phonebook-copy p  { font-size:12px; }
  .stats-grid { grid-template-columns:1fr; }
}
@media (max-width:540px) {
  #authView { max-width:100%; width:100%; height:auto; min-height:100dvh; padding:calc(env(safe-area-inset-top) + 10px) 12px calc(env(safe-area-inset-bottom) + 14px); justify-content:flex-start; gap:14px; }
  #logo { width:min(240px,82vw); margin-bottom:6px; }
  .auth-card { border-radius:28px; padding:24px 16px 18px; }
  .auth-card-corner { width:92px; height:92px; border-bottom-left-radius:70px; }
  .auth-card-title { font-size:clamp(32px,8vw,42px); margin-bottom:16px; }
  #authView #username,
  #authView #password { height:52px; font-size:17px; border-radius:14px; }
  #authView #username { margin-bottom:12px; }
  .auth-login-btn { height:52px; border-radius:14px; margin-top:14px; font-size:17px; }
  .phonebook-link { margin-top:auto; padding-top:16px; }
  .phonebook-card { width:100%; max-width:none; border-radius:24px; padding:14px; gap:8px; }
}
@media (max-width:390px) {
  #authView { padding-left:8px; padding-right:8px; gap:12px; }
  #logo { width:min(210px,78vw); }
  .auth-card { border-radius:24px; padding:20px 14px 16px; }
  .auth-card-title { font-size:clamp(28px,7.6vw,34px); }
  #authView #username,
  #authView #password,
  .auth-login-btn { height:50px; }
  .phonebook-link { padding-top:12px; }
  .phonebook-card { border-radius:20px; padding:12px; gap:8px; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .controls, #authView, #calendarView, .statusline, .admin-panel, .save-indicator { display:none !important; }
  #tableView { display:block !important; }
  .page-wrapper { padding:0; background:white; }
  body { background:white; }
  .table-container { box-shadow:none; padding:0; overflow:visible; }
  .overlay { display:none !important; }
  table { border:2px solid #222; }
  th { background:#2c5f2d !important; color:#fff !important; -webkit-print-color-adjust:exact; print-color-adjust:exact; }
  td:first-child { background:#dae8fc !important; -webkit-print-color-adjust:exact; print-color-adjust:exact; }
  td:nth-child(2),td:nth-child(3),td:nth-child(4),td:nth-child(5) { background:#fff4e6 !important; -webkit-print-color-adjust:exact; print-color-adjust:exact; }
  td:nth-child(6) { background:#ffe6f0 !important; -webkit-print-color-adjust:exact; print-color-adjust:exact; }
  td:nth-child(7) { background:#ffeb99 !important; -webkit-print-color-adjust:exact; print-color-adjust:exact; }
  .total-row td { background:#e8f5e9 !important; -webkit-print-color-adjust:exact; print-color-adjust:exact; }
  .total-row td:first-child { background:#c8e6c9 !important; -webkit-print-color-adjust:exact; print-color-adjust:exact; }
  .extra-fields { margin-top:16px; border:1px solid #ddd; background:#fff !important; box-shadow:none; padding:12px; page-break-inside:avoid; }
  .extra-fields textarea { height:auto; min-height:60px; border:1px solid #ccc; }
}
