/* Reset & Variables */
:root {
  --font-title: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Color Palette - Cyberpunk Dark & Glassmorphism */
  --bg-app: #090d16;
  --bg-gradient: radial-gradient(circle at 50% 0%, #151e36 0%, #090d16 100%);
  --bg-card: rgba(18, 25, 41, 0.65);
  --bg-sidebar: rgba(13, 19, 33, 0.9);
  --border-glass: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(139, 92, 246, 0.5);

  --accent: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%);
  --accent-glow: 0 0 20px rgba(139, 92, 246, 0.3);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --success: #10b981;
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  
  --shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-body);
  background: var(--bg-app);
  background-image: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* App Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-header {
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-glass);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 1.25rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-icon {
  stroke: url(#accent-grad-svg) #8b5cf6; /* Fallback but JS will use CSS */
  color: #8b5cf6;
  width: 28px;
  height: 28px;
}

.sidebar-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: justify-content;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.lists-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lists-menu li {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
}

.lists-menu li:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
}

.lists-menu li.active {
  background: rgba(139, 92, 246, 0.15);
  border-left: 3px solid #8b5cf6;
  color: var(--text-primary);
  font-weight: 500;
}

.list-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 8px;
}

.list-item-actions {
  display: opacity;
  opacity: 0;
  transition: var(--transition);
}

.lists-menu li:hover .list-item-actions {
  opacity: 1;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-glass);
}

.sidebar-action-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 10px 0;
  transition: var(--transition);
}

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

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  position: relative;
  padding: 40px;
}

/* Mobile Header */
.mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(13, 19, 33, 0.9);
  border-bottom: 1px solid var(--border-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 90;
}

.mobile-logo-text {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 1.2rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* List View & Headers */
.list-wrapper {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.list-title-container {
  flex: 1;
  position: relative;
}

.editable-title {
  font-family: var(--font-title);
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--text-primary);
  background: transparent;
  border: none;
  outline: none;
  width: 100%;
  padding: 4px 0;
}

.title-underline {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 60px;
  height: 4px;
  background: var(--accent-gradient);
  border-radius: 2px;
  transition: var(--transition);
}

.editable-title:focus ~ .title-underline {
  width: 100%;
}

.list-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Controls Panel (Collapsing & Sorting) */
.controls-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
}

.controls-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sort-controls {
  gap: 20px;
}

.control-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-item label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.9rem;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
}

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

.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 25px rgba(139, 92, 246, 0.5);
}

.btn-ai {
  position: relative;
  overflow: hidden;
}

.btn-ai::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 45%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 55%
  );
  transform: rotate(45deg);
  animation: shine 4s infinite ease-in-out;
}

@keyframes shine {
  0% { transform: translate(-50%, -50%) rotate(45deg); }
  20% { transform: translate(150%, 150%) rotate(45deg); }
  100% { transform: translate(150%, 150%) rotate(45deg); }
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-glass);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger-light);
  border-color: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

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

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

.btn-danger-outline:hover {
  background: var(--danger);
  color: #ffffff;
}

.btn-dashed {
  background: transparent;
  border: 1px dashed var(--border-glass);
  color: var(--text-secondary);
  width: 100%;
  padding: 16px;
  font-size: 1rem;
  border-radius: var(--radius-md);
}

.btn-dashed:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: rgba(139, 92, 246, 0.04);
}

.btn-link {
  background: transparent;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  padding: 0;
  cursor: pointer;
}

.btn-link:hover {
  color: #d946ef;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: var(--transition);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

/* Custom Select Dropdown */
.custom-select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 12px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

.custom-select:focus {
  border-color: var(--accent);
}

.custom-select option {
  background: #111827;
  color: var(--text-primary);
}

.select-full {
  width: 100%;
  padding: 10px;
}

/* Groups Card Container */
.groups-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.group-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color var(--transition), transform var(--transition);
  overflow: hidden;
}

.group-card.dragover {
  border-color: var(--accent);
  transform: scale(1.01);
}

/* Group Header */
.group-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.01);
  border-bottom: 1px solid var(--border-glass);
}

.group-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.group-drag-handle {
  color: var(--text-muted);
  cursor: grab;
  padding: 4px;
}

.group-drag-handle:active {
  cursor: grabbing;
}

.group-collapse-btn {
  color: var(--text-secondary);
  transition: transform 0.2s ease;
}

.group-card.collapsed .group-collapse-btn {
  transform: rotate(-90deg);
}

.group-title-input {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  background: transparent;
  border: none;
  outline: none;
  width: 80%;
  padding: 2px 0;
  transition: var(--transition);
}

