/* =============================================
   ClipShare - CSS Styles
   Dark/Light theme with system preference detection
   ============================================= */

/* =============================================
   Kalameh Font for Persian/RTL
   ============================================= */
@font-face {
  font-family: 'Kalameh';
  src: url('/fonts/Kalameh-Light.ttf') format('truetype');
  font-weight: 300;
  font-style: normal;
}

@font-face {
  font-family: 'Kalameh';
  src: url('/fonts/Kalameh-ExtraBold.ttf') format('truetype');
  font-weight: 800;
  font-style: normal;
}

@font-face {
  font-family: 'Kalameh';
  src: url('/fonts/Kalameh-Black.ttf') format('truetype');
  font-weight: 900;
  font-style: normal;
}

/* CSS Variables for theming */
:root {
  /* Light theme (default) */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: #dbeafe;
  --success: #10b981;
  --success-bg: #d1fae5;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --error: #ef4444;
  --error-bg: #fee2e2;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 8px;
  --radius-lg: 12px;
}

/* Dark theme */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #334155;
  --border-focus: #60a5fa;
  --accent: #60a5fa;
  --accent-hover: #3b82f6;
  --accent-light: #1e3a5f;
  --success: #34d399;
  --success-bg: #064e3b;
  --warning: #fbbf24;
  --warning-bg: #78350f;
  --error: #f87171;
  --error-bg: #7f1d1d;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

/* System preference detection */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-focus: #60a5fa;
    --accent: #60a5fa;
    --accent-hover: #3b82f6;
    --accent-light: #1e3a5f;
    --success: #34d399;
    --success-bg: #064e3b;
    --warning: #fbbf24;
    --warning-bg: #78350f;
    --error: #f87171;
    --error-bg: #7f1d1d;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  }
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Kalameh', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--accent-hover);
}

