/* ============================================================
   TaskBoard — Custom CSS
   Complements Tailwind CSS for Trello-style interactions
   ============================================================ */

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
:root {
  --primary: #0052CC;
  --primary-light: #0065FF;
  --secondary: #172B4D;
  --success: #00875A;
  --warning: #FF8B00;
  --danger: #DE350B;
  --bg: #F0F2F5;
  --card-bg: #FFFFFF;
  --list-bg: #EBECF0;
  --border: #DFE1E6;
  --text: #172B4D;
  --text-muted: #6B778C;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(9,30,66,.12), 0 0 0 1px rgba(9,30,66,.08);
  --shadow-hover: 0 4px 8px rgba(9,30,66,.2), 0 0 0 1px rgba(9,30,66,.08);
  --shadow-dragging: 0 8px 24px rgba(9,30,66,.3);
}

body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #C1C7D0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #97A0AF; }

/* ============================================================
   NAVBAR
   ============================================================ */
#navbar {
  background: var(--secondary);
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 2px 4px rgba(0,0,0,.3);
}
#navbar .nav-logo {
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
#navbar .nav-logo i { color: #0065FF; }
#navbar .nav-spacer { flex: 1; }
#navbar .nav-btn {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background .15s;
  text-decoration: none;
}
#navbar .nav-btn:hover { background: rgba(255,255,255,.25); text-decoration: none; }
#navbar .nav-user {
  color: rgba(255,255,255,.85);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary-light);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
#sidebar {
  width: 260px;
  background: #fff;
  border-right: 1px solid var(--border);
  height: calc(100vh - 48px);
  position: fixed;
  top: 48px;
  left: 0;
  overflow-y: auto;
  z-index: 20;
  transition: transform .2s;
  padding: 16px 0;
}
#sidebar.hidden-mobile { transform: translateX(-100%); }
.sidebar-section { padding: 0 8px; margin-bottom: 8px; }
.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 8px 8px 4px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  transition: background .15s;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.sidebar-item:hover { background: var(--list-bg); text-decoration: none; }
.sidebar-item.active { background: #E3EDFF; color: var(--primary); font-weight: 600; }
.sidebar-item i { width: 16px; text-align: center; opacity: .7; }
.sidebar-item.active i { opacity: 1; color: var(--primary); }

/* Main content offset */
#main-content {
  margin-left: 260px;
  padding: 24px;
  min-height: calc(100vh - 48px);
  transition: margin-left .2s;
}

/* ============================================================
   BOARD LIST / DASHBOARD
   ============================================================ */
.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.board-card {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform .15s, box-shadow .15s;
  position: relative;
  overflow: hidden;
}
.board-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.1) 0%, transparent 60%);
}
.board-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,82,204,.4); }
.board-card h3 { font-size: 16px; font-weight: 700; margin: 0; position: relative; }
.board-card p { font-size: 12px; opacity: .8; margin: 4px 0 0; position: relative; }
.board-card-meta { font-size: 11px; opacity: .7; position: relative; }