.group-title-input:focus {
  border-bottom: 1px solid var(--accent);
}

.group-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Group Items Container */
.group-body {
  transition: max-height 0.3s cubic-bezier(0, 1, 0, 1);
  max-height: 2000px; /* arbitrary high value for smooth collapse */
}

.group-card.collapsed .group-body {
  max-height: 0;
  overflow: hidden;
  border-bottom: none;
}

.group-items-list {
  list-style: none;
  padding: 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Checklist Items */
.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid transparent;
  transition: var(--transition);
}

.item-row:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.04);
}

.item-row.dragging {
  opacity: 0.4;
  border: 1px dashed var(--accent);
}

.item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.item-drag-handle {
  color: var(--text-muted);
  cursor: grab;
  padding: 4px;
}

.item-checkbox-wrapper {
  position: relative;
  width: 20px;
  height: 20px;
}

.item-checkbox {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 100%;
  width: 100%;
  z-index: 2;
}

.item-checkbox-custom {
  position: absolute;
  top: 0;
  left: 0;
  height: 20px;
  width: 20px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 2px solid var(--text-muted);
  border-radius: 6px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.item-checkbox:checked ~ .item-checkbox-custom {
  background: var(--accent-gradient);
  border-color: transparent;
}

.item-checkbox-custom::after {
  content: "";
  position: absolute;
  display: none;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

.item-checkbox:checked ~ .item-checkbox-custom::after {
  display: block;
}

.item-text-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 4px 0;
  transition: var(--transition);
  text-overflow: ellipsis;
  overflow: hidden;
}

.item-text-input:focus {
  border-bottom: 1px solid var(--accent);
}

.item-checkbox:checked ~ .item-text-input {
  color: var(--text-muted);
  text-decoration: line-through;
}

.item-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Group switcher dropdown inside elements */
.group-switch-select {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 4px;
  outline: none;
  max-width: 90px;
  text-overflow: ellipsis;
}

.group-switch-select:hover {
  color: var(--text-primary);
}

.group-switch-select option {
  background: #111827;
  color: var(--text-primary);
}

/* Item Creation Row */
.add-item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 32px 16px 32px;
  border-top: 1px solid rgba(255, 255, 255, 0.02);
}

.add-item-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.add-item-input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.04);
}

/* Empty States */
.empty-state-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  gap: 16px;
  animation: fadeIn 0.4s ease;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.empty-state-view h2 {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.empty-state-view p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 320px;
  margin-bottom: 8px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(6, 9, 17, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-card {
  background: #0f1626;
  border: 1px solid var(--border-glass);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-card.modal-lg {
  max-width: 650px;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: 70vh;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-glass);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(255, 255, 255, 0.01);
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.input-password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-password-wrapper input {
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 12px 48px 12px 14px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
}

.input-password-wrapper input:focus {
  border-color: var(--accent);
}

.input-password-wrapper .icon-btn {
  position: absolute;
  right: 10px;
  color: var(--text-muted);
}

.form-help-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

/* Danger Zone inside Modal */
.danger-zone {
  margin-top: 32px;
  padding: 20px;
  border: 1px dashed rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  background: rgba(239, 68, 68, 0.02);
}

.danger-zone h4 {
  font-family: var(--font-title);
  color: var(--danger);
  font-weight: 700;
  margin-bottom: 6px;
}

.danger-zone p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.4;
}

/* AI Modal Elements */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  display: flex;
  gap: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
  margin-bottom: 20px;
}

.alert-warning {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.alert i {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

/* Drag-Drop Zone */
.upload-area {
  border: 2px dashed var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.03);
}

.upload-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
}

.upload-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.upload-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.hidden-input {
  display: none;
}

/* Upload Preview */
.upload-preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: fadeIn 0.3s ease;
}

.preview-image-wrapper {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-glass);
  max-width: 100%;
  max-height: 250px;
}

.preview-image-wrapper img {
  display: block;
  max-width: 100%;
  max-height: 250px;
  object-fit: contain;
}

.remove-preview-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--danger) !important;
  color: white !important;
}

/* Loading animation for AI */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(139, 92, 246, 0.2);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  font-weight: 600;
  font-size: 1rem;
}

.loading-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Extraction Results Preview */
.results-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.4s ease;
}

.results-container h4 {
  font-family: var(--font-title);
  font-size: 0.95rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.extracted-preview-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  max-height: 250px;
  overflow-y: auto;
}

.extracted-list-header {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.01);
  border-bottom: 1px solid var(--border-glass);
}

.extracted-list-body {
  padding: 16px;
}

