/* 
 * Clinic Queuing System - Unified Design System
 * Replicated 1:1 from clinic_old/dashboard.php using legacy aesthetics.
 * Optimized to run alongside Bootstrap 5 structural utilities.
 */

:root {
  --blue: #35408E;
  --yellow: #FFD41C;
  --bg: #0f1226;
  --panel: #141a3a;
  --card: #0f1533;
  --text: #eef1ff;
  --muted: #b7bde8;
  --line: rgba(255, 255, 255, .12);
  --shadow: 0 12px 28px rgba(0, 0, 0, .35);
  --radius: 18px;
  --radius-sm: 12px;
  --focus: 0 0 0 3px rgba(255, 212, 28, .35);
  --font: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

html, body {
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(1000px 600px at 10% 0%, rgba(53, 64, 142, .45), transparent 55%),
              radial-gradient(900px 520px at 100% 20%, rgba(255, 212, 28, .25), transparent 60%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* --- SIDEBAR & BRANDING --- */
.sidebar {
  width: 280px;
  min-width: 280px;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20, 26, 58, .92), rgba(15, 18, 38, .92));
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
}

/* --- PAGE SECTION VISIBILITY --- */
.page-section {
  display: none;
}

.page-section.active {
  display: block;
  animation: fadeInSection 0.25s ease;
}

@keyframes fadeInSection {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.brand {
  border-radius: var(--radius);
  padding: 14px;
  background: linear-gradient(to bottom right, var(--blue) 0 50%, var(--yellow) 50% 100%);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.brand .title {
  font-weight: 800;
  font-size: 18px;
  margin: 0;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

.brand .subtitle {
  margin: 6px 0 0;
  font-size: 12px;
  color: rgba(255, 255, 255, .9);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

.nav {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav button, .nav .nav-item-custom {
  all: unset;
  cursor: pointer;
  border-radius: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
}

.nav button:hover, .nav .nav-item-custom:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, .06);
}

.nav button.active, .nav .nav-item-custom.active {
  border-color: rgba(255, 212, 28, .6);
  background: rgba(255, 212, 28, .12);
}

.nav-logout {
  display: flex;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}

.nav-logout:hover {
  background: rgba(220, 53, 69, .15);
  border-color: rgba(220, 53, 69, .4);
  transform: translateY(-1px);
}

.nav .label {
  display: flex;
  gap: 10px;
  align-items: center;
}

.pill {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(53, 64, 142, .35);
  border: 1px solid rgba(53, 64, 142, .55);
  color: var(--text);
}

.sidebar .footer {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* --- TOPBAR & HEADER --- */
.topbar-legacy {
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--line);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .22);
}

.badge-diagonal {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(to bottom right, var(--blue) 0 50%, var(--yellow) 50% 100%);
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 10px 22px rgba(0, 0, 0, .25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-legacy h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 850;
  letter-spacing: .2px;
  color: #fff;
}

.topbar-legacy p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* --- CARDS & PANELS --- */
.card-clinic {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .03);
  padding: 18px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .22);
  margin-bottom: 20px;
}

.card-clinic h2 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: .2px;
  color: #fff;
}

/* --- BUTTONS & INPUTS --- */
.btn-clinic {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 750;
  font-size: 13px;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}

.btn-clinic:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, .06);
}

.btn-clinic.yellow {
  background: rgba(255, 212, 28, .92);
  color: #0b0e22;
  border-color: rgba(255, 212, 28, .65);
}

.btn-clinic.yellow:hover {
  background: rgba(255, 212, 28, 1);
}

/* --- AUTOFILL UI FIX --- */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #1a1d21 inset !important;
    -webkit-text-fill-color: white !important;
    transition: background-color 5000s ease-in-out 0s;
}

.input-clinic {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(15, 21, 51, .55);
  color: var(--text);
  outline: none;
  font-size: 14px;
  font-weight: 700;
}

.input-clinic:focus {
  box-shadow: var(--focus);
  border-color: rgba(255, 212, 28, .55);
}

.label-clinic {
  font-size: 12px;
  color: var(--muted);
  font-weight: 850;
  margin-bottom: 6px;
  display: block;
}

