@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;
}

body {
  font-family: "Inter", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  -webkit-font-smoothing: antialiased;
  background-attachment: fixed;
}

#board {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.6) transparent;
}

#board.board-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 320px;
  gap: 24px;
  padding-bottom: 8px;
  padding-top: 32px;
}

#board.board-grid::-webkit-scrollbar {
  height: 10px;
}

#board.board-grid::-webkit-scrollbar-thumb {
  background-color: rgba(148, 163, 184, 0.5);
}

.board-container {
  position: relative;
  width: 100%;
  min-height: 320px;
}

.board-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.78));
  backdrop-filter: blur(4px);
  transition: opacity 160ms ease, visibility 160ms ease;
}

.board-overlay.hidden {
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.board-overlay.is-loading {
  opacity: 1;
  visibility: visible;
}

.board-overlay.is-error {
  opacity: 1;
  visibility: visible;
}

#board.is-loading {
  visibility: hidden;
}

.overlay-card,
.loader-card {
  max-width: 320px;
  width: 100%;
  border-radius: 24px;
  border: 1px dashed #cbd5f5;
  background: rgba(248, 250, 252, 0.95);
  padding: 32px;
  text-align: center;
  color: #64748b;
  box-shadow: 0 20px 45px -24px rgba(15, 23, 42, 0.25);
}

.overlay-card h3,
.loader-card h3 {
  margin-bottom: 8px;
  font-size: 1.125rem;
  font-weight: 600;
  color: #1e293b;
}

.overlay-card p,
.loader-card p {
  font-size: 0.875rem;
}

.loader-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  height: 48px;
  width: 48px;
}

.loading-spinner {
  box-sizing: border-box;
  height: 100%;
  width: 100%;
  border-radius: 9999px;
  border: 4px solid rgba(99, 102, 241, 0.2);
  border-top-color: #6366f1;
  animation: spinner-rotate 0.8s linear infinite;
}

@keyframes spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

.overlay-card--error {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(254, 242, 242, 0.95);
  color: #b91c1c;
}

.overlay-card--error h3 {
  color: #b91c1c;
  margin-bottom: 8px;
}

.overlay-card--error p {
  color: #dc2626;
}

#board::-webkit-scrollbar-track {
  background: transparent;
}

#board::-webkit-scrollbar-thumb {
  background-color: rgba(148, 163, 184, 0.55);
  border-radius: 9999px;
}

.modal-open {
  display: flex !important;
}

[data-drag-handle] {
  cursor: grab;
}

[data-drag-handle]:active {
  cursor: grabbing;
}

.kanban-task {
  user-select: none;
  -webkit-user-select: none;
  border-radius: 18px;
  border: 1px solid #d9e2ff;
  background: linear-gradient(180deg, #f9fbff 0%, #f3f6ff 100%);
  padding: 20px;
  box-shadow: 0 20px 32px -28px rgba(79, 70, 229, 0.35);
  transition: transform 120ms ease, box-shadow 120ms ease;
  cursor: grab;
}

.kanban-task:hover {
  transform: translateY(-4px);
  box-shadow: 0 26px 52px -28px rgba(79, 70, 229, 0.4);
}

.kanban-task:active {
  cursor: grabbing;
}

.kanban-task .task-card-body {
  pointer-events: none;
}

.label-color-preview {
  transition: background 150ms ease;
}

.tasks-dropzone {
  transition: background-color 120ms ease, border-radius 120ms ease;
}

.assignees-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.assignees-select {
  flex: 1 1 auto;
}

.assignees-add-btn svg {
  transition: transform 120ms ease;
}

.assignees-add-btn:disabled,
.assignees-add-btn:disabled:hover {
  background: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
}

.assignees-add-btn:not(:disabled):hover svg {
  transform: scale(1.1);
}

.assignees-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-radius: 1rem;
  padding: 0.5rem 0.75rem;
  min-height: 44px;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  font-size: 0.78rem;
}

.assignees-chips.is-empty {
  color: #94a3b8;
  font-style: italic;
}

