:root {
  --bg-primary: #0a0a0a;
  --bg-glass: rgba(255, 255, 255, 0.06);
  --bg-glass-hover: rgba(255, 255, 255, 0.10);
  --bg-glass-active: rgba(255, 255, 255, 0.14);
  --border-glass: rgba(255, 255, 255, 0.10);
  --border-glass-strong: rgba(255, 255, 255, 0.20);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.55);
  --text-muted: rgba(255, 255, 255, 0.35);
  --blur: blur(20px) saturate(180%);
  --radius-card: 14px;
  --radius-btn: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --transition: all 0.2s ease;
  --danger: #ff4444;
  --success: #44ff88;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
}

/* Animated background */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.03) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.02) 0%, transparent 50%);
  animation: float 20s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-30px, 20px) scale(1.05); }
  66% { transform: translate(20px, -30px) scale(0.98); }
}

/* Glass utility */
.glass {
  background: var(--bg-glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* === Login Page === */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  position: relative;
  z-index: 1;
}

.login-card {
  width: 380px;
  padding: 48px 40px;
  position: relative;
  z-index: 1;
}

.login-card h1 {
  font-size: 28px;
  font-weight: 300;
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 8px;
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 36px;
}

.input-group {
  margin-bottom: 24px;
}

.input-group input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-glass-strong);
  padding: 10px 0;
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: var(--transition);
}

.input-group input:focus {
  border-bottom-color: rgba(255, 255, 255, 0.6);
}

.input-group input::placeholder {
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-btn);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
  font-family: inherit;
}

.btn-primary {
  background: #fff;
  color: #000;
}

.btn-primary:hover {
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.15);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-glass-strong);
}

.btn-secondary:hover {
  background: var(--bg-glass-hover);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(255, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(255, 68, 68, 0.1);
  border-color: rgba(255, 68, 68, 0.5);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-icon {
  padding: 8px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-top: 16px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.error-msg.show {
  opacity: 1;
}

/* === Admin Page === */
.admin-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--border-glass);
  background: rgba(10, 10, 10, 0.7);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.topbar .logo {
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 1px;
  flex-shrink: 0;
}

.topbar .project-name {
  color: var(--text-secondary);
  font-size: 13px;
  padding-left: 16px;
  border-left: 1px solid var(--border-glass);
  flex-shrink: 0;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .link-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.topbar .link-input {
  flex: 1;
  max-width: 400px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-btn);
  padding: 6px 12px;
  color: var(--text-secondary);
  font-size: 12px;
  outline: none;
  font-family: monospace;
}

.topbar .spacer {
  flex: 1;
}

/* Main content */
.admin-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  padding: 12px;
  gap: 12px;
}

/* Left panel */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-glass);
  flex-shrink: 0;
}

.sidebar-header h3 {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.sidebar-section {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.sidebar-section + .sidebar-section {
  border-top: 1px solid var(--border-glass);
}

/* Project list */
.project-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
}

.project-item:hover {
  background: var(--bg-glass-hover);
}

.project-item.active {
  background: var(--bg-glass-active);
  border-left: 2px solid #fff;
  padding-left: 10px;
}

.project-item .name {
  flex: 1;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-item .del-btn {
  opacity: 0;
  transition: opacity 0.2s;
  color: var(--danger);
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
}

.project-item:hover .del-btn {
  opacity: 0.6;
}

.project-item .del-btn:hover {
  opacity: 1;
}

/* File tree */
.file-tree {
  list-style: none;
}

.file-tree ul {
  list-style: none;
  margin-left: 16px;
}

.tree-node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 13px;
}

.tree-node:hover {
  background: var(--bg-glass-hover);
}

.tree-node.active {
  background: var(--bg-glass-active);
}

.tree-node .icon {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.tree-node.file .icon {
  color: var(--text-muted);
}

.tree-node .label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-node .del-btn {
  margin-left: auto;
  opacity: 0;
  color: var(--danger);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 12px;
}

.tree-node:hover .del-btn {
  opacity: 0.6;
}

.tree-node .del-btn:hover {
  opacity: 1;
}

.empty-state {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.sidebar-actions {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--border-glass);
  flex-shrink: 0;
}

.sidebar-actions .btn {
  flex: 1;
}

/* Right panel - editor */
.editor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-glass);
  flex-shrink: 0;
}

.editor-toolbar .file-path {
  flex: 1;
  font-family: monospace;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.editor-container .CodeMirror {
  height: 100% !important;
  background: transparent !important;
}

.editor-container .CodeMirror-gutters {
  background: rgba(0, 0, 0, 0.2) !important;
  border-right: 1px solid var(--border-glass) !important;
}

.editor-container .CodeMirror-linenumber {
  color: var(--text-muted) !important;
}

.editor-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 14px;
}

.editor-statusbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 16px;
  border-top: 1px solid var(--border-glass);
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: 400px;
  padding: 28px;
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-overlay.show .modal {
  transform: scale(1);
}

.modal h3 {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 20px;
}

.modal input {
  width: 100%;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-btn);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
  font-family: inherit;
}

.modal input:focus {
  border-color: rgba(255, 255, 255, 0.3);
}

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

/* Toast */
.toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-btn);
  font-size: 13px;
  min-width: 200px;
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.error {
  border-left: 3px solid var(--danger);
}

.toast.info {
  border-left: 3px solid rgba(255, 255, 255, 0.4);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
  to { transform: translateX(100%); opacity: 0; }
}

.toast.removing {
  animation: slideOut 0.3s ease forwards;
}

/* Upload progress */
.upload-progress {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 16px 24px;
  z-index: 2000;
  display: none;
}

.upload-progress.show {
  display: block;
}

.upload-progress .label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.upload-progress .bar {
  width: 200px;
  height: 4px;
  background: var(--bg-glass);
  border-radius: 2px;
  overflow: hidden;
}

.upload-progress .fill {
  height: 100%;
  background: #fff;
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 220px;
  }
  .topbar .link-bar {
    display: none;
  }
}