/* Container */
.container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.header {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.logo:hover {
  color: var(--accent);
}

.logo-icon {
  width: 28px;
  height: 28px;
}

/* Theme Toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.theme-toggle:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  display: block;
}

.icon-sun { display: none; }
.icon-moon { display: block; }

[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* Main Content */
.main {
  flex: 1;
  padding: 2rem 0;
}

/* Hero */
.hero {
  text-align: center;
  margin-bottom: 2rem;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.hero p {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* Card */
.card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

.tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.tab.active {
  background-color: var(--accent);
  border-color: var(--accent);
  color: white;
}

.tab svg {
  width: 18px;
  height: 18px;
}

/* Form Elements */
.form-section {
  margin-bottom: 1.5rem;
}

.form-section.hidden {
  display: none;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-textarea {
  resize: vertical;
  min-height: 200px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.form-group {
  margin-bottom: 1rem;
}

/* Drop Zone */
.drop-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  background-color: var(--bg-tertiary);
  cursor: pointer;
  transition: all 0.2s;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background-color: var(--accent-light);
}

.drop-zone.drag-over {
  transform: scale(1.01);
}

.drop-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.drop-text {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.drop-hint {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* Paste Preview */
.paste-preview {
  position: relative;
  margin-top: 1rem;
  max-width: 100%;
}

.paste-preview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius);
  border: 2px solid var(--border-color);
}

.btn-remove-preview {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  background-color: var(--error);
  color: white;
  font-size: 1rem;
  line-height: 1;
}

.btn-remove-preview:hover {
  background-color: var(--error);
  opacity: 0.9;
}

/* Paste Button */
.btn-paste {
  margin-top: 1rem;
  width: 100%;
}

/* Upload Progress */
.upload-progress {
  margin-top: 0.75rem;
  width: 100%;
}

.progress-bar-track {
  width: 100%;
  height: 6px;
  background-color: var(--border-color);
  border-radius: 100px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, #3b82f6, #60a5fa, #3b82f6);
  background-size: 200% 100%;
  animation: progressShimmer 1.5s ease-in-out infinite;
  transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

@keyframes progressShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.progress-bar-fill.complete {
  background: linear-gradient(90deg, #22c55e, #4ade80, #22c55e);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
  animation: none;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.4rem;
}

.progress-label {
  font-size: 0.785rem;
  font-weight: 500;
  color: var(--text-muted);
}

.progress-detail {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.progress-size {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.progress-percent {
  font-size: 0.785rem;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.progress-bar-fill.complete + .progress-info .progress-percent,
.upload-progress:has(.complete) .progress-percent {
  color: #22c55e;
}

[dir="rtl"] .progress-info {
  flex-direction: row-reverse;
}

[dir="rtl"] .progress-detail {
  flex-direction: row-reverse;
}

/* Disclaimer */
.disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding: 1rem;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-muted);
  border-left: 3px solid var(--warning);
}

.disclaimer svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--warning);
}

[dir="rtl"] .disclaimer {
  border-left: none;
  border-right: 3px solid var(--warning);
  direction: rtl;
  text-align: right;
}

[dir="rtl"] .btn-remove-preview {
  right: auto;
  left: -8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background-color: var(--accent);
  color: white;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  color: white;
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--border-color);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.btn-danger {
  background-color: #dc2626;
  color: #fff;
}

.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-warning {
  background-color: #d97706;
  color: #fff;
}

.btn-warning:hover {
  background-color: #b45309;
}

.btn-copy {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
}

.btn-copy:hover {
  background-color: var(--border-color);
}

.btn-copy.copied,
.btn-copy-content.copied {
  background-color: var(--success);
  border-color: var(--success);
  color: white;
}

.btn-copy .icon-check,
.btn-copy-content .icon-check { display: none; }
.btn-copy.copied .icon-check,
.btn-copy-content.copied .icon-check { display: block; }
.btn-copy.copied .icon-copy,
.btn-copy-content.copied .icon-copy { display: none; }

/* Admin */
.admin-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: min(96vw, 1800px);
}

.admin-header-card,
.admin-upload-card,
.admin-stats-card,
.admin-table-card,
.admin-login-card {
  max-width: 100%;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.admin-user {
  margin-top: 0.3rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.admin-actions form {
  margin: 0;
}

.admin-toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  height: 40px;
  padding-top: 0;
  padding-bottom: 0;
}

.admin-actions .btn.admin-toolbar-btn,
.admin-actions .lang-toggle.admin-toolbar-btn {
  min-width: 112px;
}

.admin-actions .theme-toggle.admin-toolbar-btn {
  min-width: 40px;
  width: 40px;
  padding-inline: 0;
}

.admin-actions .btn-secondary.admin-toolbar-btn:hover {
  background-color: var(--border-color);
  color: var(--accent-hover);
  border-color: var(--accent);
}

.admin-stats-grid {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.admin-stat {
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.admin-stat span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.admin-stat strong {
  font-size: 1rem;
}

.admin-table-wrap {
  margin-top: 0.75rem;
  overflow-x: auto;
  overflow-y: auto;
  max-height: min(72vh, 780px);
  scrollbar-width: auto;
  scrollbar-color: var(--accent-hover) color-mix(in srgb, var(--bg-tertiary) 88%, #0f172a 12%);
}

.admin-table-wrap::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

.admin-table-wrap::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--bg-tertiary) 88%, #0f172a 12%);
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--border-color) 75%, transparent);
}

.admin-table-wrap::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border-radius: 999px;
  border: 2px solid color-mix(in srgb, var(--bg-tertiary) 88%, #0f172a 12%);
  min-height: 48px;
}

.admin-table-wrap::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
}

[data-theme="dark"] .admin-table-wrap {
  scrollbar-color: #93c5fd #1f2937;
}

[data-theme="dark"] .admin-table-wrap::-webkit-scrollbar-track {
  background: #1f2937;
  border-color: #334155;
}

[data-theme="dark"] .admin-table-wrap::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #93c5fd, #3b82f6);
  border-color: #1f2937;
}

[data-theme="dark"] .admin-table-wrap::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #bfdbfe, #60a5fa);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .admin-table-wrap {
    scrollbar-color: #93c5fd #1f2937;
  }

  :root:not([data-theme="light"]) .admin-table-wrap::-webkit-scrollbar-track {
    background: #1f2937;
    border-color: #334155;
  }

  :root:not([data-theme="light"]) .admin-table-wrap::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #93c5fd, #3b82f6);
    border-color: #1f2937;
  }

  :root:not([data-theme="light"]) .admin-table-wrap::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #bfdbfe, #60a5fa);
  }
}

