/*
 * heaven-sync admin UI — Mr.Venrey dark-mode palette.
 * Built on top of Bootstrap 5.3 utilities; this stylesheet owns the
 * shell (sidebar, topbar, cards, KPI tiles).
 */

:root {
  --sidebar-bg: #1c1c1c;
  --sidebar-divider: #333333;
  --sidebar-text: #cccccc;
  --sidebar-text-muted: #555555;
  --sidebar-active-bg: #2a2a2a;
  --sidebar-active-text: #ffffff;
  --sidebar-width: 230px;
  --sidebar-width-sm: 72px;

  --topbar-height: 56px;
  --topbar-bg: #1c1c1c;
  --topbar-border: #333333;

  --content-bg: #181818;
  --card-bg: #1c1c1c;
  --card-border: #333333;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);

  --text-main: #cccccc;
  --text-sub: #999999;
  --text-muted: #8a8a8a;

  --accent-blue: #597dc3;
  --accent-blue-soft: rgba(89, 125, 195, 0.15);
  --accent-green: #4caf50;
  --accent-green-soft: rgba(76, 175, 80, 0.12);
  --accent-red: #ef5350;
  --accent-red-soft: rgba(239, 83, 80, 0.12);
  --accent-amber: #ffa726;
  --accent-amber-soft: rgba(255, 167, 38, 0.12);
  --accent-slate: #8a8a8a;
  --accent-slate-soft: rgba(138, 138, 138, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI",
               "Helvetica Neue", "Hiragino Kaku Gothic ProN", Meiryo,
               Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-main);
  background: var(--content-bg);
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.142rem; }
small { font-size: 12px; }

a { color: #597dc3; text-decoration: none; }
a:hover { color: #7b9dd3; }

/* ----- Login (standalone) ----- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #141414;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #1c1c1c;
  border: 1px solid #333333;
  border-radius: 8px;
  padding: 36px 32px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.login-card .login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.login-card .login-logo .login-logo-icon {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: #597dc3;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 12px;
}

.login-card .login-logo h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #cccccc;
}

.login-card .login-logo .login-subtitle {
  margin: 4px 0 0 0;
  font-size: 12px;
  color: #999999;
}

.form-label-sm {
  font-size: 13px;
  color: var(--text-sub);
  font-weight: 500;
  margin-bottom: 6px;
}

.form-control {
  border-radius: 4px;
  background-color: #242424;
  border-color: #333333;
  color: #cccccc;
}

.form-control:focus {
  background-color: #2a2a2a;
  border-color: #597dc3;
  color: #cccccc;
  box-shadow: 0 0 0 0.2rem rgba(89, 125, 195, 0.2);
}

.form-control::placeholder {
  color: #666666;
}

.form-select {
  background-color: #242424;
  border-color: #333333;
  color: #cccccc;
}

.form-select:focus {
  background-color: #2a2a2a;
  border-color: #597dc3;
  color: #cccccc;
  box-shadow: 0 0 0 0.2rem rgba(89, 125, 195, 0.2);
}

.input-group-text {
  background-color: #242424;
  border-color: #333333;
  color: #999999;
}

.btn-login {
  display: block;
  width: 100%;
  padding: 11px 16px;
  border: none;
  border-radius: 4px;
  background: #597dc3;
  color: #ffffff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

.btn-login:hover { background: #4a6db3; }
.btn-login:active { transform: translateY(1px); }

/* ----- App shell ----- */

.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1030;
  border-right: 1px solid #333333;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px;
  border-bottom: 1px solid var(--sidebar-divider);
}

.sidebar-brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #597dc3;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-brand-text .brand-title {
  font-weight: 700;
  font-size: 14px;
  color: #ffffff;
  line-height: 1.2;
}

.sidebar-brand-text .brand-subtitle {
  font-size: 10px;
  color: var(--sidebar-text-muted);
  margin-top: 2px;
}

.sidebar-menu-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: #555555;
  text-transform: uppercase;
  padding: 16px 16px 6px 16px;
  font-weight: 600;
}

.sidebar-menu-divider {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: #555555;
  text-transform: uppercase;
  padding: 16px 16px 6px 16px;
  font-weight: 600;
  border-top: 1px solid #333333;
  margin-top: 8px;
}