.preview-group-block {
  margin-bottom: 14px;
}

.preview-group-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}

.preview-items-list {
  padding-left: 14px;
  list-style: square;
  font-size: 0.9rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.import-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.radio-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.01);
  cursor: pointer;
  transition: var(--transition);
}

.radio-option:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}

.radio-option input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--accent);
}

.radio-option div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.radio-option strong {
  font-size: 0.9rem;
  font-weight: 600;
}

.radio-option span {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.hidden {
  display: none !important;
}

/* Helpers */
.mobile-only {
  display: none;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Responsive Rules */
@media (max-width: 768px) {
  .mobile-only {
    display: flex;
  }
  
  .app-layout {
    flex-direction: column;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    height: 100vh;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.8);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .sidebar.sidebar-open {
    left: 0;
  }
  
  .main-content {
    padding: 16px;
    height: calc(100vh - 64px);
  }
  
  .list-wrapper {
    gap: 16px;
  }
  
  .editable-title {
    font-size: 1.75rem;
  }
  
  .controls-panel {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px;
  }
  
  .sort-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  .control-item {
    justify-content: space-between;
  }
  
  .import-options {
    grid-template-columns: 1fr;
  }
  
  .btn-sm {
    flex: 1;
  }
  
  .modal-card {
    width: 95%;
  }
  
  .add-item-row {
    padding: 12px 16px;
  }
  
  .group-header {
    padding: 12px 16px;
  }
}

/* --- Item Details Side Drawer --- */
.details-drawer {
  position: fixed;
  top: 0;
  right: -400px;
  width: 400px;
  height: 100vh;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-glass);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  z-index: 150;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.details-drawer.open {
  right: 0;
}

.drawer-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-header h3 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
}

.drawer-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-section label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.drawer-item-title {
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-word;
}

/* Attachments */
.attachments-upload-area {
  border: 1px dashed var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.01);
  transition: var(--transition);
}

.attachments-upload-area:hover {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.03);
}

.upload-icon-sm {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}

.upload-text-sm {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.attachments-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  transition: var(--transition);
}

.attachment-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.attachment-info-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  flex: 1;
  min-width: 0;
}

.attachment-info-link:hover {
  color: var(--text-primary);
}

.attachment-info-link i {
  flex-shrink: 0;
}

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

.item-details-btn {
  color: var(--text-secondary);
  opacity: 0.5;
  transition: var(--transition);
}

.item-row:hover .item-details-btn {
  opacity: 1;
}

.item-details-btn.active {
  color: var(--accent);
  opacity: 1;
}

/* Mobile responsive details drawer */
@media (max-width: 768px) {
  .details-drawer {
    width: 100%;
    right: -100%;
  }
  .details-drawer.open {
    right: 0;
  }
}

/* --- Properties Display Pills (Checklist Rows) --- */
.item-text-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.item-text-display {
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-primary);
  user-select: none;
  word-break: break-word;
  transition: color 0.15s ease;
  padding: 4px 0;
}

.item-row.checked .item-text-display {
  color: var(--text-muted);
  text-decoration: line-through;
}

.item-text-display:hover {
  color: var(--accent-light);
}

.item-inline-edit {
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  outline: none;
  width: 90%;
}

.item-properties-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.prop-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.prop-pill i {
  width: 10px;
  height: 10px;
  opacity: 0.7;
}

/* --- Visibility Eye Toggles --- */
.form-group-with-toggle {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.visibility-toggle {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  transition: all 0.2s ease;
}

.visibility-toggle input {
  display: none;
}

.visibility-toggle .visibility-eye::before {
  content: "👁️";
  opacity: 0.25;
  font-size: 0.95rem;
  filter: grayscale(1);
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.visibility-toggle input:checked + .visibility-eye::before {
  opacity: 1;
  filter: none;
}

.visibility-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--accent);
}

/* --- Sidebar Custom Fields Manager --- */
.sidebar-separator {
  height: 1px;
  background: var(--border-glass);
  margin: 16px 12px;
  opacity: 0.5;
}

.custom-fields-sidebar-manager {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 12px 16px 12px;
}

.add-field-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-field-input {
  font-family: inherit;
  font-size: 0.8rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-primary);
  outline: none;
  width: 100%;
}

.sidebar-field-select {
  font-family: inherit;
  font-size: 0.8rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-primary);
  outline: none;
  width: 100%;
  cursor: pointer;
}

.custom-fields-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
}

.custom-field-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.custom-field-item .field-info {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-field-item .field-type {
  font-size: 0.65rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 1px 4px;
  border-radius: 4px;
}


