:root {
  --bg-color: #0b0f19;
  --card-bg: #111827;
  --card-border: #1f293d;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.25);
  --success: #10b981;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --warning: #f59e0b;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --transition: all 0.2s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: rgba(17, 24, 39, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: white;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #ffffff, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.server-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #34d399;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}

.badge-dot {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 10px #10b981;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Main Container */
.main-container {
  max-width: 1200px;
  margin: 32px auto;
  padding: 0 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 28px;
  width: 100%;
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
}

.limit-badge {
  font-size: 0.78rem;
  color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

/* Dropzone */
.dropzone {
  border: 2px dashed #2b3952;
  border-radius: var(--radius-md);
  padding: 40px 20px;
  text-align: center;
  background: rgba(17, 24, 39, 0.5);
  cursor: pointer;
  transition: var(--transition);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.05);
  box-shadow: 0 0 20px var(--primary-glow);
}

.cloud-icon {
  color: var(--primary);
  margin-bottom: 12px;
}

.dropzone h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.dropzone p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.btn-browse {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.9rem;
}

.formats-hint {
  font-size: 0.78rem;
  color: #64748b;
  display: block;
}

/* Metadata inputs */
.meta-row {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 16px;
  margin-top: 18px;
}

@media (max-width: 640px) {
  .meta-row { grid-template-columns: 1fr; }
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.input-group input {
  background: #0f172a;
  border: 1px solid var(--card-border);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  outline: none;
  transition: var(--transition);
}

.input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Queue Container */
.queue-container {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--card-border);
}

.queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.btn-clear {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.8rem;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 18px;
}

.queue-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0f172a;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid #1e293b;
  font-size: 0.85rem;
}

.queue-item-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.queue-item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
  font-weight: 500;
}

.queue-item-size {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.btn-remove-queue {
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.btn-remove-queue:hover {
  color: var(--danger);
}

/* Progress bar */
.progress-wrap {
  margin-bottom: 18px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 6px;
  font-weight: 500;
}

.progress-track {
  background: #1e293b;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.progress-bar {
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  height: 100%;
  border-radius: 999px;
  transition: width 0.15s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Upload Button */
.btn-upload {
  width: 100%;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 14px var(--primary-glow);
  transition: var(--transition);
}

.btn-upload:hover:not(:disabled) {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  transform: translateY(-1px);
}

.btn-upload:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Files Card Header */
.file-list-header {
  flex-wrap: wrap;
  gap: 16px;
}

.subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box {
  display: flex;
  align-items: center;
  background: #0f172a;
  border: 1px solid var(--card-border);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.search-box input {
  background: none;
  border: none;
  color: var(--text-main);
  padding-left: 8px;
  font-size: 0.85rem;
  outline: none;
  width: 200px;
}

.btn-refresh {
  background: #0f172a;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-refresh:hover {
  color: var(--text-main);
  border-color: var(--primary);
}

/* File Table */
.table-responsive {
  overflow-x: auto;
}

.file-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  text-align: left;
}

.file-table th {
  padding: 12px 14px;
  background: #0f172a;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 1px solid var(--card-border);
  white-space: nowrap;
}

.file-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #1a2333;
  vertical-align: middle;
}

.file-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.03);
}

.file-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.file-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
  background: #1e293b;
  color: #cbd5e1;
}

.file-icon.cad { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.file-icon.pdf { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.file-icon.img { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.file-icon.zip { background: rgba(168, 85, 247, 0.15); color: #c084fc; }

.file-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.btn-action {
  background: #0f172a;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  transition: var(--transition);
}

.btn-action:hover {
  color: var(--text-main);
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
}

.btn-action.btn-del:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px !important;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  z-index: 1;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--card-border);
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 250px;
}

.modal-body img {
  max-width: 100%;
  max-height: 60vh;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.modal-body iframe {
  width: 100%;
  height: 60vh;
  border: none;
  background: white;
  border-radius: var(--radius-sm);
}

.modal-body pre {
  width: 100%;
  max-height: 60vh;
  overflow: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  background: #0f172a;
  padding: 16px;
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: flex-end;
}

.btn-download-modal {
  background: var(--primary);
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}

.toast {
  background: #1e293b;
  border: 1px solid #334155;
  color: var(--text-main);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
  animation: slideIn 0.25s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success { border-color: rgba(16, 185, 129, 0.4); }
.toast.error { border-color: rgba(239, 68, 68, 0.4); }

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

/* Footer */
.app-footer {
  text-align: center;
  padding: 24px;
  border-top: 1px solid var(--card-border);
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: auto;
}

.app-footer code {
  background: #1e293b;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  color: #93c5fd;
}