.admin-table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.admin-table-toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.admin-search-form {
  position: relative;
  display: flex;
  align-items: center;
}

.admin-search-input {
  padding: 0.45rem 2rem 0.45rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: 'Kalameh', 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 0.85rem;
  min-width: 240px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.admin-search-input::placeholder {
  font-family: 'Kalameh', 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--text-muted);
  opacity: 1;
}

[dir="rtl"] .admin-search-input {
  padding: 0.45rem 0.75rem 0.45rem 2rem;
}

.admin-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.admin-search-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 1rem;
  line-height: 1;
}

[dir="rtl"] .admin-search-clear {
  right: auto;
  left: 0.5rem;
}

.admin-search-clear:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.admin-title-input {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 0.88rem;
  transition: border-color 0.15s, background 0.15s;
}

.admin-title-input::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.admin-title-input:hover {
  border-color: var(--border-color);
}

.admin-title-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-tertiary);
}

.admin-title-input.saving {
  border-color: var(--accent);
  opacity: 0.7;
}

.admin-title-input.saved {
  border-color: var(--success, #16a34a);
  background: color-mix(in srgb, var(--success, #16a34a) 10%, transparent);
}

.admin-title-input.save-failed {
  border-color: #dc2626;
  background: color-mix(in srgb, #dc2626 10%, transparent);
}

.admin-filter-toggle {
  display: flex;
  gap: 0.4rem;
}

.admin-filter-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.82rem;
}

.admin-filter-pill:hover {
  background: var(--bg-tertiary);
}

.admin-filter-pill.active {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1080px;
  table-layout: fixed;
}

.admin-table .col-id { width: 9%; }
.admin-table .col-type { width: 7%; }
.admin-table .col-title { width: 16%; }
.admin-table .col-created { width: 13%; }
.admin-table .col-expires { width: 13%; }
.admin-table .col-size { width: 8%; }
.admin-table .col-views { width: 7%; }
.admin-table .col-actions { width: 27%; }

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--border-color);
  padding: 0.6rem 0.35rem;
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 0.7rem 0.6rem;
  text-align: left;
}

.admin-table thead th:first-child {
  border-top-left-radius: var(--radius);
  border-bottom-left-radius: var(--radius);
}

.admin-table thead th:last-child {
  border-top-right-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

[dir="rtl"] .admin-table thead th:first-child {
  border-radius: 0 var(--radius) var(--radius) 0;
}

[dir="rtl"] .admin-table thead th:last-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

.admin-table td {
  font-size: 0.88rem;
  word-break: break-word;
}

.admin-row-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(72px, 1fr));
  gap: 0.3rem;
  align-items: stretch;
}

.admin-row-actions form {
  margin: 0;
}

.admin-exp-form {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  grid-column: 1 / -1;
}

.form-select-sm {
  padding: 0.45rem 0.5rem;
  font-size: 0.85rem;
}

.admin-checkbox-wrap {
  display: flex;
  align-items: end;
}

.admin-row-actions .btn,
.admin-row-actions a.btn {
  width: 100%;
  justify-content: center;
}

.admin-copy-link.copied-persistent,
.admin-open-link.copied-persistent {
  border-color: #22c55e;
  color: #22c55e;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.35), 0 0 12px rgba(34, 197, 94, 0.35);
}

