:root {
  --cp-sidebar-width: 290px;
  --cp-bg: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
}

html[data-bs-theme="dark"] {
  --cp-bg: radial-gradient(circle at top, #1f2937 0, #0f172a 42%, #020617 100%);
}

body.cp-body {
  min-height: 100vh;
  background: var(--cp-bg);
}

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

.cp-sidebar {
  width: var(--cp-sidebar-width);
  background: rgba(15, 23, 42, 0.94);
  color: #e5e7eb;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.cp-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.55);
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.cp-topbar-title {
  min-width: 0;
}

.cp-topbar-actions {
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.cp-main > .container-fluid {
  flex: 1;
}

.cp-footer {
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(8px);
}

html[data-bs-theme="dark"] .cp-footer {
  background: rgba(2, 6, 23, 0.45);
  border-top-color: rgba(148, 163, 184, 0.25);
}

html[data-bs-theme="dark"] .cp-topbar {
  background: rgba(2, 6, 23, 0.55);
  color: #e2e8f0;
}

.cp-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.cp-brand-badge {
  width: 3rem;
  height: 3rem;
  border-radius: 1rem;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #fff;
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.35);
}

.cp-nav-link {
  color: #cbd5e1;
  border-radius: 0.85rem;
  padding: 0.8rem 0.9rem;
}

.cp-nav-link:hover,
.cp-nav-link.active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.cp-card {
  border: 0;
  border-radius: 1.2rem;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

.cp-info-box {
  padding: 1rem;
  border-radius: 1rem;
  background: rgba(148, 163, 184, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.cp-info-box span {
  font-size: 0.82rem;
  color: #64748b;
}

.cp-tree {
  max-height: 70vh;
  overflow: auto;
  font-size: 0.92rem;
}

.cp-tree-node {
  margin-left: 0.3rem;
}

.cp-tree-dir-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.cp-tree-toggle,
.cp-tree-toggle-placeholder {
  width: 1.25rem;
  height: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cp-tree-toggle {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  cursor: pointer;
}

.cp-tree-toggle-placeholder {
  opacity: 0;
}

.cp-tree-children {
  margin-left: 1rem;
  padding-left: 0.6rem;
  border-left: 1px solid rgba(148, 163, 184, 0.18);
}

.cp-tree-children.collapsed {
  display: none;
}

.cp-tree-link,
.cp-tree-file-row a {
  display: inline-block;
  padding: 0.3rem 0;
  text-decoration: none;
  color: inherit;
}

.cp-tree-link.active {
  font-weight: 700;
}

.cp-editor {
  height: 72vh;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px;
  overflow: hidden;
}

.explorer-list {
  max-height: 36vh;
  overflow: auto;
}

.cp-log-box {
  max-height: 72vh;
  overflow: auto;
  background: rgba(15, 23, 42, 0.96);
  color: #d1fae5;
  border-radius: 1rem;
  padding: 1rem;
  font-size: 0.85rem;
}

body.cp-body.cp-no-page-scroll {
  height: 100vh;
  overflow: hidden;
}

.cp-mysql-db-list {
  max-height: 48vh;
  overflow: auto;
}

.cp-mysql-table-list {
  max-height: 24vh;
  overflow: auto;
}

.cp-mysql-grid {
  max-height: calc(100vh - 280px);
  overflow: auto;
}

.cp-mysql-table {
  white-space: nowrap;
}

.cp-mysql-table .cp-mysql-actions-col,
.cp-mysql-table .cp-mysql-actions-cell {
  position: sticky;
  right: 0;
  z-index: 2;
  min-width: 145px;
}

.cp-mysql-table .cp-mysql-actions-col {
  background: var(--bs-tertiary-bg);
}

.cp-mysql-table .cp-mysql-actions-cell {
  background: var(--bs-body-bg);
}

.cp-mysql-table .cp-mysql-actions-cell .btn {
  margin-left: 0.35rem;
}

.cp-mobile-nav {
  --bs-offcanvas-width: 290px;
  background: rgba(15, 23, 42, 0.98);
  color: #e5e7eb;
}

.cp-mobile-nav .offcanvas-header {
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.cp-mobile-nav .btn-close {
  filter: invert(1) grayscale(100%);
  opacity: 0.9;
}

.cp-mobile-nav .cp-nav-link {
  color: #cbd5e1;
}

.cp-mobile-nav .cp-nav-link:hover,
.cp-mobile-nav .cp-nav-link.active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.cp-mobile-nav .text-secondary {
  color: rgba(226, 232, 240, 0.72) !important;
}

.cp-mysql-edit-modal-body {
  max-height: 70vh;
  overflow: auto;
}

.cp-mysql-filter-row th {
  padding: 4px 6px;
  background: var(--bs-tertiary-bg);
}

.cp-mysql-filter-row input {
  min-width: 80px;
}

@media (max-width: 991.98px) {
  body.cp-body.cp-no-page-scroll {
    height: auto;
    overflow: auto;
  }

  .cp-topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 0.875rem 1rem;
  }

  .cp-topbar-actions {
    width: 100%;
  }

  .cp-mysql-grid {
    max-height: 60vh;
  }

  .cp-editor {
    height: 58vh;
  }

  .cp-tree,
  .explorer-list,
  .cp-log-box {
    max-height: 48vh;
  }

  .cp-mysql-table-list,
  .cp-mysql-db-list {
    max-height: 34vh;
  }

  .cp-mysql-table {
    font-size: 0.9rem;
  }

  .cp-mysql-table .cp-mysql-actions-col,
  .cp-mysql-table .cp-mysql-actions-cell {
    min-width: 120px;
  }

  .cp-mysql-filter-row input {
    min-width: 72px;
  }
}

@media (max-width: 991.98px) {
  .cp-sidebar {
    display: none;
  }
}

@media (max-width: 575.98px) {
  .cp-topbar {
    gap: 0.75rem;
  }

  .cp-topbar-actions {
    gap: 0.5rem;
  }

  .cp-topbar-actions .btn {
    flex: 1 1 auto;
  }

  .cp-card {
    border-radius: 1rem;
  }

  .cp-mysql-grid {
    max-height: 50vh;
  }

  .cp-mysql-table {
    font-size: 0.85rem;
  }

  .cp-mysql-table .btn,
  .cp-mysql-table .form-control {
    font-size: 0.8rem;
  }

  .cp-mysql-table .cp-mysql-actions-col,
  .cp-mysql-table .cp-mysql-actions-cell {
    min-width: 108px;
  }
}
