/* ─────────────────────────────────────────────────────────────────────────────
   components.css
   Reusable UI components: buttons, inputs, cards, badges, avatars, modals.
   These styles are used throughout the entire app, on every page.
───────────────────────────────────────────────────────────────────────────── */


/* ── Buttons ─────────────────────────────────────────────────────────────── */

/* Base button — shared styles that all button variants inherit */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: var(--radius-full);   /* pill shape */
  border: none;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition:
    background-color var(--transition-base),
    color var(--transition-base),
    transform var(--transition-fast),
    box-shadow var(--transition-base),
    opacity var(--transition-base);
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.97);
}

/* Disabled state for all buttons */
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Loading state — shows a spinner inside the button */
.btn.loading {
  opacity: 0.8;
  cursor: wait;
  pointer-events: none;
}

/* ── Primary button (solid blue) ── */
.btn-primary {
  background-color: var(--color-primary);
  color: white;
  box-shadow: 0 1px 3px rgba(0, 113, 227, 0.3);
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.4);
}

/* ── Secondary button (ghost / outlined) ── */
.btn-secondary {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background-color: rgba(0, 0, 0, 0.08);
}

/* ── Destructive button (for delete / sign out) ── */
.btn-danger {
  background-color: var(--color-error);
  color: white;
}

.btn-danger:hover {
  background-color: #e0352b;
}

/* ── Ghost button (no background, just text) ── */
.btn-ghost {
  background-color: transparent;
  color: var(--color-primary);
  padding: 10px 16px;
}

.btn-ghost:hover {
  background-color: var(--color-primary-light);
}

/* ── Small button variant ── */
.btn-sm {
  padding: 8px 14px;
  font-size: var(--font-size-sm);
}

/* ── Large button variant ── */
.btn-lg {
  padding: 16px 28px;
  font-size: var(--font-size-md);
}

/* ── Full width button ── */
.btn-full {
  width: 100%;
}

/* ── Icon button (square, no label) ── */
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background-color var(--transition-base), color var(--transition-base);
}

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


/* ── Form Inputs ─────────────────────────────────────────────────────────── */

.input {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.9);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  outline: none;
  transition:
    border-color var(--transition-base),
    box-shadow var(--transition-base),
    background-color var(--transition-base);
  /* Prevents zooming on focus on iOS (input font size must be 16px+ to prevent this) */
  font-size: 16px;
}

.input::placeholder {
  color: var(--color-text-tertiary);
}

.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
  background: white;
}

.input.error {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.12);
}

.input:disabled {
  background: rgba(0, 0, 0, 0.04);
  color: var(--color-text-tertiary);
  cursor: not-allowed;
}

/* Textarea (multi-line input) */
textarea.input {
  resize: vertical;
  min-height: 100px;
  line-height: var(--line-height-normal);
}

/* Form field group (label + input + hint) */
.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

.form-error {
  font-size: var(--font-size-xs);
  color: var(--color-error);
}

/* Character counter (used in custom status input) */
.char-counter {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
  text-align: right;
}

.char-counter.near-limit {
  color: var(--color-warning);
}

.char-counter.at-limit {
  color: var(--color-error);
}


/* ── Cards ───────────────────────────────────────────────────────────────── */

/* Base card — used for all content containers */
.card {
  background: var(--color-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-card-border);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
  transition: box-shadow var(--transition-base);
}

/* Clickable card — adds hover state */
.card.card-clickable {
  cursor: pointer;
}

.card.card-clickable:hover {
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.12);
}

/* Card header (title row inside a card) */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.card-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

/* Stat card — compact card for showing a single metric */
.stat-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
}

.stat-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-card-icon.blue {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.stat-card-icon.green {
  background: var(--color-success-light);
  color: var(--color-success);
}

.stat-card-icon.orange {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.stat-card-icon.red {
  background: var(--color-error-light);
  color: var(--color-error);
}

.stat-card-info {
  flex: 1;
  min-width: 0;
}

.stat-card-value {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ── Badges / Status Pills ───────────────────────────────────────────────── */

/* Base badge style */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  line-height: 1.4;
  white-space: nowrap;
}

/* Badge color variants */
.badge-blue {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.badge-green {
  background: var(--color-success-light);
  color: var(--color-success);
}

.badge-orange {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.badge-red {
  background: var(--color-error-light);
  color: var(--color-error);
}

.badge-gray {
  background: rgba(0, 0, 0, 0.06);
  color: var(--color-text-secondary);
}

/* Task status badges */
.badge-todo        { background: rgba(0,0,0,0.06); color: var(--color-text-secondary); }
.badge-in-progress { background: var(--color-primary-light); color: var(--color-primary); }
.badge-blocked     { background: var(--color-error-light); color: var(--color-error); }
.badge-done        { background: var(--color-success-light); color: var(--color-success); }


/* ── Avatar ──────────────────────────────────────────────────────────────── */

/* Container — always circular */
.avatar {
  border-radius: var(--radius-round);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-semibold);
  color: white;
  line-height: 1;
  /* Background color is set dynamically by JavaScript based on the user's name */
  background-color: var(--color-primary);
  position: relative;
}

/* Avatar size variants */
.avatar-sm  { width: 28px; height: 28px; font-size: 11px; }
.avatar-md  { width: 40px; height: 40px; font-size: 15px; }
.avatar-lg  { width: 56px; height: 56px; font-size: 20px; }
.avatar-xl  { width: 80px; height: 80px; font-size: 28px; }

/* Avatar photo (when the user has uploaded an image) */
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-round);
}

/* Status dot indicator on avatar */
.avatar-wrapper {
  position: relative;
  display: inline-flex;
}

.status-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-round);
  border: 2px solid white;
}

