: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;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

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

/* 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.3);
}

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

.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);
  display: inline-block;
  margin-top: 4px;
}

.card-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-notepad-trigger {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(99, 102, 241, 0.25));
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #93c5fd;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}

.btn-notepad-trigger:hover {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.35), rgba(99, 102, 241, 0.4));
  border-color: #60a5fa;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--primary-glow);
}

/* Dropzone */
.dropzone {
  border: 2px dashed #2d3748;
  border-radius: var(--radius-md);
  padding: 40px 20px;
  text-align: center;
  background: rgba(15, 23, 42, 0.4);
  cursor: pointer;
  transition: var(--transition);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.05);
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

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

.dropzone h3 {
  font-size: 1.05rem;
  font-weight: 600;
}

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

.btn-browse {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 0 2px;
}

.btn-browse:hover {
  color: var(--primary-hover);
}

.formats-hint {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 6px;
}

/* Metadata Inputs */
.meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  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;
  font-weight: 500;
  color: var(--text-muted);
}

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

.input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Queue Container */
.queue-container {
  margin-top: 20px;
  background: #0f172a;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 16px;
}

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

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

.btn-clear:hover {
  text-decoration: underline;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.queue-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1e293b;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  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: 320px;
  font-weight: 500;
}

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

.btn-remove-queue {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
}

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

/* Upload Progress */
.progress-wrap {
  margin: 16px 0 12px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

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

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

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 6px;
}

/* Buttons */
.btn-upload {
  width: 100%;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  margin-top: 14px;
}

.btn-upload:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 16px var(--primary-glow);
}

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

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

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

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

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

.search-box svg {
  color: var(--text-muted);
}

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

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

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

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

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

.file-table th {
  padding: 12px 14px;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.file-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.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.72rem;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
  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-icon.txt { background: rgba(59, 130, 246, 0.18); color: #60a5fa; }
.file-icon.code { background: rgba(236, 72, 153, 0.18); color: #f472b6; }

.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-main);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition);
}

.btn-action:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #1e293b;
}

.btn-action.btn-edit {
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.3);
}

.btn-action.btn-edit:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: #60a5fa;
  color: #93c5fd;
}

.btn-action.btn-del {
  color: var(--text-muted);
}

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

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

/* Modals General */
.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-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.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;
  padding: 4px 8px;
}

.modal-close:hover {
  color: #fff;
}

.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-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.preview-actions-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.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;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-download-modal:hover {
  background: var(--primary-hover);
}

/* Enhanced Text Preview Container */
.text-preview-container {
  width: 100%;
  height: 60vh;
  display: flex;
  flex-direction: column;
  background: #090d16;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.text-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #0f172a;
  border-bottom: 1px solid var(--card-border);
  font-size: 0.78rem;
  color: var(--text-muted);
  gap: 8px;
  flex-wrap: wrap;
}

.text-preview-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-tool-sm {
  background: #1e293b;
  border: 1px solid #334155;
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.74rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-tool-sm:hover {
  background: #334155;
  border-color: #475569;
}

.btn-tool-sm.btn-tool-edit {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
  color: #93c5fd;
  font-weight: 500;
}

.btn-tool-sm.btn-tool-edit:hover {
  background: rgba(59, 130, 246, 0.3);
  border-color: #60a5fa;
  color: #ffffff;
}

.text-preview-warning {
  padding: 8px 12px;
  background: rgba(245, 158, 11, 0.1);
  border-bottom: 1px solid rgba(245, 158, 11, 0.25);
  color: #fbbf24;
  font-size: 0.76rem;
}

.text-preview-content {
  flex: 1;
  overflow: auto;
  padding: 16px;
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  color: #e2e8f0;
  white-space: pre;
  tab-size: 2;
}

.text-preview-content.wrap {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Notepad Editor Modal */
.notepad-dialog {
  max-width: 1000px;
  width: 94%;
  height: 88vh;
  max-height: 88vh;
}

.notepad-header-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.notepad-mode-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  display: inline-block;
  margin-top: 2px;
}

.notepad-mode-badge.new {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.notepad-mode-badge.edit {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.notepad-meta {
  display: flex;
  gap: 12px;
  padding: 12px 20px;
  background: #0d1321;
  border-bottom: 1px solid var(--card-border);
  flex-wrap: wrap;
}

.notepad-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.notepad-field label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.notepad-field input {
  background: #111827;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 8px 12px;
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
}

.notepad-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.notepad-field.field-name {
  flex: 2;
  min-width: 180px;
}

.notepad-field.field-sender {
  flex: 1;
  min-width: 130px;
}

.notepad-field.field-note {
  flex: 2;
  min-width: 180px;
}

.notepad-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px;
  background: #0f172a;
  border-bottom: 1px solid var(--card-border);
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-tool {
  background: #1e293b;
  border: 1px solid #334155;
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-tool:hover {
  background: #334155;
  border-color: #475569;
}

.notepad-stats {
  font-size: 0.78rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
}

.notepad-editor-wrap {
  flex: 1;
  position: relative;
  display: flex;
  overflow: hidden;
  background: #090d16;
}

.notepad-textarea {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  background: #090d16;
  color: #f1f5f9;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  padding: 16px 20px;
  resize: none;
  tab-size: 2;
}

.notepad-textarea.wrap {
  white-space: pre-wrap;
  word-break: break-word;
}

.notepad-textarea:not(.wrap) {
  white-space: pre;
  overflow-x: auto;
}

.notepad-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  gap: 12px;
  flex-wrap: wrap;
}

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

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

.footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-secondary {
  background: #1e293b;
  border: 1px solid #334155;
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: #334155;
}

.btn-save-as {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fbbf24;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-save-as:hover {
  background: rgba(245, 158, 11, 0.3);
  border-color: #fbbf24;
}

.btn-save-notepad {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border: none;
  color: white;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px var(--primary-glow);
  transition: var(--transition);
}

.btn-save-notepad:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

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

/* 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;
}
