/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 210px;
  --topnav-h: 32px;
  --breadcrumb-h: 22px;
  --statusbar-h: 22px;
  --console-h: 0px;

  /* pmahomme palette */
  --c-bg:          #f0f0f0;
  --c-sidebar-bg:  #e8e8e8;
  --c-sidebar-border: #ccc;
  --c-topnav-bg:   #d4d4d4;
  --c-topnav-active: #f5f5f5;
  --c-box-head:    #6c8ebf;
  --c-box-head-txt:#fff;
  --c-box-bg:      #fff;
  --c-box-border:  #bbb;
  --c-link:        #1a6496;
  --c-link-hover:  #0a3d6b;
  --c-text:        #333;
  --c-status-bar:  #d4d4d4;
  --c-table-stripe:#f8f8f8;
}

html, body {
  height: 100%;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 12px;
  color: var(--c-text);
  background: var(--c-bg);
  overflow: hidden;
}

a { color: var(--c-link); text-decoration: none; }
a:hover { color: var(--c-link-hover); text-decoration: underline; }

/* ── Layout shell ──────────────────────────────────────────── */
body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 1fr;
  height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  grid-column: 1;
  grid-row: 1;
  background: var(--c-sidebar-bg);
  border-right: 1px solid var(--c-sidebar-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-logo {
  padding: 8px 8px 4px;
  border-bottom: 1px solid var(--c-sidebar-border);
  background: #fff;
}

.pma-logo { width: 160px; height: auto; display: block; }
.pma-version {
  font-size: 10px;
  color: #888;
  text-align: right;
  padding-right: 4px;
  margin-top: -2px;
}

.sidebar-icons {
  display: flex;
  gap: 2px;
  padding: 3px 6px;
  background: #f0f0f0;
  border-bottom: 1px solid var(--c-sidebar-border);
}
.sidebar-icon {
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  text-decoration: none;
}
.sidebar-icon:hover { background: #ddd; border-radius: 3px; }

.sidebar-server-select {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--c-sidebar-border);
  font-size: 11px;
  flex-wrap: wrap;
}
.sidebar-server-select label { color: #555; flex-shrink: 0; }
.sidebar-server-select select {
  flex: 1;
  font-size: 11px;
  border: 1px solid #bbb;
  border-radius: 2px;
  padding: 1px 2px;
  min-width: 0;
}
.btn-new {
  font-size: 11px;
  padding: 1px 6px;
  background: #e8e8e8;
  border: 1px solid #aaa;
  border-radius: 2px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-new:hover { background: #d0d0d0; }

.db-filter {
  display: flex;
  align-items: center;
  padding: 4px 6px;
  border-bottom: 1px solid var(--c-sidebar-border);
  gap: 4px;
}
.db-filter input {
  flex: 1;
  font-size: 11px;
  border: 1px solid #bbb;
  border-radius: 2px;
  padding: 2px 4px;
}
.btn-filter-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: #888;
  font-size: 12px;
  line-height: 1;
  padding: 0 2px;
}

/* Database tree */
.db-tree {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0;
}
.db-tree::-webkit-scrollbar { width: 6px; }
.db-tree::-webkit-scrollbar-thumb { background: #bbb; border-radius: 3px; }

.db-entry {
  padding: 0;
  user-select: none;
}
.db-entry > div, .db-entry > span {
  display: inline;
}

.db-entry > .db-toggle,
.db-entry > .db-icon,
.db-entry > .db-name {
  /* displayed inline within same row */
}

.table-list { display: none; }
.db-entry.expanded .table-list { display: block; }

/* Row wrapper for db-entry top line */
.db-entry {
  line-height: 1;
}
.db-entry > * { vertical-align: middle; }

.db-toggle {
  display: inline-block;
  width: 14px;
  font-size: 9px;
  cursor: pointer;
  color: #666;
  text-align: center;
  padding-left: 4px;
}

.db-icon { font-size: 12px; margin: 0 2px; }

.db-name {
  font-size: 12px;
  color: var(--c-link);
  line-height: 20px;
  display: inline-block;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.db-name:hover { color: var(--c-link-hover); }

/* Row container per db entry */
.db-row {
  display: flex;
  align-items: center;
  padding: 1px 0;
  cursor: pointer;
}
.db-row:hover { background: #dde; }

.table-list {
  list-style: none;
  margin-left: 24px;
  border-left: 1px solid #ccc;
}

.table-entry {
  display: flex;
  align-items: center;
  padding: 1px 0 1px 6px;
  line-height: 18px;
}
.table-entry:hover { background: #dde; }
.tbl-icon { font-size: 11px; margin-right: 3px; }
.table-entry a {
  font-size: 11px;
  color: var(--c-link);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
  display: inline-block;
}

.sidebar-footer {
  padding: 4px 8px;
  border-top: 1px solid var(--c-sidebar-border);
  background: #f0f0f0;
}
.sidebar-new-db {
  font-size: 11px;
  font-weight: bold;
  color: var(--c-link);
}

/* ── Main Panel ────────────────────────────────────────────── */
.main-panel {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--c-bg);
}

/* Top Nav */
.top-nav {
  display: flex;
  align-items: flex-end;
  background: var(--c-topnav-bg);
  border-bottom: 1px solid #aaa;
  padding: 0 4px;
  flex-shrink: 0;
  height: calc(var(--topnav-h) + 4px);
  gap: 1px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 10px 3px;
  font-size: 12px;
  color: #444;
  text-decoration: none;
  background: #c8c8c8;
  border: 1px solid #aaa;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  margin-bottom: -1px;
  transition: background 0.1s;
  line-height: 1.3;
}
.tab img { width: 14px; height: 14px; }
.tab:hover { background: #e8e8e8; color: #111; text-decoration: none; }
.tab.active {
  background: var(--c-topnav-active);
  color: #000;
  border-color: #aaa;
  font-weight: bold;
}

/* Breadcrumb */
.breadcrumb {
  padding: 3px 8px;
  font-size: 11px;
  color: #666;
  background: #ebebeb;
  border-bottom: 1px solid #ccc;
  flex-shrink: 0;
}
.breadcrumb a { color: var(--c-link); }

/* Content area */
.content-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
}
.content-area::-webkit-scrollbar { width: 8px; }
.content-area::-webkit-scrollbar-thumb { background: #bbb; border-radius: 4px; }

/* Views */
.view { display: none; }
.view.active { display: block; }

/* Content grid (two columns) */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: start;
}

/* ── pma-box ────────────────────────────────────────────────── */
.pma-box {
  background: var(--c-box-bg);
  border: 1px solid var(--c-box-border);
  border-radius: 2px;
  margin-bottom: 8px;
  overflow: hidden;
}

.box-title {
  background: var(--c-box-head);
  color: var(--c-box-head-txt);
  font-size: 12px;
  font-weight: bold;
  padding: 4px 8px;
  margin: 0;
}

.box-body {
  padding: 8px;
}

/* Settings table */
.settings-table {
  width: 100%;
  border-collapse: collapse;
}
.settings-table tr { margin-bottom: 4px; }
.settings-table td {
  padding: 3px 4px;
  vertical-align: middle;
}
.label-cell { white-space: nowrap; color: #555; }
.label-cell label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.icon-wrap { font-size: 13px; }
.help-icon {
  font-size: 11px;
  cursor: pointer;
  opacity: 0.6;
}
.help-icon:hover { opacity: 1; }

.settings-table select {
  font-size: 11px;
  border: 1px solid #bbb;
  border-radius: 2px;
  padding: 2px 4px;
  width: 100%;
  max-width: 220px;
}

.box-actions { margin-top: 6px; }
.link-more-settings { font-size: 11px; }

.theme-cell { display: flex; align-items: center; gap: 6px; }
.theme-cell select { max-width: 120px; }
.btn-view-all {
  font-size: 11px;
  padding: 1px 8px;
  background: #e8e8e8;
  border: 1px solid #aaa;
  border-radius: 2px;
  white-space: nowrap;
}

/* Info list */
.info-list {
  list-style: none;
  font-size: 12px;
  line-height: 1.7;
}
.info-label { font-weight: bold; color: #555; }
.ext-link {
  color: var(--c-link);
  cursor: pointer;
  text-decoration: underline;
  font-size: 11px;
}

/* ── SQL view ────────────────────────────────────────────────── */
.sql-textarea {
  width: 100%;
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
  border: 1px solid #bbb;
  border-radius: 2px;
  padding: 6px;
  resize: vertical;
  outline: none;
}
.sql-textarea:focus { border-color: #6c8ebf; box-shadow: 0 0 3px rgba(108,142,191,0.4); }

.sql-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  flex-wrap: wrap;
}
.sql-controls label { display: flex; align-items: center; gap: 4px; cursor: pointer; }

.btn-go {
  padding: 3px 20px;
  background: linear-gradient(to bottom, #f5f5f5, #ddd);
  border: 1px solid #aaa;
  border-radius: 3px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  margin-left: auto;
}
.btn-go:hover { background: linear-gradient(to bottom, #e8e8e8, #ccc); }
.btn-go:active { background: #ccc; }

.bookmark-section {
  border-top: 1px solid #eee;
  padding-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  color: #666;
}
.bookmark-label {
  font-size: 11px;
  border: 1px solid #bbb;
  border-radius: 2px;
  padding: 2px 6px;
  width: 160px;
}

/* ── Status table ─────────────────────────────────────────────── */
.status-loading { display: none; }
.status-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.status-table th {
  background: #6c8ebf;
  color: #fff;
  padding: 4px 8px;
  text-align: left;
}
.status-table td { padding: 3px 8px; border-bottom: 1px solid #eee; }
.status-table tr:nth-child(even) td { background: var(--c-table-stripe); }

/* ── Status bar ────────────────────────────────────────────────── */
.status-bar {
  flex-shrink: 0;
  height: var(--statusbar-h);
  background: var(--c-status-bar);
  border-top: 1px solid #aaa;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 11px;
  color: #555;
  gap: 8px;
}
#status-message { display: flex; align-items: center; gap: 4px; flex: 1; }
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
}
.status-dot.green { background: #4caf50; }
.status-dot.yellow { background: #f5a623; }

.status-right {
  cursor: pointer;
  user-select: none;
  color: var(--c-link);
  font-size: 11px;
}
.status-right:hover { color: var(--c-link-hover); }

/* ── Console Drawer ────────────────────────────────────────────── */
.console-drawer {
  flex-shrink: 0;
  max-height: 0;
  overflow: hidden;
  border-top: 1px solid #aaa;
  background: #1e1e2e;
  transition: max-height 0.2s ease;
}
.console-drawer.open { max-height: 200px; }

.console-toolbar {
  display: flex;
  align-items: center;
  background: #2a2a3e;
  padding: 3px 6px;
  gap: 4px;
}
.console-btn {
  background: none;
  border: 1px solid #555;
  color: #aaa;
  border-radius: 2px;
  padding: 1px 8px;
  font-size: 11px;
  cursor: pointer;
}
.console-btn:hover, .console-btn.active { background: #3a3a5e; color: #fff; }
.console-go { border-color: #6c8ebf; color: #6c8ebf; }
.console-go:hover { background: #6c8ebf; color: #fff; }
.console-spacer { flex: 1; }
.console-input {
  width: 300px;
  background: #111;
  border: 1px solid #444;
  color: #eee;
  font-family: monospace;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 2px;
  outline: none;
}
.console-input:focus { border-color: #6c8ebf; }

.console-output {
  padding: 6px 10px;
  font-family: monospace;
  font-size: 11px;
  color: #aaa;
  max-height: 150px;
  overflow-y: auto;
}
.console-hint { color: #555; font-style: italic; }

/* ── Utility ───────────────────────────────────────────────────── */
select {
  cursor: pointer;
}

/* Sidebar db-entry row layout fix */
.db-entry {
  display: flex;
  flex-direction: column;
}
.db-header {
  display: flex;
  align-items: center;
  padding: 2px 4px;
  cursor: pointer;
  line-height: 18px;
}
.db-header:hover { background: #dde; }

/* ── Data table (used in variables, charsets, engines, plugins, status) ── */
.data-table {
  border-collapse: collapse;
  font-size: 12px;
}
.data-table.full-width { width: 100%; }
.data-table th {
  background: var(--c-box-head);
  color: #fff;
  padding: 4px 8px;
  text-align: left;
  font-weight: normal;
  white-space: nowrap;
}
.data-table td {
  padding: 3px 8px;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}
.data-table tr:nth-child(even) td { background: #f9f9f9; }
.data-table tr:hover td { background: #eef3fb; }

/* ── Settings view ── */
.settings-sections { display: flex; flex-direction: column; gap: 16px; }
.settings-group-title {
  font-size: 12px;
  font-weight: bold;
  color: #444;
  border-bottom: 1px solid #ddd;
  padding-bottom: 4px;
  margin-bottom: 6px;
}
.inline-select {
  font-size: 12px;
  border: 1px solid #bbb;
  border-radius: 2px;
  padding: 2px 4px;
}
.inline-input {
  font-size: 12px;
  border: 1px solid #bbb;
  border-radius: 2px;
  padding: 2px 6px;
  width: 80px;
}
.link-small { font-size: 11px; margin-left: 6px; }

/* ── Action buttons ── */
.btn-action {
  display: inline-block;
  padding: 3px 12px;
  background: linear-gradient(to bottom, #f5f5f5, #ddd);
  border: 1px solid #aaa;
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
  margin-top: 8px;
  font-family: inherit;
}
.btn-action:hover { background: linear-gradient(to bottom, #e8e8e8, #ccc); }

/* ── Table toolbar ── */
.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid #ddd;
  background: #f5f5f5;
}
.btn-action-sm {
  display: inline-block;
  padding: 2px 10px;
  background: linear-gradient(to bottom, #f5f5f5, #e0e0e0);
  border: 1px solid #aaa;
  border-radius: 3px;
  font-size: 11px;
  color: #333;
  cursor: pointer;
  text-decoration: none;
  line-height: 18px;
}
.btn-action-sm:hover { background: linear-gradient(to bottom, #e8e8e8, #ccc); text-decoration: none; color: #000; }

.table-footer-bar {
  padding: 6px 8px;
  font-size: 11px;
  color: #555;
  border-top: 1px solid #eee;
  background: #f9f9f9;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.table-footer-bar a { font-size: 11px; }

/* ── Status view sub-tabs ── */
.status-nav-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid #ccc;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.snav {
  padding: 4px 12px;
  font-size: 12px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 3px 3px 0 0;
  color: var(--c-link);
  text-decoration: none;
  margin-bottom: -1px;
}
.snav:hover { background: #eef; text-decoration: none; }
.snav.active {
  background: #fff;
  border-color: #ccc;
  color: #333;
  font-weight: bold;
}

/* ── Box section label ── */
.box-section-label {
  font-size: 11px;
  font-weight: bold;
  color: #555;
  margin-bottom: 4px;
  margin-top: 8px;
}
.box-section-label:first-child { margin-top: 0; }

/* ── Radio rows ── */
.radio-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
  margin-bottom: 4px;
}

/* ── Var value ── */
.var-val {
  font-family: monospace;
  font-size: 11px;
  color: #333;
  word-break: break-all;
}

/* ── msg success/error ── */
.msg-error { color: #c0392b; font-size: 12px; margin-top: 8px; }

/* ── Responsive tweak: hide sidebar on very small screens ── */
@media (max-width: 600px) {
  body { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
