/* ============================================
   FTP Photo Dispatcher — Custom Styles
   ============================================ */

/* --- CSS Variables / Theme --- */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --info: #0891b2;
  --info-light: #cffafe;
  --bg-body: #f1f5f9;
  --bg-card: #ffffff;
  --bg-navbar: #0f172a;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --radius: 0.75rem;
  --radius-sm: 0.5rem;
  --transition: 0.2s ease;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* --- Dark theme --- */
[data-bs-theme="dark"] {
  --bg-body: #0f172a;
  --bg-card: #1e293b;
  --bg-navbar: #020617;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #334155;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* --- Base --- */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

/* --- Navbar --- */
.navbar {
  background-color: var(--bg-navbar) !important;
  box-shadow: var(--shadow-md);
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.navbar .nav-link {
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.5rem 1rem !important;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
  color: rgba(255, 255, 255, 0.7) !important;
}

.navbar .nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff !important;
}

.navbar .nav-link.active {
  background: var(--primary);
  color: #fff !important;
}

.navbar .nav-link i {
  margin-right: 0.35rem;
}

/* Status indicator */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.75);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.online {
  background-color: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: pulse-green 2s infinite;
}

.status-dot.offline {
  background-color: var(--danger);
  box-shadow: 0 0 6px var(--danger);
}

@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  padding: 1rem 1.25rem;
}

.card-body {
  padding: 1.25rem;
}

/* Stats cards */
.stat-card {
  position: relative;
  overflow: hidden;
  border: none;
  box-shadow: var(--shadow-md);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.stat-card.stat-primary::before { background: var(--primary); }
.stat-card.stat-success::before { background: var(--success); }
.stat-card.stat-danger::before  { background: var(--danger); }
.stat-card.stat-warning::before { background: var(--warning); }
.stat-card.stat-info::before    { background: var(--info); }

.stat-card .stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-card.stat-primary .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-card.stat-success .stat-icon { background: var(--success-light); color: var(--success); }
.stat-card.stat-danger  .stat-icon { background: var(--danger-light);  color: var(--danger); }
.stat-card.stat-warning .stat-icon { background: var(--warning-light); color: var(--warning); }
.stat-card.stat-info    .stat-icon { background: var(--info-light);    color: var(--info); }

.stat-card .stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.stat-card .stat-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- Activity Feed --- */
.activity-feed {
  max-height: 520px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.activity-feed::-webkit-scrollbar {
  width: 5px;
}

.activity-feed::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 9999px;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition);
  animation: fadeSlideIn 0.35s ease;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-item:hover {
  background: rgba(37, 99, 235, 0.03);
}

.activity-item .activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.activity-item .activity-icon.success {
  background: var(--success-light);
  color: var(--success);
}

.activity-item .activity-icon.error {
  background: var(--danger-light);
  color: var(--danger);
}

.activity-item .activity-icon.sending {
  background: var(--warning-light);
  color: var(--warning);
}

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

.activity-item .activity-filename {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.activity-item .activity-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-family: var(--font-mono);
}

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

/* --- Badges --- */
.badge-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3em 0.7em;
  border-radius: 9999px;
  letter-spacing: 0.02em;
}

.badge-status.success {
  background: var(--success-light);
  color: var(--success);
}

.badge-status.error {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-status.sending,
.badge-status.pending {
  background: var(--warning-light);
  color: var(--warning);
}

.badge-status.info {
  background: var(--info-light);
  color: var(--info);
}

.badge-xmp-original {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3em 0.7em;
  border-radius: 9999px;
}

.badge-xmp-modify {
  background: var(--warning-light);
  color: var(--warning);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3em 0.7em;
  border-radius: 9999px;
}

/* --- Tables --- */
.table-modern {
  font-size: 0.88rem;
}

.table-modern thead th {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border-color);
  padding: 0.85rem 1rem;
  white-space: nowrap;
}