.assignee-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: #e0e7ff;
  color: #3730a3;
  border-radius: 9999px;
  padding: 0.25rem 0.75rem;
  font-weight: 600;
  line-height: 1;
}

.assignee-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: rgba(55, 48, 163, 0.1);
  color: #312e81;
  padding: 0.15rem;
  transition: background 120ms ease, color 120ms ease;
}

.assignee-chip-remove:hover {
  background: rgba(55, 48, 163, 0.2);
  color: #1e1b4b;
}

.column-menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9999px;
  background: transparent;
  color: #64748b;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.column-menu-trigger:hover,
.column-menu-trigger:focus-visible {
  background: rgba(99, 102, 241, 0.12);
  color: #4338ca;
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.25);
  outline: none;
}

.column-menu {
  backdrop-filter: blur(12px);
  border-radius: 18px;
  border: 1px solid rgba(226, 232, 240, 0.8);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 22px 60px -28px rgba(30, 41, 59, 0.35);
  padding: 6px;
}

.column-menu::before {
  content: "";
  position: absolute;
  top: -7px;
  right: 18px;
  width: 14px;
  height: 14px;
  background: inherit;
  transform: rotate(45deg);
  border-left: 1px solid rgba(226, 232, 240, 0.8);
  border-top: 1px solid rgba(226, 232, 240, 0.8);
}

.column-menu-item {
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #1f2937;
  transition: background 140ms ease, color 140ms ease;
}

.column-menu-item + .column-menu-item {
  margin-top: 4px;
}

.column-menu-item:hover,
.column-menu-item:focus-visible {
  background: rgba(99, 102, 241, 0.12);
  color: #4338ca;
  outline: none;
}

.column-menu-item.text-rose-600 {
  color: #dc2626;
}

.column-menu-item.text-rose-600:hover,
.column-menu-item.text-rose-600:focus-visible {
  background: rgba(248, 113, 113, 0.15);
  color: #b91c1c;
}

.kanban-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-radius: 24px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  box-shadow: 0 20px 45px -24px rgba(15, 23, 42, 0.25);
  width: 320px;
}

.column-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9999px;
  background: transparent;
  color: #cbd5f5;
  opacity: 0;
  transition: opacity 140ms ease, color 140ms ease, background 140ms ease;
  cursor: grab;
}

.kanban-column:hover .column-drag-handle {
  opacity: 1;
  color: #4f46e5;
  background: rgba(99, 102, 241, 0.12);
}

.column-drag-handle:hover,
.column-drag-handle:focus-visible {
  color: #312e81;
  background: rgba(99, 102, 241, 0.18);
  outline: none;
}

.column-drag-handle:active {
  cursor: grabbing;
}

.column-dragging {
  opacity: 0.85;
  box-shadow: 0 28px 60px -28px rgba(30, 41, 59, 0.35);
}

.column-placeholder {
  border: 2px dashed rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.06);
  min-height: 120px;
  border-radius: 24px;
  opacity: 0.5;
}

.task-card-cover {
  aspect-ratio: 16 / 9;
  object-fit: cover;
  width: 100%;
}

.kanban-column .tasks-dropzone {
  display: grid;
  gap: 16px;
}

.kanban-task .task-card-body > div:first-child span {
  border-radius: 9999px;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

@supports not (aspect-ratio: 16 / 9) {
  .task-card-cover {
    height: 180px;
  }
}

.dragging {
  opacity: 0.6;
  transform: scale(0.98);
}

.tasks-dropzone.drag-over {
  background-color: rgba(79, 70, 229, 0.08);
  border-radius: 20px;
  transition: background-color 120ms ease;
}

#board {
  position: relative;
  transition: background-color 160ms ease, background-image 160ms ease;
  border-radius: 32px;
}

#board.board-pan-hover {
  cursor: grab;
  background-image: linear-gradient(180deg, rgba(99, 102, 241, 0.06), rgba(99, 102, 241, 0.02));
}

#board.board-scroll-dragging {
  cursor: grabbing;
  background-image: linear-gradient(180deg, rgba(99, 102, 241, 0.06), rgba(99, 102, 241, 0.02));
}

