/* --- CSS Variables & Theming --- */
:root {
  /* Common variables */
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  /* #16 FIX: color unificado con el branding de VJ */
  --accent: #4a926a;
  --accent-hover: #3a7a58;
  
  --priority-baja: #95a5a6;
  --priority-media: #f1c40f;
  --priority-alta: #e67e22;
  --priority-urgente: #e74c3c;
  
  --user-mati: #4A90D9;
  --user-gise: #E67E22;
  --user-ema: #27AE60;
  --user-guille: #E74C3C;
}

/* Dark Mode (Default) */
html.dark {
  --bg-color: #0d1f0d;
  --panel-bg: #1a3a1a;
  --panel-hover: #224a22;
  --text-primary: #ffffff;
  --text-secondary: #a8d5a8;
  --border-color: #2c5a2c;
  --input-bg: #0d1f0d;
  --modal-overlay: rgba(0,0,0,0.7);
}

/* Light Mode */
html.light {
  --bg-color: #f4f7f4;
  --panel-bg: #ffffff;
  --panel-hover: #f0f0f0;
  --text-primary: #1a3a1a;
  --text-secondary: #4a6a4a;
  --border-color: #d0e0d0;
  --input-bg: #ffffff;
  --modal-overlay: rgba(0,0,0,0.5);
}

/* --- Global Reset & Basics --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.5;
  transition: background-color 0.3s, color 0.3s;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* --- Utilities --- */
.hidden { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  border: none;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-family);
}
.btn-primary {
  background-color: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background-color: var(--accent-hover);
}
.btn-outline {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}
.btn-outline:hover {
  background-color: var(--panel-hover);
}
.btn-block {
  width: 100%;
}
.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border-radius: 50%;
  transition: all 0.2s;
}
.icon-btn:hover {
  color: var(--accent);
  background-color: var(--panel-hover);
}

/* --- Login Page --- */
.login-body {
  justify-content: center;
  align-items: center;
}
.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}
.login-card {
  background-color: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.login-header {
  text-align: center;
  margin-bottom: 2rem;
}
.logo {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.5rem;
  letter-spacing: -1px;
}
.form-group {
  margin-bottom: 1.2rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--input-bg);
  color: var(--text-primary);
  font-family: var(--font-family);
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.error-message {
  color: var(--priority-urgente);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  text-align: center;
  display: none;
}

/* --- App Layout --- */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.5rem;
  height: 60px;
  background-color: var(--panel-bg);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.nav-tabs {
  display: flex;
  gap: 0.5rem;
}
.nav-tab {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  position: relative;
}
.nav-tab:hover {
  background-color: var(--panel-hover);
  color: var(--text-primary);
}
.nav-tab.active {
  background-color: var(--panel-hover);
  color: var(--accent);
}
.badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  background-color: var(--priority-urgente);
  border-radius: 50%;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
}

.main-content {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}
.view {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* 70/30 Unified Layout */
.unified-layout {
  display: flex;
  flex-direction: row;
  height: 100%;
  min-height: 0;
}
.unified-chat {
  flex: 7;
  border-right: 1px solid var(--border-color);
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.unified-sidebar {
  flex: 3;
  min-width: 320px;
  background-color: var(--bg-color);
  display: flex;
  flex-direction: column;
}

@media (max-width: 768px) {
  .unified-layout {
    position: relative;
  }
  .unified-chat {
    flex: 1;
    border-right: none;
    /* Bug 2/3: ensure full height for scroll on mobile */
    height: calc(100dvh - 54px);
  }
  .unified-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 90vw);
    z-index: 50;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -5px 0 30px rgba(0,0,0,0.6);
  }
  .unified-sidebar.open {
    transform: translateX(0);
  }
  #mobile-menu-btn {
    display: flex !important;
  }
}

