/* Global tweaks */
:root {
  --brand-primary: #0d6efd;
  --bg-body: #f7f8fc; /* soft cool white */
  --text-color: #0f172a; /* slate-900 */
  --text-secondary: #556070;
  --surface: rgba(255, 255, 255, 0.75);
  --surface-border: rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 20px 50px rgba(2, 6, 23, 0.12);
  /* Map to Bootstrap tokens for consistent theming */
  --bs-body-bg: var(--bg-body);
  --bs-body-color: var(--text-color);
  --bs-heading-color: var(--text-color);
  --bs-secondary-color: var(--text-secondary);
  --bs-border-color: rgba(15, 23, 42, 0.12);
  --bs-form-control-bg: #ffffff;
  --bs-form-control-color: var(--text-color);
}

[data-theme="dark"] {
  --bg-body: #0e141e; /* slightly bluish charcoal */
  --text-color: #e6eaf2;
  --text-secondary: #c3c9d4; /* brighter secondary for readability */
  --surface: rgba(17, 24, 39, 0.55);
  --surface-border: rgba(255, 255, 255, 0.08);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
  /* Bootstrap mappings in dark */
  --bs-body-bg: var(--bg-body);
  --bs-body-color: var(--text-color);
  --bs-heading-color: var(--text-color);
  --bs-secondary-color: var(--text-secondary);
  --bs-border-color: rgba(255, 255, 255, 0.12);
  --bs-form-control-bg: rgba(255, 255, 255, 0.06);
  --bs-form-control-color: var(--text-color);
}

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, 'Helvetica Neue', Arial, 'Noto Sans', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  color: var(--text-color);
  background: var(--bg-body);
}

.cursor-grab {
  cursor: grab;
}

/* Decorative background */
.background-decor {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.bg-gradient {
  position: absolute;
  inset: -10% -10% -10% -10%;
  background: radial-gradient(1200px 700px at 10% -10%, rgba(167, 139, 250, 0.20), transparent 60%),
              radial-gradient(1200px 700px at 90% -10%, rgba(34, 197, 94, 0.18), transparent 60%),
              radial-gradient(900px 600px at 50% 110%, rgba(96, 165, 250, 0.18), transparent 60%);
  filter: blur(10px) saturate(115%);
}

.bg-glow {
  position: absolute;
  width: 42vw;
  height: 42vw;
  border-radius: 999px;
  filter: blur(40px);
  opacity: 0.6;
}

.bg-glow-1 {
  background: radial-gradient(circle at 30% 30%, rgba(124, 58, 237, 0.35), transparent 60%);
  top: -10vh;
  left: -10vw;
}

.bg-glow-2 {
  background: radial-gradient(circle at 70% 40%, rgba(14, 165, 233, 0.28), transparent 60%);
  bottom: -8vh;
  right: -8vw;
}

/* Glass surfaces */
.glass-nav {
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-color: var(--surface-border) !important;
}

/* Ensure nav text contrasts in both themes */
.glass-nav .navbar-brand,
.glass-nav .nav-link {
  color: var(--text-color) !important;
}
.glass-nav .nav-link:hover { opacity: 0.85; }

.card {
  border-radius: 0.9rem;
}

.glass-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Dropzone */
.dropzone {
  border: 2px dashed #c9d2e1;
  border-radius: 0.9rem;
  background:
    radial-gradient(circle at 20px 20px, rgba(13, 110, 253, 0.07) 2px, transparent 3px) 0 0 / 22px 22px,
    linear-gradient(180deg, rgba(255,255,255,0.65), rgba(255,255,255,0.5));
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  display: block;
}

[data-theme="dark"] .dropzone {
  background:
    radial-gradient(circle at 20px 20px, rgba(13, 110, 253, 0.09) 2px, transparent 3px) 0 0 / 22px 22px,
    linear-gradient(180deg, rgba(17,24,39,0.6), rgba(17,24,39,0.5));
  border-color: rgba(255,255,255,0.12);
}

.dropzone .dropzone-inner .icon-wrap {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  background: rgba(13, 110, 253, 0.08);
  color: var(--brand-primary);
  border-radius: 999px;
}

.dropzone.is-dragover {
  background: linear-gradient(180deg, rgba(13,110,253,0.07), rgba(13,110,253,0.04));
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 0.3rem rgba(13, 110, 253, 0.15);
  transform: translateY(-1px);
}

.dropzone.disabled {
  opacity: 0.6;
  pointer-events: none;
}

/* Reorder handle spacing */
.draggable-item i.bi-grip-vertical {
  font-size: 1.1rem;
}

/* List look */
.list-group-item {
  border-left: 0;
  border-right: 0;
  background: transparent;
}

.list-group-item:hover {
  background: rgba(13, 110, 253, 0.05);
}

[data-theme="dark"] .list-group-item:hover {
  background: rgba(13, 110, 253, 0.08);
}

/* Buttons */
.btn-gradient {
  background-image: linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%);
  border: 0;
}

.btn-gradient:hover {
  filter: brightness(0.98);
}

.btn-gradient:active {
  filter: brightness(0.95);
}

/* Small helpers */
.fw-medium { font-weight: 600; }

/* Progress */
.progress {
  background-color: rgba(2, 6, 23, 0.08);
}

.progress .progress-bar {
  background-image: linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%);
}

/* Ensure list item actions remain aligned right and visible */
.list-group-item.draggable-item {
  display: flex;
  align-items: center;
}
.list-group-item.draggable-item > .d-flex.flex-column.flex-grow-1 {
  min-width: 0;
}
.list-group-item .actions {
  margin-left: auto;
}

/* Enable wrapping of long filenames without affecting actions */
.list-group-item .fw-medium.text-truncate {
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile tweaks */
@media (max-width: 576px) {
  .dropzone .dropzone-inner .icon-wrap { width: 56px; height: 56px; }
  .glass-card .form-control { max-width: 100% !important; }
  .glass-card .btn { width: auto; }
}