:root {
  --bg: #111827;
  --panel: #1f2937;
  --surface: #111827;
  --text: #ffffff;
  --muted: #b2cefe;
  --accent: #94d9f6;
  --danger: #f97316;
  --background: #000a21;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  font-family: Inter, system-ui, sans-serif;
  background: var(--background);
  color: var(--text);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

header img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

header h1 {
  margin: 0;
  font-size: 1.8rem;
}

section {
  background: var(--panel);
  border-radius: 16px;
  padding: 24px;
}

.container:has(section.loginSection){
  width: 900px;
}

.hidden {
  display: none;
}

form {
  display: grid;
  gap: 14px;
  max-width: 360px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 0.95rem;
}

input, textarea, button {
  border: 1px solid #334155;
  border-radius: 10px;
  background: var(--background);
  color: var(--text);
  outline: none;
}

input, textarea {
  padding: 12px;
}

button {
  padding: 8px 12px;
  cursor: pointer;
  background: var(--background);
  border: none;
  color: var(--accent);
  font-weight: 700;
}

button:hover {
  opacity: 0.8;
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 16px;
}

.progress-container {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.progress {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #0ea5e9);
  transition: width 0.2s ease;
}

.progress-fill.indeterminate {
  width: 100%;
  animation: progress-indeterminate 1.3s infinite linear;
}

@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.row-select {
  margin: 0;
  padding: 8px 0.5rem;
  width: 48px important;
}

.text-align-right {
  text-align: right;
}

.text-align-left {
  text-align: left;
}

.text-align-center {
  text-align: center;
}

.progress-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid #334155;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  z-index: 2000;
  max-width: 300px;
  text-align: center;
}

.progress-modal .progress {
  margin-top: 10px;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  padding: 0;
  outline: none;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.icon-btn {
  min-width: 29px;
  width: auto;
  height: 29px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 8px;
  border: none;
  background: rgba(56, 189, 248, 0.18);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
  font-size: 0.8rem;
  padding: 0 9px;
}

.icon-btn i {
  font-size: 1rem;
  line-height: 1;
}

.icon-btn:hover {
  background: rgba(56, 189, 248, 0.28);
  transform: translateY(-1px);
}

#messageModal .icon-btn {
  padding: 10px 16px;
  min-width: 110px;
}

#messageModalConfirm {
  background: #22c55e;
  color: var(--background);
}

#messageModalConfirm:hover {
  background: #16a34a;
}

#messageModalCancel {
  background: #f43f5e;
  color: #ffffff;
}

#messageModalCancel:hover {
  background: #e11d48;
}

.icon-btn.danger:hover {
  background: rgba(249, 115, 22, 0.28);
}

.table-card td:last-child {
  min-width: 180px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.link-btn:hover {
  opacity: 0.9;
}

.icon-btn.danger:hover {
  background: rgba(249, 115, 22, 0.24);
}

.path-bar {
  margin-bottom: 16px;
  color: var(--muted);
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.table-card, .editor-card {
  background: #111827;
  border-radius: 16px;
  padding: 14px;
}

.editor-card {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #334155;
}

th {
  color: var(--muted);
}

tbody tr:hover {
  background: var(--background);
}

textarea {
  width: 100%;
  min-height: 320px;
  resize: vertical;
}

.editor-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  justify-content: flex-end;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-dialog {
  background: #1a2332;
  border-radius: 18px;
  border: 1px solid #334155;
  width: min(760px, calc(100% - 40px));
  max-height: min(90vh, 900px);
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.image-dialog {
  max-width: 760px;
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid #334155;
}

.modal-header {
  justify-content: flex-start;
}

.modal-footer {
  justify-content: flex-end;
}

.modal-header h2,
.modal-footer h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-body {
  padding: 18px 22px;
  overflow: auto;
}

.image-body {
  padding: 0 22px 22px;
}

.modal-body textarea {
  width: 100%;
  min-height: 420px;
  resize: vertical;
  background: var(--background);
  border: 1px solid #334155;
}

.modal-body img {
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  border-radius: 16px;
  background: #090d18;
}

.modal-dialog.message-dialog {
  max-width: 520px;
}

.modal-dialog.modal-info-dialog {
  max-width: 400px;
}

.modal-body p {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.6;
}

.modal-input {
  width: 100%;
  margin-top: 14px;
  padding: 10px;
  border-radius: 10px;
  background: var(--background);
  border: 1px solid #334155;
  color: var(--text);
}

.modal-footer {
  border-top: 1px solid #334155;
}

.modal-footer label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.modal-footer input {
  width: 100%;
  padding: 10px;
}

.permissions-grid {
  margin-top: 16px;
  padding: 10px;
  display: grid;
  gap: 8px;
  border-radius: 10px;
  border: 1px solid #334155;
}

.perm-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.perm-row span {
  min-width: 80px;
  font-weight: 500;
}

.perm-row label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.9rem;
}

.message {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.table-card th:nth-child(1), .table-card td:nth-child(1) {
  width: 4%;
}

.table-card th:nth-child(2), .table-card td:nth-child(2) {
  width: 64%;
}

.table-card th:nth-child(3), .table-card td:nth-child(3) {
  width: 12%;
}

.table-card th:nth-child(4), .table-card td:nth-child(4) {
  width: 20%;
}

.table-card td:first-child {
  max-width: 560px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-card td {
  word-break: break-word;
}



.icon-btn.danger:hover {
  background: rgba(249, 115, 22, 0.28);
}

#previewContainer {
  margin-bottom: 12px;
}

#previewContainer h4 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: var(--text);
}

#imagePreview {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid #334155;
  background: #09111f;
}

.message {
  margin-top: 10px;
  color: var(--accent);
}

.message.error {
  color: #ff6b6b;
  font-weight: 500;
}

.message.success {
  color: #51cf66;
  font-weight: 500;
}

.loginSection {
  width: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
}

.loginLogo {
  width: 100%;
  height: 120px;
  background: url('img/logo.png') center/contain no-repeat;
}

.loginForm {
  margin: 0 auto;
  width: 360px;
  padding: 0 20px;
  border: 1px solid #334155;
  border-radius: 10px;
}

.loginFooter {
  width: 100%;
  height: auto;
  bottom: 0;
  position: fixed;
  padding-bottom: 5px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  background: var(--background);
}

@media (max-width: 900px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

/* Directory Picker Modal */
.directory-picker-dialog {
  max-width: 600px;
  width: 90vw;
}

.directory-picker-body {
  max-height: 400px;
  display: flex;
  flex-direction: column;
}

.directory-tree {
  flex: 1;
  border: 1px solid #334155;
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 16px;
}

.directory-tree-content {
  max-height: 300px;
  overflow-y: auto;
  padding: 8px;
}

.directory-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.directory-item:hover {
  background: var(--panel);
}

.directory-item.selected {
  background: var(--accent);
  color: var(--bg);
}

.directory-item-icon {
  margin-right: 8px;
  width: 16px;
  text-align: center;
}

.directory-item-name {
  flex: 1;
  font-size: 14px;
}

.directory-item-toggle {
  margin-left: auto;
  width: 16px;
  text-align: center;
  cursor: pointer;
}

.directory-item-toggle.hidden {
  opacity: 0;
  pointer-events: none;
}

.directory-children {
  margin-left: 20px;
  border-left: 1px solid #334155;
  padding-left: 4px;
}

.selected-path {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid #334155;
  border-radius: 8px;
  font-family: monospace;
  font-size: 14px;
}

.selected-path label {
  font-weight: 500;
  color: var(--muted);
}

.selected-path span {
  color: var(--accent);
  word-break: break-all;
}