/* Sidebar overlay backdrop */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 49;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}
.sidebar-overlay.active {
  display: block;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* --- Chat View --- */
/* Bug 1: padding-bottom aquí en vez de main-content, para que no tape el input */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;          /* Bug 2/3: clave para que flex calcule overflow */
  padding-bottom: 0;      /* Bug 1: el sticky del input se encarga solo */
}
@media (max-width: 768px) {
  .chat-container {
    padding-bottom: 70px; /* Bug 1: espacio para la bottom nav */
  }
}
.pinned-message {
  background-color: var(--panel-hover);
  border-bottom: 1px solid var(--border-color);
  padding: 0.8rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.pinned-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
}
.pinned-text {
  font-size: 0.95rem;
  font-style: italic;
  margin-top: 2px;
}
/* Bug 2/3: min-height:0 + overflow-y:scroll + iOS touch scroll */
.chat-messages {
  flex: 1;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 0;
}
.message {
  display: flex;
  gap: 1rem;
  max-width: 80%;
}
.message.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.message.theirs {
  align-self: flex-start;
}
.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  flex-shrink: 0;
}
.message-content {
  display: flex;
  flex-direction: column;
  position: relative;
}
.message.mine .message-content {
  align-items: flex-end;
}
.message.theirs .message-content {
  align-items: flex-start;
}
.message-user {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 2px;
}
.message-bubble {
  background-color: var(--panel-bg);
  border: 1px solid var(--border-color);
  padding: 0.8rem 1rem;
  border-radius: 12px;
  /* #19 FIX: 1rem mínimo para evitar zoom automático en iOS */
  font-size: 1rem;
  position: relative;
  word-break: break-word;
}
.message.mine .message-bubble {
  color: #fff;
  border: none;
  border-top-right-radius: 2px;
}
.message.theirs .message-bubble {
  border-top-left-radius: 2px;
}
.message-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Reactions */
.reactions-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 4px;
}
.reaction-pill {
  background-color: var(--panel-hover);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2px 6px;
  font-size: 0.8rem;
  cursor: pointer;
  user-select: none;
}
.reaction-pill:hover {
  border-color: var(--text-secondary);
}
.reaction-pill small {
  color: var(--text-secondary);
  margin-left: 2px;
}

/* Message Actions Hover */
.message-actions {
  position: absolute;
  top: -15px;
  right: 10px;
  background-color: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  display: flex;
  padding: 2px;
  opacity: 0;
  transition: opacity 0.2s;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.message.mine .message-actions {
  right: auto;
  left: 10px;
}
.message:hover .message-actions {
  opacity: 1;
}
.action-btn {
  background: none;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
}
.action-btn:hover {
  background-color: var(--panel-hover);
}
.reaction-trigger {
  position: relative;
}
.reaction-bar {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 5px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  z-index: 10;
  gap: 5px;
  margin-bottom: 5px;
}
.reaction-trigger:hover .reaction-bar {
  display: flex;
}
.reaction-bar span {
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
  transition: transform 0.2s;
}
.reaction-bar span:hover {
  transform: scale(1.2);
}

/* Reply Preview */
.message-reply-preview {
  background-color: var(--panel-hover);
  border-left: 3px solid var(--border-color);
  padding: 0.5rem;
  border-radius: 4px;
  margin-bottom: 5px;
  font-size: 0.85rem;
  opacity: 0.8;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-reply-preview .reply-user {
  font-weight: 600;
  margin-right: 5px;
}

/* ── @Mention styles ──────────────────────────────────────────── */
.mention-tag {
  display: inline-block;
  background: rgba(74, 146, 106, 0.2);
  color: #4a926a;
  font-weight: 600;
  border-radius: 4px;
  padding: 0 3px;
  font-size: 0.95em;
  transition: background 0.2s;
}
.mention-tag:hover {
  background: rgba(74, 146, 106, 0.35);
}

/* Burbuja resaltada cuando te mencionan a vos */
.message.mention-me .message-bubble {
  border: 1.5px solid rgba(74, 146, 106, 0.7) !important;
  box-shadow: 0 0 0 3px rgba(74, 146, 106, 0.12);
}
.message.theirs.mention-me .message-bubble {
  background-color: rgba(74, 146, 106, 0.08) !important;
}

/* ── Swipe-to-reply icon ──────────────────────────────────────── */
.swipe-reply-icon {
  position: absolute;
  left: -38px;
  top: 50%;
  transform: translateY(-50%) scale(0.6);
  opacity: 0;
  font-size: 1.3rem;
  transition: opacity 0.15s, transform 0.15s;
  pointer-events: none;
  color: var(--accent);
}
.message.swiping .swipe-reply-icon {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}
.message.mine .swipe-reply-icon {
  left: auto;
  right: -38px;
}

/* Input Area — Bug 1: sticky para que no quede tapado por la bottom nav */
.chat-input-container {
  padding: 1rem 1.5rem;
  background-color: var(--panel-bg);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 10;
}
.reply-preview {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-color);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  border-left: 3px solid var(--accent);
}
.reply-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.reply-content .reply-user {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
}
.reply-content .reply-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.emoji-wrapper {
  position: relative;
}
.emoji-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 10px;
  background-color: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  width: 280px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  box-shadow: 0 -5px 15px rgba(0,0,0,0.3);
  z-index: 100;
}
.emoji-picker span {
  font-size: 1.5rem;
  cursor: pointer;
  text-align: center;
  padding: 4px;
  border-radius: 4px;
}
.emoji-picker span:hover {
  background-color: var(--panel-hover);
}
.input-row input {
  flex: 1;
  padding: 0.8rem 1rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background-color: var(--input-bg);
  color: var(--text-primary);
  font-family: var(--font-family);
}
.input-row input:focus {
  outline: none;
  border-color: var(--accent);
}
.send-btn {
  border-radius: 50%;
  width: 42px;
  height: 42px;
  padding: 0;
}

