/* src/public/css/style.css */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f1115;
  color: #e6e8eb;
  font-size: 14px;
}

a { color: #6ea8fe; text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
  background: #1a1d23;
  border: 1px solid #2c3138;
  border-radius: 4px;
  padding: 6px 10px;
}

button {
  cursor: pointer;
  background: #2c3138;
  user-select: none;
}
button:hover { background: #383f48; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: #2b5fc7; border-color: #2b5fc7; }
button.primary:hover { background: #3a6fd6; }
button.danger { background: #b1392e; border-color: #b1392e; }
button.danger:hover { background: #c8483a; }

.btn-icon { display: none; }

/* --- Login --- */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  height: 100vh;
}
.login-card {
  background: #161922;
  border: 1px solid #2c3138;
  border-radius: 8px;
  padding: 32px;
  width: 360px;
  box-shadow: 0 4px 24px rgba(0,0,0,.5);
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card .sub { color: #8a92a0; font-size: 13px; margin-bottom: 24px; }
.login-card label { display: block; margin-bottom: 4px; color: #b1b8c5; font-size: 12px; }
.login-card input { width: 100%; margin-bottom: 16px; }
.login-card .err { color: #ff6b6b; margin-bottom: 12px; min-height: 16px; font-size: 13px; }
.login-card button { width: 100%; padding: 10px; font-weight: 600; }

/* --- App shell --- */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}
.topbar {
  flex-shrink: 0;
  display: flex; align-items: center; flex-wrap: wrap;
  background: #161922;
  border-bottom: 1px solid #2c3138;
  padding: 8px 16px;
  gap: 12px;
}
.topbar .brand { font-weight: 600; }
.topbar .crumb {
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", monospace;
  color: #b1b8c5;
  flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .crumb a { cursor: pointer; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  padding: 4px 10px;
  border-radius: 4px;
  color: #e6e8eb;
}
.topbar nav a.active { background: #2c3138; }
.topbar nav a:hover { text-decoration: none; background: #232830; }

.address-bar {
  flex: 1;
  display: flex;
  gap: 6px;
}
.address-bar input {
  flex: 1;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  min-width: 0;
}

/* --- File browser --- */
.browser { display: grid; grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; overflow: hidden; }
.toolbar {
  display: flex; gap: 6px; align-items: center;
  padding: 8px 16px;
  background: #131722;
  border-bottom: 1px solid #2c3138;
}
.files-table {
  overflow: auto;
  padding: 0 16px 16px;
}
.files-table table { width: 100%; border-collapse: collapse; }
.files-table th, .files-table td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid #232830;
}
.files-table th { color: #8a92a0; font-weight: 500; font-size: 12px; text-transform: uppercase; }
.files-table tr.row:hover { background: #1a1f2c; cursor: pointer; }
.files-table tr.row.selected { background: #2b3550; }
.files-table .name { display: flex; align-items: center; gap: 8px; }
.files-table .icon { width: 16px; text-align: center; }
.files-table td.muted { color: #8a92a0; }
.files-table td.actions { text-align: right; white-space: nowrap; }

.statusbar {
  background: #161922;
  border-top: 1px solid #2c3138;
  padding: 4px 16px;
  font-size: 12px;
  color: #8a92a0;
}

/* --- Modal --- */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: #161922;
  border: 1px solid #2c3138;
  border-radius: 8px;
  padding: 20px;
  min-width: 360px;
  max-width: 90vw;
}
.modal h2 { margin-bottom: 12px; font-size: 16px; }
.modal .row { margin-bottom: 12px; }
.modal .row label { display: block; margin-bottom: 4px; color: #b1b8c5; font-size: 12px; }
.modal .row input, .modal .row textarea { width: 100%; }
.modal .row textarea { min-height: 240px; font-family: ui-monospace, monospace; font-size: 12px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #161922;
  border: 1px solid #2c3138;
  border-radius: 4px;
  padding: 10px 16px;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.toast.err { border-color: #b1392e; }
.toast.ok { border-color: #2b5fc7; }

/* --- WebView --- */
.wv {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
}
.wv-bar {
  display: flex; gap: 6px; align-items: center;
  padding: 8px 16px;
  background: #131722;
  border-bottom: 1px solid #2c3138;
}
.wv-bar input {
  flex: 1;
  font-family: ui-monospace, monospace;
  font-size: 13px;
}
.wv-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}
.wv-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.7);
  color: #aaa;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
}

/* --- Preview (split layout) --- */
.pv {
  flex: 1;
  display: flex;
  overflow: hidden;
}
.pv-side {
  width: 360px;
  flex-shrink: 0;
  background: #131722;
  border-right: 1px solid #2c3138;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pv-side .pv-head {
  padding: 10px 12px;
  border-bottom: 1px solid #2c3138;
  display: flex;
  gap: 6px;
  flex-direction: column;
}
.pv-side .pv-head .row1 { display: flex; gap: 6px; }
.pv-side .pv-head input { flex: 1; min-width: 0; }
.pv-side .pv-list { overflow: auto; flex: 1; }
.pv-cat {
  padding: 8px 12px 4px;
  color: #8a92a0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: sticky; top: 0;
  background: #131722;
  border-bottom: 1px solid #232830;
}
.pv-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid #232830;
  cursor: pointer;
}
.pv-item:hover { background: #1a1f2c; }
.pv-item.active { background: #2b3550; }
.pv-item .star { color: #f5c84b; }
.pv-item .star.off { color: #444; }
.pv-item .meta { color: #8a92a0; font-size: 11px; font-family: ui-monospace, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-item .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.pv-item .dot.online { background: #5ad36b; }
.pv-item .dot.offline { background: #e25c5c; }
.pv-item .dot.slow { background: #f5c84b; }
.pv-item .dot.unknown { background: #666; }

.pv-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #0f1115;
  overflow: hidden;
  min-width: 0;
}
.pv-toolbar {
  flex-shrink: 0;
  display: flex; gap: 8px; align-items: center;
  padding: 8px 16px;
  background: #161922;
  border-bottom: 1px solid #2c3138;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}
.pv-toolbar .url { flex: 1; color: #b1b8c5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-toolbar .actions { display: flex; gap: 6px; }
.pv-frame-host {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: transparent;
}
.pv-frame-host iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}
.pv-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%;
  color: #666;
  font-size: 14px;
}

@media (max-width: 768px) {
  .topbar {
    padding: 8px 12px;
  }
  .address-bar {
    order: 4;
    flex-basis: 100%;
    margin-top: 4px;
  }
  #logout-btn {
    margin-left: auto;
  }
  .pv {
    flex-direction: column !important;
  }
  .pv-side {
    width: 100% !important;
    height: 40vh !important;
    flex-shrink: 0 !important;
    border-right: none !important;
    border-bottom: 1px solid #2c3138 !important;
  }
  .pv-toolbar {
    flex-wrap: wrap;
  }
  .btn-text { display: none !important; }
  .btn-icon { display: inline !important; }
  .pv-toolbar .actions {
    flex-wrap: wrap;
  }
}

/* --- Fullscreen mode --- */
.app.fullscreen-preview .topbar {
  display: none !important;
}
.app.fullscreen-preview .pv-side {
  display: none !important;
}
/* pv-main inherently flex-grows to fill .pv, so no further CSS needed */