.table-modern tbody td {
  padding: 0.85rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-color);
}

.table-modern tbody tr {
  transition: background var(--transition);
}

.table-modern tbody tr:hover {
  background: rgba(37, 99, 235, 0.03);
}

/* --- Destination cards --- */
.dest-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  transition: all var(--transition);
}

.dest-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.dest-card.inactive {
  opacity: 0.55;
}

.dest-card .dest-icon {
  width: 44px;
  height: 44px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

/* --- Buttons --- */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

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

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: all var(--transition);
}

.btn-icon:hover {
  transform: scale(1.08);
}

/* --- Forms --- */
.form-control,
.form-select {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

/* Password toggle */
.password-toggle {
  cursor: pointer;
  color: var(--text-muted);
  transition: color var(--transition);
}

.password-toggle:hover {
  color: var(--text-primary);
}

/* --- Toasts --- */
.toast-container {
  z-index: 9999;
}

.toast {
  border: none;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  animation: toastSlideIn 0.3s ease;
}

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

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

.toast.toast-info {
  border-left: 4px solid var(--info);
}

.toast.toast-warning {
  border-left: 4px solid var(--warning);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* --- Filter bar --- */
.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

/* --- Pagination --- */
.pagination .page-link {
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-sm) !important;
  margin: 0 2px;
  transition: all var(--transition);
}

.pagination .page-link:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.pagination .page-item.disabled .page-link {
  color: var(--text-muted);
}

/* --- Footer --- */
.footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 1rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* --- Danger zone --- */
.danger-zone {
  border: 2px solid var(--danger);
  border-radius: var(--radius);
}

.danger-zone .card-header {
  background: var(--danger-light);
  color: var(--danger);
  font-weight: 700;
  border-bottom: 2px solid var(--danger);
}

/* --- Modals --- */
.modal-content {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  border-bottom: 1px solid var(--border-color);
  padding: 1.15rem 1.5rem;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  border-top: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
}

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

/* --- XMP Rules --- */
.xmp-rule-item {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  margin-bottom: 0.5rem;
  transition: box-shadow var(--transition);
  cursor: grab;
}

.xmp-rule-item:active {
  cursor: grabbing;
}

.xmp-rule-item:hover {
  box-shadow: var(--shadow-sm);
}

.xmp-rule-item .drag-handle {
  color: var(--text-muted);
  cursor: grab;
  font-size: 1rem;
}

/* --- Toggle switch overrides --- */
.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.form-switch .form-check-input {
  width: 2.5em;
  height: 1.3em;
  cursor: pointer;
}

/* --- Confirmation modal --- */
#confirmModal .modal-body {
  text-align: center;
  padding: 2rem 1.5rem;
}

#confirmModal .confirm-icon {
  font-size: 3rem;
  color: var(--warning);
  margin-bottom: 1rem;
}

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.95rem;
}

/* --- Utilities --- */
.text-mono {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .stat-card .stat-value {
    font-size: 1.4rem;
  }

  .stat-card .stat-label {
    font-size: 0.72rem;
  }

  .activity-item {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .activity-item .activity-time {
    width: 100%;
    text-align: right;
  }

  .filter-bar .row > [class*="col"] {
    margin-bottom: 0.5rem;
  }

  .table-modern {
    font-size: 0.82rem;
  }

  .table-modern thead th,
  .table-modern tbody td {
    padding: 0.6rem 0.5rem;
  }

  .dest-card .btn-group {
    flex-wrap: wrap;
  }
}

@media (max-width: 576px) {
  .navbar-brand {
    font-size: 1.05rem;
  }

  .stat-card .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }
}

/* --- Loading spinner --- */
.spinner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(2px);
}

.spinner-overlay .spinner-border {
  width: 3rem;
  height: 3rem;
}

/* --- Sortable drag ghost --- */
.sortable-ghost {
  opacity: 0.4;
  background: var(--primary-light) !important;
}