.admin-one-time-row {
  background: color-mix(in srgb, #f59e0b 8%, transparent);
}

.admin-empty-row {
  text-align: center !important;
  color: var(--text-secondary);
  padding: 1.2rem 0.5rem !important;
}

.admin-pagination {
  margin-top: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.admin-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.84rem;
  transition: all 0.2s;
}

.admin-page-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.admin-page-btn.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.admin-page-btn.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.admin-page-meta {
  margin-inline-start: auto;
  color: var(--text-secondary);
  font-size: 0.84rem;
}

[dir="rtl"] .admin-page-meta {
  margin-inline-start: 0;
  margin-inline-end: auto;
}

[dir="rtl"] .admin-table th,
[dir="rtl"] .admin-table td {
  text-align: right;
}

@media (max-width: 768px) {
  .admin-topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .admin-actions {
    width: 100%;
    justify-content: flex-start;
    gap: 0.4rem;
    row-gap: 0.5rem;
  }

  .admin-actions .btn.admin-toolbar-btn,
  .admin-actions .lang-toggle.admin-toolbar-btn {
    min-width: 0;
    flex: 1 1 auto;
    padding-inline: 0.7rem;
    font-size: 0.85rem;
  }

  .admin-actions .theme-toggle.admin-toolbar-btn {
    flex: 0 0 auto;
  }

  .admin-table-header {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-table-toolbar {
    width: 100%;
    justify-content: space-between;
  }

  .admin-search-form {
    flex: 1 1 100%;
  }

  .admin-search-input {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 480px) {
  .admin-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    gap: 0.4rem;
  }

  .admin-actions form {
    width: 100%;
  }

  .admin-actions form .btn.admin-toolbar-btn {
    width: 100%;
  }
}

/* Success Page */
.success-card {
  text-align: center;
  max-width: 500px;
  margin: 0 auto;
}

.success-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  color: var(--success);
}

.success-icon svg {
  width: 100%;
  height: 100%;
}

.success-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.success-subtitle {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.share-box {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.view-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn-qr {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
}

.btn-qr svg {
  width: 18px;
  height: 18px;
}

.btn-sm.btn-qr {
  padding: 0.5rem 0.75rem;
  gap: 0.35rem;
}

.btn-sm.btn-qr svg {
  width: 14px;
  height: 14px;
}

.preview-toolbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.share-input {
  flex: 1;
  padding: 0.75rem 1rem;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: 'Consolas', 'Monaco', monospace;
}

.info-box {
  margin-bottom: 1.5rem;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.info-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.info-item.warning {
  background-color: var(--warning-bg);
  color: var(--warning);
}

/* Password Page */
.password-card {
  text-align: center;
  max-width: 400px;
  margin: 0 auto;
}

.lock-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  color: var(--warning);
}

.lock-icon svg {
  width: 100%;
  height: 100%;
}

.password-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.password-card p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.password-card form {
  text-align: left;
}

.back-link {
  display: inline-block;
  margin-top: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.back-link:hover {
  color: var(--accent);
}

/* View Page */
.view-card {
  max-width: 100%;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.view-title h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  word-break: break-word;
}

.view-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.meta-item svg {
  width: 14px;
  height: 14px;
}

.meta-item.warning {
  color: var(--warning);
}

.file-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.file-info svg {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
}

.file-name {
  font-weight: 500;
  word-break: break-all;
}

.file-size {
  color: var(--text-muted);
}

/* Preview Container */
.preview-container {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}

.preview-text {
  background-color: var(--bg-tertiary);
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.preview-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.code-block {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  background-color: var(--bg-tertiary) !important;
  max-height: 500px;
  overflow-y: auto;
}

.code-block code {
  background: none !important;
}

.preview-image {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  background-color: var(--bg-tertiary);
}

.preview-image img {
  max-width: 100%;
  max-height: 600px;
  object-fit: contain;
  border-radius: var(--radius);
}

.preview-pdf {
  height: 600px;
}

.preview-pdf iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.preview-audio,
.preview-video {
  display: flex;
  justify-content: center;
  padding: 2rem;
  background-color: var(--bg-tertiary);
}

.preview-audio audio {
  width: 100%;
  max-width: 500px;
}

.preview-video video {
  max-width: 100%;
  max-height: 500px;
  border-radius: var(--radius);
}

.preview-download {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  background-color: var(--bg-tertiary);
  text-align: center;
}

.preview-download svg {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.preview-download p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.preview-message {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: var(--radius);
  margin-top: 1rem;
  font-size: 0.9rem;
}

.alert svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

[dir="rtl"] .alert {
  flex-direction: rtl;
  text-align: right;
}

[dir="rtl"] .alert-error,
[dir="rtl"] .alert-warning,
[dir="rtl"] .alert-success {
  flex-direction: rtl;
}

.alert-error {
  background-color: var(--error-bg);
  color: var(--error);
}

.alert-warning {
  background-color: var(--warning-bg);
  color: var(--warning);
}

.alert-success {
  background-color: var(--success-bg);
  color: var(--success);
}

/* Error Page */
.error-card {
  text-align: center;
  max-width: 400px;
  margin: 0 auto;
}

.error-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  color: var(--error);
}

.error-icon svg {
  width: 100%;
  height: 100%;
}

.error-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.error-card p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.retry-info {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Footer */
.footer {
  padding: 1.5rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  border-top: 1px solid var(--border-color);
}

/* Utility */
.hidden {
  display: none !important;
}

body.qr-modal-open {
  overflow: hidden;
}

.qr-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(59, 130, 246, 0.08);
  backdrop-filter: blur(5px);
}

.qr-dialog {
  position: relative;
  z-index: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
  min-width: 280px;
  box-shadow: var(--shadow-lg);
}

.qr-title {
  margin: 0 0 0.8rem 0;
  font-size: 1rem;
  text-align: center;
  padding: 0 2rem;
}

.qr-image {
  display: block;
  width: 320px;
  max-width: 80vw;
  height: auto;
  background: #fff;
  padding: 0.35rem;
  border-radius: var(--radius);
}

.qr-close {
  position: absolute;
  top: 0.4rem;
  right: 0.5rem;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
}

.admin-toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 1100;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--success, #16a34a);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.9rem 2.25rem 0.9rem 1rem;
  min-width: 280px;
  max-width: min(420px, calc(100vw - 2rem));
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  color: var(--text-primary);
  animation: admin-toast-in 0.18s ease-out;
}

.admin-toast-info {
  border-left-color: var(--accent, #3b82f6);
}

.admin-toast-error {
  border-left-color: #dc2626;
}

[dir="rtl"] .admin-toast {
  right: auto;
  left: 1.25rem;
  border-left: 1px solid var(--border-color);
  border-right: 4px solid var(--success, #16a34a);
  padding: 0.9rem 1rem 0.9rem 2.25rem;
}

[dir="rtl"] .admin-toast-info {
  border-right-color: var(--accent, #3b82f6);
}

[dir="rtl"] .admin-toast-error {
  border-right-color: #dc2626;
}

@keyframes admin-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.admin-toast strong {
  font-size: 0.95rem;
}

.admin-toast-link-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.admin-toast-link {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.6rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.85rem;
}

.admin-toast-close {
  position: absolute;
  top: 0.35rem;
  right: 0.5rem;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

[dir="rtl"] .admin-toast-close {
  right: auto;
  left: 0.5rem;
}

.admin-toast-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.admin-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: admin-toast-in 0.15s ease-out;
}

.admin-confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}

.admin-confirm-dialog {
  position: relative;
  z-index: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.25rem 1.25rem 1rem;
  max-width: min(440px, calc(100vw - 2rem));
  min-width: min(320px, calc(100vw - 2rem));
  font-family: 'Kalameh', 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

.admin-confirm-text {
  margin: 0 0 1rem 0;
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 0.95rem;
}

.admin-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

[dir="rtl"] .admin-confirm-actions {
  justify-content: flex-start;
}

.admin-confirm-actions .btn {
  min-width: 90px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Selection */
::selection {
  background-color: var(--accent);
  color: white;
}

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Language Toggle */
.lang-toggle {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: 'Kalameh', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

.lang-toggle:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

/* =============================================
   RTL Support for Persian Language
   ============================================= */

[dir="rtl"] {
  font-family: 'Kalameh', 'Vazirmatn', 'Segoe UI', Tahoma, Arial, sans-serif;
}

[dir="rtl"] body {
  font-family: 'Kalameh', 'Vazirmatn', 'Segoe UI', Tahoma, Arial, sans-serif;
}

[dir="rtl"] .form-input,
[dir="rtl"] .form-textarea,
[dir="rtl"] .form-select,
[dir="rtl"] .btn,
[dir="rtl"] .tab,
[dir="rtl"] .lang-toggle {
  font-family: 'Kalameh', 'Vazirmatn', 'Segoe UI', Tahoma, Arial, sans-serif;
}

/* Flex containers need to reverse direction */
[dir="rtl"] .header-content,
[dir="rtl"] .header-actions,
[dir="rtl"] .logo,
[dir="rtl"] .tab,
[dir="rtl"] .btn,
[dir="rtl"] .share-box,
[dir="rtl"] .info-item,
[dir="rtl"] .meta-item,
[dir="rtl"] .file-info,
[dir="rtl"] .view-header,
[dir="rtl"] .view-meta,
[dir="rtl"] .view-title,
[dir="rtl"] .alert,
[dir="rtl"] .preview-toolbar,
[dir="rtl"] .drop-zone,
[dir="rtl"] .success-icon,
[dir="rtl"] .lock-icon,
[dir="rtl"] .error-icon {
  flex-direction: rtl;
}

/* Tabs - align to right in RTL */
[dir="rtl"] .tabs {
  flex-direction: rtl;
  justify-content: flex-end;
}

/* Text alignment */
[dir="rtl"] .form-input,
[dir="rtl"] .form-textarea,
[dir="rtl"] .form-select {
  text-align: right;
}

[dir="rtl"] .form-label {
  text-align: right;
  display: block;
}

[dir="rtl"] .hero {
  text-align: center;
}

[dir="rtl"] .alert {
  text-align: right;
}

[dir="rtl"] .info-item {
  text-align: right;
  justify-content: flex-start;
}

[dir="rtl"] .meta-item {
  text-align: right;
  justify-content: flex-start;
}

[dir="rtl"] .view-meta {
  justify-content: flex-start;
}

[dir="rtl"] .alert-warning {
  text-align: right;
}

[dir="rtl"] .info-item span {
  text-align: right;
}

[dir="rtl"] .info-box {
  text-align: right;
}

[dir="rtl"] .success-card,
[dir="rtl"] .password-card,
[dir="rtl"] .error-card {
  text-align: center;
}

[dir="rtl"] .preview-download {
  text-align: center;
}

/* Form row direction */
[dir="rtl"] .form-row {
  direction: rtl;
}

/* Drop zone */
[dir="rtl"] .drop-zone {
  direction: rtl;
  flex-direction: column;
}

/* Keep code blocks LTR */
[dir="rtl"] .code-block {
  direction: ltr;
  text-align: left;
}

[dir="rtl"] .share-input {
  direction: ltr;
  text-align: left;
}

/* Back links with arrow */
[dir="rtl"] .back-link {
  direction: rtl;
  unicode-bidi: plaintext;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .hero h1 {
    font-size: 1.5rem;
  }
  
  .hero p {
    font-size: 1rem;
  }
  
  .card {
    padding: 1rem;
  }
  
  .tabs {
    flex-direction: column;
  }
  
  [dir="rtl"] .tabs {
    flex-direction: column;
  }
  
  .tab {
    justify-content: center;
  }
  
  .share-box {
    flex-direction: column;
  }
  
  [dir="rtl"] .share-box {
    flex-direction: column;
  }
  
  .view-header {
    flex-direction: column;
  }
  
  [dir="rtl"] .view-header {
    flex-direction: column;
  }
  
  .view-header .btn {
    width: 100%;
  }
}