/* Animaciones para notificaciones */
@keyframes slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.animate-slide-in {
  animation: slide-in 0.3s ease-out;
}

/* Estilos para el panel de usuario */
#user-info-panel {
  transition: all 0.2s ease;
}

#user-info-panel:hover {
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.08);
}

/* ============= ESTILOS RESPONSIVE ============= */

/* Optimización para pantallas pequeñas */
@media (max-width: 640px) {
  /* Mejorar scroll en tableros móviles */
  [id^="board-"] {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Cards de facturas más compactas en móvil */
  .invoice-card {
    padding: 12px !important;
  }
  
  /* Modales ocupan más espacio en móvil */
  #invoice-modal > div,
  #recycle-modal > div {
    margin: 0;
    max-width: 100% !important;
    width: 100% !important;
  }
  
  /* Inputs más grandes para tocar fácilmente */
  input[type="text"],
  input[type="search"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px !important; /* Previene zoom en iOS */
  }
  
  /* Botones con área táctil mínima de 44px */
  button {
    min-height: 44px;
  }
  
  /* Grid de campos en una columna en móvil */
  #invoice-fields {
    grid-template-columns: 1fr !important;
  }
}

/* Optimización para tablets */
@media (min-width: 641px) and (max-width: 1024px) {
  /* Tableros en 2 columnas en tablet */
  #boards-container {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* Optimización para pantallas muy pequeñas */
@media (max-width: 375px) {
  /* Reducir padding en pantallas muy pequeñas */
  header .max-w-7xl {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  
  main {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  
  /* Texto del header más pequeño */
  h1 {
    font-size: 16px !important;
  }
  
  /* Ocultar texto en botones muy pequeños */
  #recycle-bin-btn span {
    display: none !important;
  }
}

/* Smooth scrolling en todos los contenedores */
* {
  scroll-behavior: smooth;
}

/* Mejorar legibilidad de texto en pantallas pequeñas */
@media (max-width: 640px) {
  body {
    font-size: 14px;
    line-height: 1.6;
  }
  
  /* Cards de papelera responsive */
  #recycle-list > div {
    padding: 12px !important;
  }
  
  #recycle-list button {
    font-size: 11px !important;
    padding: 6px 10px !important;
  }
}

/* Animaciones suaves para transiciones */
.invoice-card,
button,
input,
select {
  transition: all 0.2s ease;
}

/* Hover states solo en desktop */
@media (hover: hover) and (pointer: fine) {
  .invoice-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.1);
  }
}

/* Touch feedback para móviles */
@media (hover: none) {
  .invoice-card:active {
    transform: scale(0.98);
    opacity: 0.9;
  }
  
  button:active {
    transform: scale(0.95);
  }
}

/* Optimización de scrollbar personalizado solo en desktop */
@media (min-width: 1024px) {
  [id^="board-"]::-webkit-scrollbar {
    width: 8px;
  }
  
  [id^="board-"]::-webkit-scrollbar-track {
    background: rgba(241, 245, 249, 0.5);
    border-radius: 10px;
  }
  
  [id^="board-"]::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.5);
    border-radius: 10px;
  }
  
  [id^="board-"]::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.7);
  }
}

/* Asegurar que los modales sean accesibles en móvil */
@media (max-width: 640px) {
  .fixed.inset-0 {
    padding: 8px !important;
  }
  
  /* Footer de modales sticky en móvil */
  #invoice-modal > div > div:last-child,
  #recycle-modal > div > div:last-child {
    position: sticky;
    bottom: 0;
    z-index: 10;
  }
}

/* Optimización de fuentes para diferentes densidades de pantalla */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* Prevenir overflow horizontal en móvil */
@media (max-width: 640px) {
  body, html {
    overflow-x: hidden;
  }
  
  * {
    max-width: 100%;
  }
}

/* Mejorar contraste en modo oscuro del sistema */
@media (prefers-color-scheme: dark) {
  /* Mantener modo claro pero ajustar para mejor visibilidad nocturna */
  body {
    background-color: #f8fafc;
  }
}