.board-card-new {
  background: #fff !important;
  border: 2px dashed var(--border);
  color: var(--text-muted) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
}
.board-card-new:hover { border-color: var(--primary); color: var(--primary) !important; background: #F0F4FF !important; }

/* Board color variants */
.board-color-0 { background: #0052CC; }
.board-color-1 { background: #00875A; }
.board-color-2 { background: #6554C0; }
.board-color-3 { background: #FF5630; }
.board-color-4 { background: #00B8D9; }
.board-color-5 { background: #FF8B00; }
.board-color-6 { background: #36B37E; }
.board-color-7 { background: #5243AA; }

/* ============================================================
   BOARD VIEW — KANBAN COLUMNS
   ============================================================ */
#board-view {
  display: flex;
  gap: 12px;
  padding: 16px;
  overflow-x: auto;
  align-items: flex-start;
  min-height: calc(100vh - 96px);
}
#board-view::-webkit-scrollbar { height: 8px; }

.kanban-column {
  background: var(--list-bg);
  border-radius: var(--radius);
  width: 272px;
  min-width: 272px;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.column-header {
  padding: 12px 12px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.column-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  flex: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  border: 2px solid transparent;
}
.column-title:hover { background: rgba(9,30,66,.08); }
.column-title-input {
  font-weight: 700;
  font-size: 14px;
  border: 2px solid var(--primary);
  border-radius: 4px;
  padding: 2px 4px;
  outline: none;
  flex: 1;
  background: #fff;
}
.column-count {
  background: rgba(9,30,66,.12);
  color: var(--text-muted);
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 10px;
}
.column-menu-btn {
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 6px;
  border-radius: 4px;
  transition: opacity .15s, background .15s;
  font-size: 14px;
}
.column-header:hover .column-menu-btn { opacity: 1; }
.column-menu-btn:hover { background: rgba(9,30,66,.12); color: var(--text); }

.column-cards {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
  min-height: 40px;
}
.column-cards.drag-over {
  background: rgba(0,82,204,.06);
  border-radius: 6px;
}
.column-add-card {
  padding: 4px 8px 8px;
}
.add-card-btn {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background .15s, color .15s;
}
.add-card-btn:hover { background: rgba(9,30,66,.08); color: var(--text); }

/* ============================================================
   TASK CARDS
   ============================================================ */
.task-card {
  background: var(--card-bg);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  cursor: grab;
  transition: box-shadow .15s, transform .1s;
  position: relative;
  border-left: 3px solid transparent;
}
.task-card:hover { box-shadow: var(--shadow-hover); }
.task-card.dragging {
  opacity: .5;
  box-shadow: var(--shadow-dragging);
  transform: rotate(2deg);
}
.task-card.drag-placeholder {
  background: rgba(0,82,204,.08);
  border: 2px dashed var(--primary);
  min-height: 60px;
}

/* Priority border colors */
.task-card.priority-Low      { border-left-color: #97A0AF; }
.task-card.priority-Medium   { border-left-color: #FF8B00; }
.task-card.priority-High     { border-left-color: #FF5630; }
.task-card.priority-Critical { border-left-color: #BF2600; }

.card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 8px;
}
.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.badge-priority-Low      { background: #F4F5F7; color: #97A0AF; }
.badge-priority-Medium   { background: #FFF3CD; color: #996400; }
.badge-priority-High     { background: #FFE8E5; color: #BF2600; }
.badge-priority-Critical { background: #BF2600; color: #fff; }
.badge-status-open       { background: #E3EDFF; color: #0052CC; }
.badge-status-in_progress { background: #E3FCEF; color: #006644; }
.badge-status-done       { background: #EBECF0; color: #6B778C; }
.badge-due-overdue       { background: #FFE8E5; color: #BF2600; }
.badge-due-soon          { background: #FFF3CD; color: #996400; }
.badge-due-ok            { background: #E3FCEF; color: #006644; }

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}
.card-assignee {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
}
.card-assignee .avatar {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700;
}
.card-meta-icons {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}
.card-meta-icons span {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Add new column button */
.add-column-btn {
  background: rgba(255,255,255,.5);
  border: none;
  border-radius: var(--radius);
  width: 272px;
  min-width: 272px;
  padding: 12px 16px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background .15s;
  flex-shrink: 0;
  height: 44px;
  align-self: flex-start;
}
.add-column-btn:hover { background: rgba(255,255,255,.75); }

/* Inline add card form */
.add-card-form {
  background: var(--card-bg);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 8px;
}
.add-card-textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-size: 14px;
  font-family: inherit;
  background: transparent;
  min-height: 60px;
  color: var(--text);
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 20px; font-weight: 700; margin: 0; color: var(--text); }
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
  transition: background .15s;
}
.modal-close:hover { background: var(--list-bg); color: var(--text); }
.modal-body { padding: 20px 24px 24px; }

/* Card detail modal */
.card-detail-grid {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 20px;
}
@media (max-width: 640px) { .card-detail-grid { grid-template-columns: 1fr; } }

/* ============================================================
   FORMS & INPUTS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s;
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s, box-shadow .15s;
  text-decoration: none;
  line-height: 1.4;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); box-shadow: 0 4px 12px rgba(0,82,204,.3); }
.btn-secondary { background: var(--list-bg); color: var(--text); }
.btn-secondary:hover { background: #DFE1E6; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #BF2600; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #006644; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--list-bg); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-icon { padding: 6px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ============================================================
   TABLES
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 2px solid var(--border);
  background: #F4F5F7;
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:hover td { background: #FAFBFC; }
.data-table tr:last-child td { border-bottom: none; }

/* ============================================================
   PRIORITY & STATUS BADGES
   ============================================================ */
.priority-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.priority-Low      { background: #F4F5F7; color: #97A0AF; }
.priority-Medium   { background: #FFF3CD; color: #996400; }
.priority-High     { background: #FFE8E5; color: #BF2600; }
.priority-Critical { background: #BF2600; color: #fff; }

.status-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.status-open       { background: #E3EDFF; color: #0052CC; }
.status-in_progress { background: #E3FCEF; color: #006644; }
.status-done       { background: #EBECF0; color: #6B778C; }
.status-archived   { background: #F4F5F7; color: #97A0AF; }

/* Role badge */
.role-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.role-admin    { background: #EAE6FF; color: #403294; }
.role-manager  { background: #E3FCEF; color: #006644; }
.role-user     { background: #E3EDFF; color: #0052CC; }
.role-readonly { background: #F4F5F7; color: #97A0AF; }

/* ============================================================
   ACTIVITY LOG
   ============================================================ */
.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--list-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.activity-content { flex: 1; }
.activity-action { font-weight: 600; color: var(--text); }
.activity-details { color: var(--text-muted); }
.activity-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--secondary);
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  min-width: 280px;
  max-width: 400px;
  animation: slideIn .2s ease;
  font-size: 14px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; transform: translateX(20px); } }
.toast.fade-out { animation: fadeOut .3s ease forwards; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0052CC 0%, #172B4D 100%);
  padding: 24px;
}
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo i { font-size: 40px; color: var(--primary); }
.login-logo h1 { font-size: 24px; font-weight: 800; color: var(--secondary); margin: 8px 0 4px; }
.login-logo p { color: var(--text-muted); font-size: 14px; margin: 0; }

/* ============================================================
   API KEY MANAGEMENT
   ============================================================ */
.apikey-reveal {
  background: #F4F5F7;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-family: monospace;
  font-size: 13px;
  word-break: break-all;
  position: relative;
}
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 8px; }
.perm-checkbox { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.perm-checkbox input { accent-color: var(--primary); width: 14px; height: 14px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #main-content { margin-left: 0; padding: 16px; }
  .board-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  #board-view { padding: 8px; }
  .kanban-column { width: 240px; min-width: 240px; }
}

/* ============================================================
   MISC HELPERS
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.section-title { font-size: 20px; font-weight: 700; color: var(--text); }
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: .4; }
.empty-state h3 { font-size: 18px; margin: 0 0 8px; color: var(--text); }
.empty-state p { margin: 0 0 20px; font-size: 14px; }
.spinner { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.loading-overlay {
  position: absolute; inset: 0;
  background: rgba(255,255,255,.7);
  display: flex; align-items: center; justify-content: center;
  border-radius: inherit;
  z-index: 10;
}
.card-number {
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
}
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* Code block for API key display */
.code-block {
  background: #1E2A3B;
  color: #E6EDF3;
  border-radius: 8px;
  padding: 16px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
}
.inline-code {
  background: #F4F5F7;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: monospace;
  font-size: 12px;
  color: var(--danger);
}
