/* WebSQL - layout only. All colors/typography/radii come from the
   Luveedu UI library tokens (library.css).

   Library layout contract (do not fight it):
     body.lv-app            display:flex
       .lv-sidebar          268px sticky column  (direct child)
       .lv-app-main         flex:1 column        (direct child)
         .lv-header         sticky 68px
         .lv-main           padded content area                                    */

/* ------------------------------ login ------------------------------ */
.login-wrap {
  flex: 1;                             /* fill body.lv-app flex row */
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: var(--lv-space-4);
  background:
    radial-gradient(60rem 30rem at 85% -10%,
      color-mix(in srgb, var(--lv-accent-500) 14%, transparent), transparent 60%),
    radial-gradient(50rem 26rem at 0% 110%,
      color-mix(in srgb, var(--lv-accent-500) 10%, transparent), transparent 55%),
    var(--lv-bg-canvas);
}
.login-card { width: min(420px, 100%); }
.login-brand { display: flex; align-items: center; gap: var(--lv-space-3);
  margin-bottom: var(--lv-space-5); }
.login-brand img { border-radius: var(--lv-radius-pill); width: 44px; height: 44px;
  object-fit: cover; display: block; }
.login-title { margin: 0; font-size: 22px; font-weight: 800;
  color: var(--lv-text-primary); line-height: 1.2; }
.login-error {
  background: color-mix(in srgb, var(--lv-danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--lv-danger) 45%, transparent);
  color: var(--lv-danger); border-radius: var(--lv-radius-md);
  padding: 10px 12px; font-size: 13.5px; margin-bottom: var(--lv-space-4);
}

/* ------------------------------ shell ------------------------------ */
/* .lv-main already pads (28/32 desktop, smaller on mobile per library). */
.content-max { max-width: 1400px; margin: 0 auto; }

.crumb { display: flex; align-items: center; gap: 6px; font-weight: 600;
  color: var(--lv-text-primary); min-width: 0; }
.crumb .sep { color: var(--lv-text-tertiary); font-weight: 400; }
.crumb .db { cursor: pointer; white-space: nowrap; }
.crumb .db:hover { color: var(--lv-link-hover); }
.crumb .tbl { font-family: var(--lv-font-mono); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }

.pane { animation: fadein var(--lv-duration-fast) var(--lv-easing-standard); }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); }
                    to { opacity: 1; transform: none; } }

/* sidebar db/table tree */
.db-item { display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border-radius: var(--lv-radius-md); border: 0;
  background: transparent; color: var(--lv-sidebar-text); cursor: pointer;
  font: inherit; font-size: 14px; text-align: left; }
.db-item:hover { background: var(--lv-sidebar-hover-bg); }
.db-item.active { background: var(--lv-sidebar-active-bg);
  color: var(--lv-sidebar-active-icon); font-weight: 600; }
.tbl-list { margin: 2px 0 6px; }
.tbl-item { display: flex; align-items: center; justify-content: space-between;
  gap: 8px; width: 100%; padding: 6px 10px 6px 26px; border: 0;
  background: transparent; color: var(--lv-sidebar-text-muted); cursor: pointer;
  font: inherit; font-size: 13.5px; text-align: left;
  border-radius: var(--lv-radius-md); }
.tbl-item:hover { background: var(--lv-sidebar-hover-bg);
  color: var(--lv-sidebar-text); }
.tbl-item.active { background: var(--lv-sidebar-active-bg);
  color: var(--lv-sidebar-active-icon); font-weight: 600; }
.tbl-item .n { font-size: 11px; color: var(--lv-sidebar-text-muted); }

/* table view head */
.table-head { display: flex; align-items: center; justify-content: space-between;
  gap: var(--lv-space-3); margin-bottom: var(--lv-space-4); flex-wrap: wrap; }
.tab-chips { display: inline-flex; gap: 8px; flex-wrap: wrap; }

.toolbar { display: flex; gap: var(--lv-space-2); margin-bottom: var(--lv-space-3);
  flex-wrap: wrap; }
.grow { flex: 1 1 220px; }

.grid-wrap { max-height: calc(100vh - 330px); overflow: auto; }
.grid-wrap .lv-table { font-size: 13px; }
.grid-wrap .lv-table th { position: sticky; top: 0; z-index: 2; white-space: nowrap; }
.grid-wrap .lv-table th.sortable { cursor: pointer; user-select: none; }
.grid-wrap .lv-table th.sortable:hover { color: var(--lv-accent-500); }
.grid-wrap .lv-table td { max-width: 340px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.grid-wrap .lv-table td.num { text-align: right; font-family: var(--lv-font-mono); }
.grid-wrap .lv-table td.nullv { color: var(--lv-text-disabled); font-style: italic; }
.row-actions { white-space: nowrap; width: 1%; }

/* structure */
.struct-grid { display: grid; grid-template-columns: 1fr; gap: var(--lv-space-4); }
@media (min-width: 1000px) { .struct-grid { grid-template-columns: 3fr 2fr; } }

/* sql tab */
.sql-editor { font-size: 13.5px; resize: vertical; min-height: 120px; width: 100%; }
.sql-preview { background: var(--lv-bg-surface-2);
  border: 1px solid var(--lv-border-muted); border-radius: var(--lv-radius-md);
  padding: 10px 12px; font-size: 12.5px; overflow: auto;
  color: var(--lv-text-secondary); margin: 0; white-space: pre-wrap; }

/* row form (inside modal body) */
.rowform-row { display: grid; grid-template-columns: 200px 1fr auto;
  gap: 10px 14px; align-items: center; padding: 8px 0;
  border-bottom: 1px solid var(--lv-border-muted); }
.rowform-row:last-child { border-bottom: 0; }
.rowform-row .colname { font-family: var(--lv-font-mono); font-size: 13px;
  color: var(--lv-text-primary); display: flex; flex-direction: column; gap: 2px;
  word-break: break-all; }
.rowform-row .coltype { font-size: 11px; color: var(--lv-text-tertiary);
  font-family: var(--lv-font-ui); }
.rowform-row .nullchk { display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--lv-text-tertiary); white-space: nowrap; }
@media (max-width: 719px) {
  .rowform-row { grid-template-columns: 1fr; gap: 6px; }
}

/* new-table column builder */
.nt-row { display: grid; grid-template-columns: 1.2fr 1.2fr repeat(4, auto);
  gap: 8px; align-items: center; margin-bottom: 8px; }
.nt-row .lv-input, .nt-row .lv-select { padding: 7px 10px; font-size: 13px; }
.nt-row label { font-size: 11px; color: var(--lv-text-tertiary);
  display: flex; gap: 4px; align-items: center; }

/* toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--lv-bg-surface-2); color: var(--lv-text-primary);
  border: 1px solid var(--lv-border-strong);
  border-left: 3px solid var(--lv-success-500);
  border-radius: var(--lv-radius-md); box-shadow: var(--lv-shadow-lg);
  padding: 10px 14px; font-size: 13.5px; max-width: 380px;
  animation: slidein var(--lv-duration-base) var(--lv-easing-emphasized); }
.toast.err { border-left-color: var(--lv-danger-500); }
@keyframes slidein { from { opacity: 0; transform: translateX(12px); }
                     to { opacity: 1; transform: none; } }

.skel-grid .lv-skel-row { height: 34px; margin-bottom: 6px; }

/* responsive helpers not in library */
.hide-sm { display: inline; }
@media (max-width: 640px) {
  .hide-sm { display: none; }
}