.sidebar-menu {
  list-style: none;
  margin: 0;
  padding: 0 8px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-menu li + li {
  margin-top: 1px;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 12px;
  border-left: 3px solid transparent;
  border-radius: 0;
  color: #cccccc;
  font-size: 14px;
  transition: all 0.15s ease;
}

.sidebar-menu a i {
  width: 18px;
  text-align: center;
  font-size: 14px;
  opacity: 0.6;
}

.sidebar-menu a:hover {
  background: rgba(89, 125, 195, 0.15);
  color: #597dc3;
  border-left: 3px solid #597dc3;
}

.sidebar-menu a:hover i {
  opacity: 1;
}

.sidebar-menu a.active {
  background: rgba(89, 125, 195, 0.15);
  color: #597dc3;
  font-weight: 600;
  border-left: 3px solid #597dc3;
}

.sidebar-menu a.active i {
  opacity: 1;
  color: #597dc3;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-divider);
  font-size: 10px;
  color: var(--sidebar-text-muted);
}

/* Main column */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-sub);
  font-size: 13px;
}

.topbar-user .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #597dc3;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.topbar-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 4px;
  background: #242424;
  color: #cccccc;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid #333333;
  transition: background 0.15s;
}

.topbar-logout:hover {
  background: #c62828;
  border-color: #c62828;
  color: #ffffff;
}

/* Content */
.content {
  padding: 24px;
  flex: 1;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-sub);
  margin: -4px 0 20px 0;
}

/* ----- KPI cards ----- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--card-shadow);
  transition: transform 0.15s;
}

.kpi-card:hover {
  transform: translateY(-1px);
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.kpi-icon.kpi-icon-blue  { background: var(--accent-blue-soft);  color: var(--accent-blue); }
.kpi-icon.kpi-icon-green { background: var(--accent-green-soft); color: var(--accent-green); }
.kpi-icon.kpi-icon-red   { background: var(--accent-red-soft);   color: var(--accent-red); }
.kpi-icon.kpi-icon-amber { background: var(--accent-amber-soft); color: var(--accent-amber); }

.kpi-body {
  min-width: 0;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-sub);
  margin-bottom: 4px;
  font-weight: 500;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
}

.kpi-value .kpi-unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-sub);
  margin-left: 4px;
}

/* ----- Panel (card with left accent) ----- */

.panel {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
  margin-bottom: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--card-border);
  position: relative;
}

.panel-head::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 0;
  width: 3px;
  background: var(--accent-blue);
  border-radius: 0 3px 3px 0;
}

.panel-head i {
  color: var(--accent-blue);
  font-size: 14px;
}

.panel-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.panel-body {
  padding: 16px 18px;
}

.panel-body.p-0 {
  padding: 0;
}

.panel-empty {
  margin: 0;
  padding: 18px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ----- Tables ----- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table thead th {
  background: #1c1c1c;
  color: #999999;
  font-weight: 600;
  font-size: 12px;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #333333;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #282828;
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: #222222;
}

.data-table tbody tr.row-success td {
  background: #1b3a1b;
}

.data-table tbody tr.row-error td {
  background: #3a1b1b;
}

.data-table td.text-end,
.data-table th.text-end {
  text-align: right;
}

.data-table td.mono,
.data-table .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--text-sub);
}

/* ----- Trend bars ----- */

.trend-bar {
  height: 8px;
  background: #282828;
  border-radius: 999px;
  overflow: hidden;
  min-width: 80px;
}

.trend-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #597dc3, #7b9dd3);
  border-radius: 999px;
  min-width: 2px;
}

/* ----- Badges ----- */

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  background: var(--accent-slate-soft);
  color: var(--accent-slate);
}