.typing-indicator {
  padding: 0 1.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 0.5rem;
}

/* --- Tickets View --- */
#tickets-view {
  display: flex;
  flex-direction: column;
}
.tickets-header {
  padding: 1.5rem;
  background-color: var(--panel-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.view-toggles {
  display: flex;
  background-color: var(--bg-color);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}
.toggle-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-family);
  font-weight: 500;
}
.toggle-btn.active {
  background-color: var(--panel-hover);
  color: var(--text-primary);
}
.ticket-filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.filter-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.filter-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.4rem 0.8rem;
  border-radius: 15px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.filter-btn:hover {
  background-color: var(--panel-hover);
}
.filter-btn.active {
  background-color: var(--text-secondary);
  color: var(--bg-color);
  border-color: var(--text-secondary);
}

.sub-view {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Kanban */
.kanban-board {
  display: flex;
  height: 100%;
  overflow-x: auto;
  padding: 1.5rem;
  gap: 1.5rem;
}
.kanban-column {
  flex: 1;
  min-width: 300px;
  background-color: var(--panel-bg);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
}
.column-title {
  padding: 1rem;
  font-size: 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.column-title .count {
  background-color: var(--panel-hover);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.kanban-cards {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 100px;
}
.kanban-cards.drag-over {
  background-color: rgba(46, 204, 113, 0.05);
}

.kanban-card {
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem;
  cursor: grab;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}
.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.kanban-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
}
.priority-bar {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 4px;
}
.priority-urgent {
  animation: pulse-border 2s infinite;
}
@keyframes pulse-border {
  0% { box-shadow: -2px 0 5px rgba(231, 76, 60, 0); }
  50% { box-shadow: -2px 0 10px rgba(231, 76, 60, 0.8); }
  100% { box-shadow: -2px 0 5px rgba(231, 76, 60, 0); }
}

.card-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  margin-left: 8px;
}
.card-prop {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  margin-left: 8px;
}
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 0.8rem;
  margin-left: 8px;
}
.tag {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: var(--panel-hover);
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
}
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-left: 8px;
  margin-top: 10px;
}
.card-date {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.card-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
}

