:root {
  --edoc-bg: #f4f6f9;
  --edoc-surface: #ffffff;
  --edoc-surface-2: #f1f3f6;
  --edoc-border: #e2e5eb;
  --edoc-text: #1f2430;
  --edoc-text-muted: #6b7280;
  --edoc-primary: #2f6fed;
  --edoc-primary-hover: #2558c4;
  --edoc-sidebar-bg: #172038;
  --edoc-sidebar-text: #c3cbe0;
  --edoc-sidebar-active: #2f6fed;
  --edoc-card-shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}

[data-bs-theme="dark"] {
  --edoc-bg: #10131c;
  --edoc-surface: #1a1f2e;
  --edoc-surface-2: #222838;
  --edoc-border: #2b3245;
  --edoc-text: #e6e9f2;
  --edoc-text-muted: #9aa3b8;
  --edoc-primary: #4f8cff;
  --edoc-primary-hover: #6fa1ff;
  --edoc-sidebar-bg: #0d101a;
  --edoc-sidebar-text: #aab2c8;
  --edoc-sidebar-active: #4f8cff;
  --edoc-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
  background-color: var(--edoc-bg);
  color: var(--edoc-text);
  min-height: 100vh;
}

.edoc-shell { display: flex; min-height: 100vh; }

.edoc-sidebar {
  width: 250px;
  flex-shrink: 0;
  background-color: var(--edoc-sidebar-bg);
  color: var(--edoc-sidebar-text);
  overflow: hidden;
  transition: margin-left .2s ease, width .2s ease;
}
.edoc-sidebar .brand {
  padding: 1.1rem 1.25rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: 1.05rem;
  white-space: nowrap;
}
.edoc-sidebar .nav-link {
  color: var(--edoc-sidebar-text);
  padding: .65rem 1.25rem;
  border-left: 3px solid transparent;
  font-size: .93rem;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .edoc-shell.sidebar-collapsed .edoc-sidebar { width: 64px; }
  .edoc-shell.sidebar-collapsed .edoc-sidebar .nav-label,
  .edoc-shell.sidebar-collapsed .edoc-sidebar .nav-section-title { display: none; }
  .edoc-shell.sidebar-collapsed .edoc-sidebar .brand { padding: 1.1rem 0; text-align: center; }
  .edoc-shell.sidebar-collapsed .edoc-sidebar .nav-link { padding: .65rem 0; text-align: center; }
}
.edoc-sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.edoc-sidebar .nav-link.active {
  color: #fff;
  background: rgba(255,255,255,.08);
  border-left-color: var(--edoc-sidebar-active);
}
.edoc-sidebar .nav-section-title {
  color: rgba(255,255,255,.35);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 1rem 1.25rem .35rem;
}

.edoc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.edoc-topbar {
  background-color: var(--edoc-surface);
  border-bottom: 1px solid var(--edoc-border);
  padding: .6rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}

.edoc-content { padding: 1.25rem; flex: 1; }

.card, .edoc-card {
  background-color: var(--edoc-surface);
  border: 1px solid var(--edoc-border);
  box-shadow: var(--edoc-card-shadow);
}

.stat-card { border-radius: .6rem; }
.stat-card .stat-value { font-size: 1.9rem; font-weight: 700; }
.stat-card .stat-label { color: var(--edoc-text-muted); font-size: .85rem; }
.stat-card .stat-icon {
  width: 48px; height: 48px; border-radius: .6rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}

.table { color: var(--edoc-text); }
.table > :not(caption) > * > * { background-color: transparent; }

.timeline-scroll { max-height: 620px; overflow-y: auto; padding-right: .5rem; }
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before {
  content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px;
  width: 2px; background: var(--edoc-border);
}
.timeline-item { position: relative; padding-bottom: 1.25rem; }
.timeline-item::before {
  content: ""; position: absolute; left: -1.5rem; top: 3px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--edoc-primary); border: 2px solid var(--edoc-surface);
}

.bg-orange { background-color: #fd7e14 !important; color: #fff; }

.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--edoc-sidebar-bg), var(--edoc-primary));
}
.login-card {
  width: 100%; max-width: 400px;
  background-color: var(--edoc-surface);
  border-radius: .75rem;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}

@media (max-width: 768px) {
  .edoc-sidebar { position: fixed; z-index: 1040; height: 100vh; margin-left: -250px; }
  .edoc-sidebar.show { margin-left: 0; }
  .edoc-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1030; }
  .edoc-backdrop.show { display: block; }
}

/* ตารางข้อมูล -> แสดงเป็นการ์ดในโหมดมือถือ (ใช้ class "table-cards" + data-label บนแต่ละ td) */
@media (max-width: 767.98px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td {
    display: block;
    width: 100%;
  }
  .table-cards tbody tr {
    margin-bottom: .75rem;
    border: 1px solid var(--edoc-border);
    border-radius: .6rem;
    padding: 0 .9rem;
    background-color: var(--edoc-surface);
    box-shadow: var(--edoc-card-shadow);
  }
  .table-cards tbody tr:last-child { margin-bottom: 0; }
  .table-cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    padding: .6rem 0;
    border-top: 1px solid var(--edoc-border);
    text-align: right;
  }
  .table-cards td:first-child { border-top: none; }
  .table-cards td[data-label]::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: .78rem;
    color: var(--edoc-text-muted);
    text-align: left;
    margin-right: 1rem;
    flex-shrink: 0;
  }
  .table-cards td.cell-actions { justify-content: flex-end; flex-wrap: wrap; }
  .table-cards td.cell-empty { justify-content: center; text-align: center; padding: 1.5rem 0; }
  .table-cards td.text-truncate {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    max-width: none !important;
  }
}