/* --- TABLES & LISTS --- */
.table-clinic {
  width: 100%;
  border-collapse: collapse;
}

.table-clinic th {
  text-align: left;
  padding: 12px 8px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--line);
}

.table-clinic td {
  padding: 14px 8px;
  font-size: 14px;
  font-weight: 750;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .04);
}

.listItem-clinic {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line);
  margin-bottom: 10px;
}

.chip {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .14);
  color: var(--muted);
  background: rgba(15, 21, 51, .45);
}

.chip.yellow {
  border-color: rgba(255, 212, 28, .35);
  color: #fff3b0;
  background: rgba(255, 212, 28, .10);
}

/* --- MAIN LAYOUT GRID --- */
.app-container {
  display: flex;
  min-height: 100vh;
}

.main-clinic {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

.topbar-clinic {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 16px 20px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.topbar-clinic .left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-clinic h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 850;
  color: #fff;
}

.topbar-clinic p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.topbar-clinic .counterSelect {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  margin-left: 20px;
  padding-left: 20px;
  border-left: 1px solid var(--line);
}

.topbar-clinic .counterSelect label {
  font-size: 10px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#active-counter-display {
  font-size: 15px;
  font-weight: 900;
  color: var(--yellow);
  text-shadow: 0 0 10px rgba(255, 212, 28, 0.2);
}

.topbar-clinic .right {
  display: flex;
  gap: 10px;
}

.grid-clinic {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 20px;
}

@media (max-width: 1100px) {
  .grid-clinic { grid-template-columns: 1fr; }
}

/* --- TICKET & DASHBOARD UI --- */
.ticket-display {
  display: flex;
  background: linear-gradient(135deg, rgba(53, 64, 142, .2), rgba(15, 21, 51, .4));
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  padding: 24px;
  margin-bottom: 18px;
  align-items: center;
  justify-content: space-between;
}

.ticket-display .num {
  font-size: 52px;
  font-weight: 950;
  color: var(--yellow);
  line-height: .9;
  text-shadow: 0 0 30px rgba(255, 212, 28, .2);
}

.ticket-display .meta {
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}

.list-scrollable {
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.list-scrollable::-webkit-scrollbar { width: 6px; }
.list-scrollable::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; }

/* --- CUSTOM MODALS & OVERLAYS --- */
.modalBack {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s ease;
}

.modalBack.hidden {
  display: none;
}

.counterModal {
  background: #141a3a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: modalSlide 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.counterModal h3 {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
}

.counterModal p {
  margin: 0 0 24px;
  color: #b7bde8;
  font-size: 14px;
  line-height: 1.5;
}

.counterModal .field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.counterModal label {
  font-size: 13px;
  color: #eef1ff;
  font-weight: 600;
  opacity: 0.8;
}

.counterModal select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px !important;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(15, 21, 51, 0.7) !important;
  color: #fff !important;
  font-size: 15px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23FFD515' 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 16px center;
}

.counterModal .btns {
  margin-top: 28px;
}

.counterModal .btn-ok {
  width: 100%;
  background: #FFD515;
  color: #12163A;
  border-radius: 14px;
  padding: 14px;
  font-weight: 800;
  border: none;
  font-size: 16px;
  cursor: pointer;
  transition: 0.2s;
}

.counterModal .btn-ok:hover {
  background: #e6bf12;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(255, 213, 21, 0.4);
}

.table-selectable-row {
  cursor: pointer;
  transition: background 0.15s ease;
}

.table-selectable-row:hover {
  background: rgba(255, 255, 255, 0.03) !important;
}

.table-selectable-row.selected {
  background: rgba(255, 212, 28, 0.15) !important;
  border-left: 3px solid var(--yellow);
}

.form-control-dark {
  background: #1a1d21 !important;
  border: 1px solid #333 !important;
  color: #fff !important;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  transition: all 0.2s ease;
}

.form-control-dark:focus {
  background: #1a1d21 !important;
  border-color: var(--yellow) !important;
  box-shadow: 0 0 0 3px rgba(255, 212, 28, 0.2);
  outline: none;
}

.btn-filter-outline {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid #333;
  color: #fff;
  border-radius: 12px;
  padding: 10px 20px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-filter-outline:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: #444;
}