/* Calendar */
.calendar-container {
  padding: 1.5rem;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.calendar-header-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.calendar-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: auto repeat(5, 1fr);
  gap: 4px;
  background-color: var(--border-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}
.day-name {
  background-color: var(--panel-bg);
  text-align: center;
  padding: 0.8rem;
  font-weight: 600;
  font-size: 0.9rem;
}
.calendar-day {
  background-color: var(--bg-color);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  position: relative;
  cursor: pointer;
  transition: background-color 0.2s;
}
.calendar-day:hover:not(.blank) {
  background-color: var(--panel-hover);
}
.calendar-day.blank {
  background-color: var(--panel-bg);
  cursor: default;
}
.calendar-day.today {
  background-color: rgba(46, 204, 113, 0.1);
}
.calendar-day.today .date-num {
  background-color: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.calendar-day.past {
  opacity: 0.6;
}
.date-num {
  font-size: 0.9rem;
  font-weight: 500;
  align-self: flex-end;
  margin-bottom: 5px;
}
.dots-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: auto;
}
.ticket-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.urgent-pulse {
  animation: pulse-dot 1.5s infinite;
}
@keyframes pulse-dot {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); }
  70% { transform: scale(1.5); box-shadow: 0 0 0 5px rgba(231, 76, 60, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

/* Modals */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--modal-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-content {
  background-color: var(--panel-bg);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.small-modal {
  max-width: 400px;
}
.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}
.form-row {
  display: flex;
  gap: 1rem;
}
.form-row .form-group {
  flex: 1;
}
.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.tag-checkbox {
  background-color: var(--input-bg);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  user-select: none;
}
.tag-checkbox:hover {
  border-color: var(--text-secondary);
}
.tag-checkbox input {
  width: auto;
}
.form-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.comments-section {
  margin-top: 2rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}
.comments-list {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}
.comment {
  display: flex;
  gap: 0.8rem;
}
.comment-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}
.comment-meta {
  font-size: 0.8rem;
  margin-bottom: 2px;
}
.comment-meta .author {
  font-weight: 600;
  color: var(--text-primary);
}
.comment-meta .time {
  color: var(--text-secondary);
}
.comment-text {
  font-size: 0.9rem;
  background-color: var(--bg-color);
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  border-top-left-radius: 0;
}
.add-comment {
  display: flex;
  gap: 0.5rem;
}
.add-comment input {
  flex: 1;
  padding: 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--input-bg);
  color: var(--text-primary);
}

.day-tickets-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.day-ticket-item {
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  padding: 1rem;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ═══════════════════════════════════════
   MOBILE RESPONSIVE — Complete Overhaul
   ═══════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Bottom Navigation Bar ── */
  .bottom-nav {
    display: flex !important;
  }
  .main-content {
    padding-bottom: 70px; /* space for bottom nav */
  }
  /* Hide desktop nav tabs (now in bottom nav) */
  .nav-tabs {
    display: none;
  }
  /* Compact navbar on mobile */
  .navbar {
    padding: 0 1rem;
    height: 54px;
  }
  .user-name {
    display: none; /* hide name, show only avatar */
  }

  /* ── Touch Targets (min 44×44px) ── */
  .icon-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0.6rem;
  }
  .nav-tab {
    min-height: 44px;
    padding: 0.6rem 0.8rem;
  }
  .btn {
    min-height: 44px;
    padding: 0.75rem 1.2rem;
  }
  .send-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
  }
  .filter-btn {
    min-height: 36px;
    padding: 0.5rem 0.9rem;
  }

  /* ── Chat bubbles wider on mobile ── */
  .message {
    max-width: 90%;
  }

  /* ── Chat input area ── */
  .chat-input-container {
    padding: 0.75rem 1rem;
  }
  .input-row input {
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  /* ── Message actions: show on tap (not hover) ── */
  .message-actions {
    opacity: 1;
    position: static;
    margin-top: 4px;
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
  }
  .message.mine .message-actions {
    justify-content: flex-start;
  }

  /* ── Kanban stacks vertically ── */
  .kanban-board {
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    gap: 1rem;
  }
  .kanban-column {
    min-width: unset;
    min-height: 200px;
  }

  /* ── Calendar ── */
  .calendar-header-nav h2 {
    font-size: 1.1rem;
  }
  .day-name {
    font-size: 0.65rem;
    padding: 0.3rem;
  }
  .calendar-container {
    padding: 0.75rem;
  }

  /* ── Modals full-screen on mobile ── */
  .modal {
    padding: 0;
    align-items: flex-end;
  }
  .modal-content {
    border-radius: 16px 16px 0 0;
    max-height: 92dvh;
    max-width: 100%;
  }

  /* ── Forms ── */
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  .tickets-header {
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }
  .ticket-filters {
    overflow-x: auto;
    padding-bottom: 4px;
    flex-wrap: nowrap;
  }
}

