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

:root {
  --bg: #0f1117;
  --bg-surface: #1a1d27;
  --bg-card: #232733;
  --bg-hover: #2a2e3d;
  --border: #2e3348;
  --text: #e1e4ed;
  --text-muted: #8b90a5;
  --accent: #6c5ce7;
  --accent-hover: #7c6ef7;
  --danger: #e74c3c;
  --success: #2ecc71;
  --warning: #f39c12;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---- AUTH SCREEN ---- */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.auth-box h1 {
  text-align: center;
  margin-bottom: 8px;
  font-size: 1.6rem;
}

.auth-box .subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
}

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

.btn-danger:hover {
  background: #c0392b;
}

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

.auth-toggle {
  text-align: center;
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.auth-toggle a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}

.auth-toggle a:hover {
  text-decoration: underline;
}

.auth-error {
  background: rgba(231,76,60,0.15);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: #e74c3c;
  display: none;
}

/* ---- HEADER ---- */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header h1 .logo-icon {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

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

.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-bar select {
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

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

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-card);
  border-radius: 8px;
  font-size: 0.85rem;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.avatar-sm {
  width: 22px;
  height: 22px;
  font-size: 0.65rem;
}

/* ---- BOARD ---- */
.board {
  display: flex;
  gap: 20px;
  padding: 24px;
  overflow-x: auto;
  min-height: calc(100vh - 60px);
  align-items: flex-start;
}

.column {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 100px);
}

.column-header {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.column-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.column-count {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.add-task-header-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.add-task-header-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.1);
}

.column-tasks {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 60px;
}

.column-tasks.drag-over {
  background: rgba(108,92,231,0.08);
  border-radius: 0 0 12px 12px;
}

/* ---- TASK CARDS ---- */
.task-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: grab;
  transition: all 0.2s;
  position: relative;
}

.task-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(108,92,231,0.15);
}

.task-card.dragging {
  opacity: 0.4;
  transform: rotate(2deg);
}

/* Card inner with color stripe */
.task-card-inner {
  border-radius: 6px;
}

/* Main layout: left content + right icons column */
.task-card-layout {
  display: flex;
  gap: 10px;
}

.task-card-left {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 0;
}

.task-card-left.has-thumb {
  gap: 10px;
}

.task-thumb {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  align-self: flex-start;
}

.task-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.15s;
}

.task-thumb:hover img {
  transform: scale(1.08);
}

.task-card-content {
  flex: 1;
  min-width: 0;
}

.task-title-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.task-card .task-title {
  font-size: 0.9rem;
  font-weight: 500;
  word-break: break-word;
}

.task-title-row .task-expand-btn {
  align-self: center;
  flex-shrink: 0;
}

.task-card .task-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.4;
  margin-top: 4px;
}

.task-card .task-desc.collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Right column: avatars, expand, attachments stacked */
.task-card-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.task-expand-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  margin: -4px -4px -4px 0;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.task-expand-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.task-expand-btn svg {
  transition: transform 0.2s;
}

.task-expand-btn.expanded svg {
  transform: rotate(180deg);
}

.task-avatars {
  display: flex;
  align-items: center;
}

.task-avatars .avatar {
  margin-left: -4px;
  border: 2px solid var(--bg-card);
}

.task-avatars .avatar:first-child {
  margin-left: 0;
}

.task-attachment-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Drop image highlight on card */
.task-card.drop-image {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(108,92,231,0.3), 0 2px 12px rgba(108,92,231,0.2);
  background: rgba(108,92,231,0.06);
}


/* Add task button (bottom) */
.add-task-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  margin: 0 12px 12px 12px;
  width: calc(100% - 24px);
}

.add-task-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(108,92,231,0.05);
}

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(4px);
}

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

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

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

.modal-header h2 {
  font-size: 1.1rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 24px;
}

.modal-body .form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.2s;
}

.modal-body .form-group textarea:focus {
  border-color: var(--accent);
}

.modal-body .form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
}

.modal-body .form-group select:focus {
  border-color: var(--accent);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Attachments in modal */
.attachments-section {
  margin-top: 16px;
}

.attachments-section h3 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.attachment-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.attachment-item {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.attachment-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-item .att-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.7);
  border: none;
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.7rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.attachment-item:hover .att-delete {
  display: flex;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-zone:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.upload-zone.drag-active {
  border-color: var(--accent);
  background: rgba(108,92,231,0.05);
}

/* ---- GALLERY ---- */
.gallery-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  flex-direction: column;
  gap: 16px;
}

.gallery-overlay.hidden {
  display: none;
}

.gallery-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  z-index: 10;
  line-height: 1;
}

.gallery-close:hover {
  opacity: 1;
}

.gallery-body {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 32px;
  width: min(1400px, 86vw);
  max-height: 75vh;
}

.gallery-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-height: 75vh;
  flex: 1 1 auto;
  min-width: 0;
}

.gallery-main img {
  max-width: 100%;
  max-height: 68vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  object-fit: contain;
  user-select: none;
}

.gallery-info {
  flex: 0 0 340px;
  max-width: 340px;
  max-height: 68vh;
  overflow-y: auto;
  color: rgba(255,255,255,0.92);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 20px 22px;
  backdrop-filter: blur(6px);
}

.gallery-info.hidden {
  display: none;
}

.gallery-info-title {
  margin: 0 0 14px 0;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.35;
  color: #fff;
  word-wrap: break-word;
}

.gallery-info-desc {
  font-size: 0.9rem;
  line-height: 1.55;
  color: rgba(255,255,255,0.78);
  white-space: pre-wrap;
  word-wrap: break-word;
}

@media (max-width: 900px) {
  .gallery-body {
    flex-direction: column;
    gap: 12px;
  }
  .gallery-main img { max-width: 90vw; max-height: 50vh; }
  .gallery-info { max-width: 90vw; max-height: 25vh; flex-basis: auto; }
}

.gallery-counter {
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 10;
}

.gallery-nav:hover {
  background: rgba(255,255,255,0.25);
}

.gallery-prev { left: 20px; }
.gallery-next { right: 20px; }

.gallery-thumbs {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 85vw;
}

.gallery-thumb {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0.5;
  transition: all 0.2s;
}

.gallery-thumb:hover {
  opacity: 0.8;
}

.gallery-thumb.active {
  border-color: var(--accent);
  opacity: 1;
}

/* Make attachment count clickable */
.task-attachment-count {
  cursor: pointer;
}

.task-attachment-count:hover {
  color: var(--accent);
}

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

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Column color indicators */
.col-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.col-todo .col-indicator { background: var(--warning); }
.col-inprogress .col-indicator { background: var(--accent); }
.col-done .col-indicator { background: var(--success); }

/* ---- ADMIN PANEL ---- */
.admin-user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}

.admin-user-row .avatar {
  flex-shrink: 0;
}

.admin-user-info {
  flex: 1;
  min-width: 0;
}

.admin-user-info .name {
  font-size: 0.9rem;
  font-weight: 500;
}

.admin-user-info .username {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.admin-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  flex-shrink: 0;
}

.color-picker {
  width: 32px;
  height: 32px;
  padding: 1px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  cursor: pointer;
  flex-shrink: 0;
}

.color-picker::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.admin-user-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.admin-user-actions button {
  padding: 4px 10px;
  font-size: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.admin-user-actions button:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.admin-user-actions button.delete-user-btn:hover {
  background: rgba(231,76,60,0.15);
  color: var(--danger);
  border-color: var(--danger);
}