.tag.tag-green  { background: var(--accent-green-soft); color: #4caf50; }
.tag.tag-blue   { background: var(--accent-blue-soft);  color: #597dc3; }
.tag.tag-red    { background: var(--accent-red-soft);   color: #ef5350; }
.tag.tag-amber  { background: var(--accent-amber-soft); color: #ffa726; }
.tag.tag-slate  { background: var(--accent-slate-soft); color: #8a8a8a; }

/* ----- Panel footer + pagination ----- */

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--card-border);
  background: #1a1a1a;
  flex-wrap: wrap;
}

.pagination-info {
  font-size: 12px;
  color: var(--text-sub);
}

.pagination {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pagination-link {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-sub);
  background: #242424;
  border: 1px solid #333333;
  transition: background 0.15s, color 0.15s;
}

.pagination-link:hover:not(.is-disabled):not(.is-active) {
  background: #2a2a2a;
  color: #cccccc;
}

.pagination-link.is-active {
  background: #597dc3;
  border-color: #597dc3;
  color: #ffffff;
  font-weight: 600;
}

.pagination-link.is-disabled {
  color: #444444;
  cursor: default;
  background: #1c1c1c;
}

/* ----- Long log detail cell ----- */

.log-detail {
  max-width: 520px;
  font-size: 12px;
  color: var(--text-sub);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-scroll {
  overflow-x: auto;
}

/* ----- Alerts ----- */

.alert-box {
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-box.alert-error {
  background: var(--accent-red-soft);
  color: #ef5350;
  border: 1px solid rgba(239, 83, 80, 0.3);
}

.alert-box.alert-success {
  background: var(--accent-green-soft);
  color: #4caf50;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.alert-box.alert-info {
  background: var(--accent-blue-soft);
  color: #7b9dd3;
  border: 1px solid rgba(89, 125, 195, 0.3);
}

/* Panel head with an inline action button on the right. */
.panel-head .ms-auto {
  margin-left: auto !important;
}

/* ----- Sync control screen ----- */

.sync-state-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.sync-state-main {
  flex: 1 1 260px;
  min-width: 240px;
}

.sync-state-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 6px;
}

.sync-state-indicator.is-on {
  background: var(--accent-green-soft);
  color: #4caf50;
}

.sync-state-indicator.is-off {
  background: var(--accent-slate-soft);
  color: #8a8a8a;
}

.sync-state-indicator i {
  font-size: 22px;
}

.sync-state-help {
  margin: 10px 0 0 2px;
  color: var(--text-sub);
  font-size: 13px;
}

.sync-state-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sync-meta-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.sync-meta-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  width: 120px;
}

.sync-meta-value {
  font-size: 14px;
  color: var(--text-main);
}

tr.sync-media-disabled td {
  color: var(--text-muted);
}

/* ----- Notices ----- */

.notice-preview {
  max-width: 520px;
  color: var(--text-sub);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notice-modal-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.notice-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  color: var(--text-main);
  line-height: 1.7;
  background: #242424;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: 14px 16px;
  min-height: 120px;
}

/* ----- Password cell toggle ----- */

.pw-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pw-cell .pw-mask,
.pw-cell .pw-value {
  letter-spacing: 0.04em;
  color: var(--text-main);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pw-cell .pw-value {
  color: #cccccc;
  font-weight: 500;
}

.pw-cell .btn {
  padding: 2px 8px;
  line-height: 1;
}

/* ----- Media credentials cards (C-09) ----- */

.media-cred-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.media-cred-card {
  margin-bottom: 0;
}

.media-cred-card .panel-head i[class*="media-cred-icon-"] {
  font-size: 16px;
  margin-right: 2px;
}

.media-cred-icon-blue  { color: var(--accent-blue); }
.media-cred-icon-green { color: var(--accent-green); }
.media-cred-icon-amber { color: var(--accent-amber); }
.media-cred-icon-red   { color: var(--accent-red); }

.media-cred-card .panel-head::before {
  background: var(--accent-blue);
}

/* ----- Bootstrap dark overrides ----- */

.btn-primary {
  background-color: #597dc3;
  border-color: #597dc3;
  color: #ffffff;
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: #4a6db3;
  border-color: #4a6db3;
  color: #ffffff;
}

.btn-light {
  background-color: #242424;
  border-color: #333333;
  color: #cccccc;
}

.btn-light:hover {
  background-color: #2a2a2a;
  border-color: #444444;
  color: #ffffff;
}

.btn-outline-danger {
  color: #ef5350;
  border-color: #ef5350;
}

.btn-outline-danger:hover {
  background-color: rgba(239, 83, 80, 0.12);
  color: #ff6b6b;
}

.btn-danger {
  background-color: #c62828;
  border-color: #c62828;
  color: #ffffff;
}

.text-muted {
  color: var(--text-muted) !important;
}

.text-success {
  color: #4caf50 !important;
}

.text-danger {
  color: #ef5350 !important;
}

hr {
  border-color: #333333;
}

/* Course masters inline styles */
.course-item {
  border-bottom-color: #282828 !important;
}

.course-add-row {
  border-top-color: #333333 !important;
}

.course-duration {
  color: #cccccc !important;
}

/* ----- Scrollbar ----- */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #181818;
}

::-webkit-scrollbar-thumb {
  background: #444444;
  border-radius: 3px;
}

/* ----- Responsive ----- */

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
  .main {
    margin-left: 0;
  }
  .topbar {
    padding: 0 16px;
  }
  .content {
    padding: 16px;
  }
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 18px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 4px;
}

.sidebar-toggle:hover {
  background: #2a2a2a;
  color: #cccccc;
}

@media (max-width: 900px) {
  .sidebar-toggle {
    display: inline-flex;
  }
}