/* ── Bottom Navigation Bar (hidden on desktop) ── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 70px;
  background-color: var(--panel-bg);
  border-top: 1px solid var(--border-color);
  z-index: 48;
  padding: 0 1rem env(safe-area-inset-bottom, 0);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.25);
}
.bottom-nav-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 100%;
}
.bottom-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  height: 100%;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 12px;
  transition: color 0.2s, background 0.15s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-btn svg {
  transition: transform 0.2s;
}
.bottom-nav-btn:active svg {
  transform: scale(0.85);
}
.bottom-nav-btn.active {
  color: var(--accent);
}
.bottom-nav-btn.active svg {
  filter: drop-shadow(0 0 6px var(--accent));
}
.bottom-nav-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.bottom-nav-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 18px);
  min-width: 16px;
  height: 16px;
  background: var(--priority-urgente);
  border-radius: 8px;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* ── Swipe hint on sidebar edge ── */
.swipe-hint {
  display: none;
}
@media (max-width: 768px) {
  .swipe-hint {
    display: block;
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 4px;
    height: 48px;
    background: var(--accent);
    border-radius: 4px 0 0 4px;
    opacity: 0.4;
    transition: opacity 0.3s;
    z-index: 45;
    pointer-events: none;
  }
  .swipe-hint.hide {
    opacity: 0;
  }
}


/* ═══════════════════════════════════════════════════════════════════
   VISUAL DEPTH SYSTEM — Advanced CSS Rendering Enhancement
   Cero cambios de layout · Cero cambios de variables · Solo rendering
   ═══════════════════════════════════════════════════════════════════ */

/* ── 1. Keyframes ────────────────────────────────────────────────── */
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.4; }
  30%           { transform: translateY(-5px); opacity: 1;   }
}

@keyframes urgent-card-pulse {
  0%   { box-shadow: 0 1px 2px rgba(0,0,0,.3), 0 2px 6px rgba(0,0,0,.15), inset 0 1px 0 rgba(255,255,255,.04); }
  50%  { box-shadow: 0 1px 2px rgba(0,0,0,.3), 0 2px 6px rgba(0,0,0,.15), 0 0 18px -4px rgba(231,76,60,.45), inset 0 1px 0 rgba(255,255,255,.04); }
  100% { box-shadow: 0 1px 2px rgba(0,0,0,.3), 0 2px 6px rgba(0,0,0,.15), inset 0 1px 0 rgba(255,255,255,.04); }
}

/* ── 2. Elevation system — Z levels ─────────────────────────────── */
/* Z1 — kanban cards */
.kanban-card {
  box-shadow: 0 1px 2px rgba(0,0,0,.3), 0 2px 6px rgba(0,0,0,.15),
              inset 0 1px 0 rgba(255,255,255,.04);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  will-change: transform;
}
.kanban-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0,0,0,.25), 0 1px 3px rgba(0,0,0,.2),
              inset 0 1px 0 rgba(255,255,255,.06);
}
.kanban-card:active {
  transform: translateY(0) scale(0.98);
  transition-duration: 80ms;
}

/* Z2 — kanban columns */
.kanban-column {
  box-shadow: 0 4px 12px rgba(0,0,0,.25), 0 1px 3px rgba(0,0,0,.2);
}

/* Z3 — navbar (sticky header) */
.navbar {
  box-shadow: 0 8px 24px rgba(0,0,0,.3), 0 2px 6px rgba(0,0,0,.15);
  padding-top: env(safe-area-inset-top, 0);
}

/* Z4 — modals */
.modal-content {
  box-shadow: 0 24px 48px rgba(0,0,0,.5), 0 8px 16px rgba(0,0,0,.3);
  border-image: none; /* reset before applying gradient border */
}

/* Message actions panel (Z2) */
.message-actions {
  box-shadow: 0 4px 12px rgba(0,0,0,.25), 0 1px 3px rgba(0,0,0,.2);
}

/* Emoji picker (Z3) */
.emoji-picker {
  box-shadow: 0 8px 24px rgba(0,0,0,.3), 0 2px 6px rgba(0,0,0,.15);
}

/* ── 3. Surface micro-gradients (dark mode) ──────────────────────── */
html.dark .navbar,
html.dark .kanban-column,
html.dark .modal-content {
  background: linear-gradient(
    160deg,
    color-mix(in srgb, var(--panel-bg) 96%, white 4%) 0%,
    var(--panel-bg) 100%
  );
}