.status-dot.available  { background-color: var(--status-available); }
.status-dot.busy       { background-color: var(--status-busy); }
.status-dot.inMeeting  { background-color: var(--status-meeting); }
.status-dot.custom     { background-color: var(--status-custom); }

/* Larger status dot for the sidebar user block */
.status-dot-lg {
  width: 12px;
  height: 12px;
  border-width: 2px;
}


/* ── Divider ─────────────────────────────────────────────────────────────── */

.divider {
  height: 1px;
  background: var(--color-divider);
  border: none;
  margin: var(--space-4) 0;
}


/* ── Modal ───────────────────────────────────────────────────────────────── */

/* Dark overlay behind the modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

/* The modal box itself */
.modal {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-slow);
}

.modal-overlay.visible .modal {
  transform: scale(1) translateY(0);
}

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

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
}

.modal-body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-divider);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* On mobile, modals slide up from the bottom instead of appearing centered */
@media (max-width: 767px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    border-radius: 24px 24px 0 0;
    max-width: 100%;
    transform: translateY(100%);
    margin: 0;
  }

  .modal-overlay.visible .modal {
    transform: translateY(0);
  }
}


/* ── Toast Notification ──────────────────────────────────────────────────── */
/* A temporary message that appears at the top of the screen and auto-dismisses */

.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  background: rgba(29, 29, 31, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  animation: toastIn 300ms ease, toastOut 300ms ease 2.7s forwards;
  pointer-events: all;
}

.toast.toast-success i { color: var(--color-success); }
.toast.toast-error   i { color: var(--color-error); }
.toast.toast-warning i { color: var(--color-warning); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-8px); }
}


/* ── Notification Bell ───────────────────────────────────────────────────── */

.notification-bell-wrapper {
  position: relative;
  display: inline-flex;
}

.notification-badge {
  position: absolute;
  top: -2px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  background: var(--color-error);
  border-radius: var(--radius-full);
  color: white;
  font-size: 9px;
  font-weight: var(--font-weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid white;
  line-height: 1;
}


/* ── File Upload Area ────────────────────────────────────────────────────── */

.file-upload-area {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-5);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition-base), background-color var(--transition-base);
}

.file-upload-area:hover,
.file-upload-area.drag-over {
  border-color: var(--color-primary);
  background-color: var(--color-primary-light);
}

.file-upload-area input[type="file"] {
  display: none; /* The actual input is hidden; clicking the area triggers it */
}

.file-upload-icon {
  font-size: 36px;
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-3);
}

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

.file-upload-text strong {
  color: var(--color-primary);
}


/* ── Status Selector ─────────────────────────────────────────────────────── */
/* Horizontal row of status option buttons in the profile panel */

.status-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}

.status-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border);
  background: transparent;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  transition: all var(--transition-base);
}

.status-option:hover {
  background: rgba(0, 0, 0, 0.03);
}

.status-option.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: var(--font-weight-medium);
}

.status-option .status-dot {
  position: static; /* override the absolute position used on avatars */
  width: 8px;
  height: 8px;
  border: none;
}


/* ── Section Placeholder ─────────────────────────────────────────────────── */
/* Used for sections not yet implemented (Tasks, Projects, etc.) */

.placeholder-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  gap: var(--space-4);
  padding: var(--space-8);
}

.placeholder-icon {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-xl);
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.placeholder-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
}

.placeholder-description {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  max-width: 320px;
  line-height: var(--line-height-normal);
}

.placeholder-phase {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--color-text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}


/* ── Dashboard Greeting ──────────────────────────────────────────────────── */

.dashboard-greeting {
  margin-bottom: var(--space-6);
}

.greeting-text {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.5px;
  color: var(--color-text-primary);
  line-height: var(--line-height-tight);
}

.greeting-date {
  font-size: var(--font-size-md);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
  font-weight: var(--font-weight-regular);
}


/* ── Task List Item ──────────────────────────────────────────────────────── */

.task-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-divider);
}

.task-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.task-item-info {
  flex: 1;
  min-width: 0;
}

.task-item-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-item-meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
  margin-top: 2px;
}

.task-item-overdue .task-item-name {
  color: var(--color-error);
}
