/* ── CSS Variables & Reset ── */
:root {
  --bg-primary: #0f0f13;
  --bg-secondary: #1a1a24;
  --bg-card: #22222e;
  --bg-hover: #2a2a38;
  --bg-input: #181822;
  --border: #2e2e3e;
  --border-focus: #6c5ce7;
  --text-primary: #e8e8f0;
  --text-secondary: #9090a8;
  --text-muted: #606078;
  --accent: #6c5ce7;
  --accent-hover: #7d6ff0;
  --accent-glow: rgba(108, 92, 231, 0.15);
  --success: #00c897;
  --warning: #f0a040;
  --danger: #e74c5c;
  --gradient-1: linear-gradient(135deg, #6c5ce7 0%, #a855f7 100%);
  --gradient-2: linear-gradient(135deg, #00c897 0%, #00b4d8 100%);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-primary: #f5f5fa;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f0f0f8;
  --bg-input: #f0f0f8;
  --border: #e0e0e8;
  --border-focus: #6c5ce7;
  --text-primary: #1a1a2e;
  --text-secondary: #606078;
  --text-muted: #9090a8;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.app-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 100px;
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 28px;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
}

.app-logo-icon {
  width: 40px;
  height: 40px;
  background: var(--gradient-1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

.app-logo-text {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.app-logo-text span {
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition);
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

/* ── Upload Area ── */
.upload-section {
  margin-bottom: 32px;
}

.tab-nav {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab-btn.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ── Text Input ── */
.text-input-area {
  position: relative;
}

.text-input-area textarea {
  width: 100%;
  min-height: 160px;
  padding: 16px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  line-height: 1.6;
  resize: vertical;
  transition: var(--transition);
  outline: none;
}

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

.text-input-area textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.text-char-count {
  position: absolute;
  bottom: 12px;
  right: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

/* ── Drop Zone ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-card);
  position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.drop-zone.drag-over {
  transform: scale(1.01);
}

.drop-zone-icon {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
}

.drop-zone-text {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 4px;
}

.drop-zone-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ── Upload Progress ── */
.upload-progress {
  margin-top: 16px;
  display: none;
}

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

.progress-bar-track {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient-1);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1;
}

.btn-primary {
  background: var(--gradient-1);
  color: white;
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.4);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-size: 16px;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

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

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 3px;
  border: 1px solid var(--border);
}

.filter-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition);
}

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

.filter-btn.active {
  background: var(--accent);
  color: white;
}

.items-count {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Items List ── */
.items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: var(--transition);
  animation: fadeInUp 0.3s ease;
}

.item-card:hover {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-sm);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.item-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.item-type-badge {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.item-type-badge.text {
  background: rgba(0, 200, 151, 0.12);
  color: #00c897;
}

.item-type-badge.file {
  background: rgba(240, 160, 64, 0.12);
  color: #f0a040;
}

.item-type-badge.image {
  background: rgba(108, 92, 231, 0.12);
  color: #6c5ce7;
}

.item-info {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.item-meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
}

.item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Text Preview in Card ── */
.item-text-preview {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Fira Code', monospace;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 100px;
  overflow: hidden;
  position: relative;
}

.item-text-preview::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: linear-gradient(transparent, var(--bg-input));
}

/* ── Image Preview in Card ── */
.item-image-preview {
  margin-top: 10px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-height: 200px;
  display: flex;
  justify-content: center;
  background: var(--bg-input);
}

.item-image-preview img {
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
}

/* ── Expiration Badge ── */
.expire-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.expire-badge.safe {
  background: rgba(0, 200, 151, 0.1);
  color: #00c897;
}

.expire-badge.warning {
  background: rgba(240, 160, 64, 0.1);
  color: #f0a040;
}

.expire-badge.danger {
  background: rgba(231, 76, 92, 0.1);
  color: #e74c5c;
}

/* ── Share Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  transform: scale(0.95) translateY(10px);
  transition: var(--transition);
  box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

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

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--bg-hover);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--danger);
  color: white;
}

.share-link-box {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.share-link-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
}

.share-link-input:focus {
  border-color: var(--border-focus);
}

.qr-container {
  display: flex;
  justify-content: center;
  padding: 20px;
  background: white;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.qr-container canvas {
  border-radius: 4px;
}

.share-info {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

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

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: white;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 360px;
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

.toast.info {
  background: var(--accent);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
  }
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 56px;
  margin-bottom: 16px;
  display: block;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 1.05rem;
  margin-bottom: 4px;
  color: var(--text-secondary);
}

.empty-state-hint {
  font-size: 0.85rem;
}

/* ── Share Page View ── */
.share-view {
  max-width: 640px;
  margin: 40px auto;
  padding: 0 16px;
}

.share-view-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-md);
}

.share-view-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.share-view-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.share-view-title {
  font-size: 1.2rem;
  font-weight: 600;
}

.share-view-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.share-view-content {
  margin-bottom: 24px;
}

.share-text-content {
  padding: 20px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 500px;
  overflow-y: auto;
}

.share-image-content {
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  justify-content: center;
  background: var(--bg-input);
}

.share-image-content img {
  max-width: 100%;
  max-height: 600px;
  object-fit: contain;
}

.share-view-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
}

.pagination button {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
}

.pagination button:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination .page-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Confirm Dialog ── */
.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

.confirm-text {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ── Loading ── */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .app-container {
    padding: 12px 12px 80px;
  }

  .app-header {
    padding: 12px 0 20px;
  }

  .tab-btn {
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  .drop-zone {
    padding: 32px 16px;
  }

  .drop-zone-icon {
    font-size: 36px;
  }

  .item-card {
    padding: 12px;
  }

  .item-actions {
    flex-wrap: wrap;
  }

  .modal {
    padding: 20px;
    margin: 12px;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .share-view-card {
    padding: 20px;
  }

  .share-view-actions {
    flex-direction: column;
  }

  .share-view-actions .btn {
    justify-content: center;
  }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Tooltip ── */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  pointer-events: none;
  z-index: 100;
}

[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
}