html.dark .kanban-card {
  background: linear-gradient(
    160deg,
    color-mix(in srgb, var(--bg-color) 96%, white 4%) 0%,
    var(--bg-color) 100%
  );
}

/* Light mode — gradient reversed */
html.light .navbar,
html.light .kanban-column,
html.light .modal-content {
  background: linear-gradient(
    340deg,
    color-mix(in srgb, var(--panel-bg) 97%, black 3%) 0%,
    var(--panel-bg) 100%
  );
}

html.light .kanban-card {
  background: linear-gradient(
    340deg,
    color-mix(in srgb, var(--bg-color) 97%, black 3%) 0%,
    var(--bg-color) 100%
  );
}

/* ── 4. Priority bar — glow cromático 6px ───────────────────────── */
.priority-bar {
  width: 6px; /* was 4px */
}

/* Lateral glow per priority */
.priority-bar[style*="var(--priority-baja)"],
.priority-bar[data-priority="baja"] {
  box-shadow: 3px 0 12px -2px rgba(149, 165, 166, 0.6);
}
.priority-bar[style*="var(--priority-media)"],
.priority-bar[data-priority="media"] {
  box-shadow: 3px 0 12px -2px rgba(241, 196, 15, 0.6);
}
.priority-bar[style*="var(--priority-alta)"],
.priority-bar[data-priority="alta"] {
  box-shadow: 3px 0 12px -2px rgba(230, 126, 34, 0.6);
}
.priority-bar[style*="var(--priority-urgente)"],
.priority-bar[data-priority="urgente"] {
  box-shadow: 3px 0 12px -2px rgba(231, 76, 60, 0.6);
  animation: pulse-border 2s infinite;
}

/* Cards urgentes: top border gradient + animated card glow */
.kanban-card:has(.priority-bar[data-priority="urgente"]),
.kanban-card:has(.priority-urgent) {
  border-top: 1px solid;
  border-image: linear-gradient(90deg, rgba(231,76,60,.8), transparent) 1;
  animation: urgent-card-pulse 3s ease-in-out infinite;
}

/* ── 5. Calendario con semántica visual ─────────────────────────── */
.calendar-day {
  border-radius: 10px;
  transition: background-color 0.2s, box-shadow 0.2s;
}

/* Día actual — doble ring */
.calendar-day.today {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  box-shadow: inset 0 0 0 1px var(--accent), 0 0 16px rgba(74,146,106,.15);
}

/* Días pasados — recesión visual */
.calendar-day.past {
  opacity: 0.45;
  filter: saturate(0.6);
}

/* Dots más grandes con glow */
.ticket-dot {
  width: 10px;
  height: 10px;
  box-shadow: 0 0 6px currentColor;
}

/* ── 6. Focus states y affordances de input ─────────────────────── */
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  box-shadow: 0 0 0 3px rgba(74,146,106,.2), 0 0 0 1px var(--accent);
}

.input-row input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(74,146,106,.2), 0 0 0 1px var(--accent);
}

/* btn-primary glow */
.btn-primary {
  box-shadow: 0 4px 14px rgba(74,146,106,.35);
  transition: background-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(74,146,106,.5);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 2px 8px rgba(74,146,106,.25);
  transition-duration: 80ms;
}

/* ── 7. Backdrop-filter surfaces (desktop only) ─────────────────── */
@media (min-width: 769px) {
  .navbar {
    background-color: rgba(0,0,0,0); /* transparent to let backdrop show */
    backdrop-filter: blur(12px) saturate(1.4);
    -webkit-backdrop-filter: blur(12px) saturate(1.4);
  }
  html.dark .navbar {
    background-color: rgba(26, 58, 26, 0.85);
  }
  html.light .navbar {
    background-color: rgba(255, 255, 255, 0.85);
  }

  .tickets-header {
    backdrop-filter: blur(12px) saturate(1.4);
    -webkit-backdrop-filter: blur(12px) saturate(1.4);
  }
  html.dark .tickets-header {
    background-color: rgba(26, 58, 26, 0.85);
  }
  html.light .tickets-header {
    background-color: rgba(255, 255, 255, 0.85);
  }
}

/* Mobile: navbar sí tiene backdrop (elemento estático), tickets-header no */
@media (max-width: 768px) {
  .navbar {
    backdrop-filter: blur(12px) saturate(1.4);
    -webkit-backdrop-filter: blur(12px) saturate(1.4);
  }
  html.dark .navbar  { background-color: rgba(26, 58, 26, 0.95); }
  html.light .navbar { background-color: rgba(255, 255, 255, 0.95); }

  /* tickets-header: fallback sin backdrop en mobile */
  html.dark .tickets-header  { background-color: rgba(26, 58, 26, 0.98); }
  html.light .tickets-header { background-color: rgba(255, 255, 255, 0.98); }
}

/* Navbar bottom border gradient */
.navbar {
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(90deg, transparent, var(--border-color), transparent) 1;
}

/* ── 8. Typing indicator — animated dots ────────────────────────── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-style: normal;
  min-height: 28px;
}

/* Hide the old text span, show dots instead */
.typing-indicator > span {
  display: none;
}

/* Three animated dots injected via pseudo on the indicator itself */
.typing-indicator::before {
  content: '';
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

/* Use a wrapper approach — override with actual dot spans via CSS */
.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  margin-left: 4px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent);
  opacity: 0.4;
  animation: typing-bounce 1.4s ease-in-out infinite;
  display: inline-block;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.30s; }

/* Typing name label */
.typing-name {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* ── 9. Pinned message — identidad visual ───────────────────────── */
.pinned-message {
  border-left: 3px solid var(--accent);
  box-shadow: inset 4px 0 12px rgba(74,146,106,.08);
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--panel-hover) 90%, #4a926a 10%) 0px,
    color-mix(in srgb, var(--panel-hover) 90%, #4a926a 10%) 40px,
    var(--panel-hover) 200px
  );
  border-bottom: 1px solid var(--border-color);
}

/* ── 10. Reaction pills — glass effect ──────────────────────────── */
.reaction-pill {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  background-color: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.2s, border-color 0.2s;
}
html.light .reaction-pill {
  background-color: rgba(0,0,0,.04);
  border-color: rgba(0,0,0,.1);
}
.reaction-pill:hover {
  transform: scale(1.08);
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(74,146,106,.2);
}
.reaction-pill:active {
  transform: scale(0.95);
  transition-duration: 80ms;
}

/* Tags — letter-spacing y borde translúcido */
.tag {
  letter-spacing: 0.05em;
  border: 1px solid rgba(255,255,255,.12);
  transition: border-color 0.15s;
}
html.light .tag {
  border-color: rgba(0,0,0,.1);
}

/* ── 11. Mobile adaptations ─────────────────────────────────────── */
@media (max-width: 768px) {
  /* Sombras Z3/Z4 simplificadas en mobile */
  .navbar {
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
  }
  .modal-content {
    box-shadow: 0 8px 24px rgba(0,0,0,.4);
  }

  /* Calendario: border-radius y dots más chicos */
  .calendar-day {
    border-radius: 6px;
  }
  .ticket-dot {
    width: 8px;
    height: 8px;
    box-shadow: none; /* disable glow — aliasing en pantallas variables */
  }

  /* Hover → active en touch (más honesto) */
  .kanban-card:hover {
    transform: none;
    box-shadow: 0 1px 2px rgba(0,0,0,.3), 0 2px 6px rgba(0,0,0,.15),
                inset 0 1px 0 rgba(255,255,255,.04);
  }
  .kanban-card:active {
    transform: scale(0.97);
    transition: transform 80ms, box-shadow 80ms;
  }
  .btn-primary:hover {
    transform: none;
    box-shadow: 0 4px 14px rgba(74,146,106,.35);
  }
  .btn-primary:active {
    transform: scale(0.97);
    transition-duration: 80ms;
  }
  .reaction-pill:hover {
    transform: none;
  }
  .reaction-pill:active {
    transform: scale(0.95);
  }
  .filter-btn:hover {
    background-color: transparent;
  }
  .filter-btn:active {
    background-color: var(--panel-hover);
    transform: scale(0.97);
    transition: transform 80ms;
  }

  /* will-change solo durante drag en mobile */
  .kanban-card {
    will-change: auto;
  }
  .kanban-card.dragging {
    will-change: transform;
  }
}

