/*
 * Allocations Component Styles
 * Styles for team member allocation management
 */

@layer components {
  /* ==========================================================================
     Allocation List
     ========================================================================== */

  .allocations-list {
    margin-block-start: var(--space-4);
  }

  .allocation-row.allocation-status-ended {
    opacity: 0.6;
  }

  .allocation-row.allocation-status-future {
    background: var(--color-surface-alt, oklch(0.97 0 0));
  }

  .team-member-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
  }

  .team-member-info .text-muted {
    font-size: var(--text-sm);
  }

  .allocation-percentage {
    font-weight: var(--font-semibold);
    font-size: var(--text-lg);
  }

  .allocation-hours {
    color: var(--color-ink-muted);
  }

  .allocation-dates {
    font-size: var(--text-sm);
  }

  .allocation-notes-row td {
    padding-block-start: 0;
    border-top: none;
  }

  .allocation-notes {
    font-size: var(--text-sm);
    color: var(--color-ink-muted);
    padding-inline-start: var(--space-4);
    border-inline-start: 2px solid var(--color-border-muted);
  }

  /* ==========================================================================
     Allocation Form
     ========================================================================== */

  .allocation-form {
    max-width: 600px;
  }

  .form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
  }

  .capacity-preview {
    background: var(--color-surface-alt, oklch(0.97 0 0));
    border: 1px solid var(--color-border);
    padding: var(--space-4);
  }

  .capacity-preview h2 {
    margin-block-end: var(--space-3);
  }

  /* ==========================================================================
     Status Badges for Allocations
     ========================================================================== */

  .status-active {
    background: var(--color-positive-subtle, oklch(0.95 0.05 150));
    color: var(--color-positive);
  }

  .status-future {
    background: var(--color-info-subtle, oklch(0.95 0.05 250));
    color: var(--color-info, oklch(0.55 0.15 250));
  }

  .status-ended {
    background: var(--color-surface-alt, oklch(0.9 0 0));
    color: var(--color-ink-muted);
  }

  /* Solid warning badge for conflict indicators */
  .badge-warning.badge-solid {
    background: var(--color-warning);
    color: white;
    box-shadow: none;
    font-size: var(--text-xs);
    padding: 0.1em 0.4em;
    border: 1px solid var(--color-border);
    margin-inline-start: var(--space-2);
  }

  /* ==========================================================================
     Conflict Resolution Modal
     ========================================================================== */

  .conflict-list {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    margin-bottom: var(--space-3);
  }

  .conflict-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-border);
  }



  .conflict-dates {
    font-size: var(--text-sm);
  }

  .conflict-percentage {
    font-weight: var(--font-semibold);
  }

  /* New allocation info box - stacked layout */
  .conflict-new-allocation {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
  }

  .conflict-new-allocation strong {
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: 0.025em;
  }

  .conflict-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
  }

  .conflict-action-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
  }

  .conflict-action-help {
    font-size: var(--text-xs);
    color: var(--color-ink-muted);
    text-align: center;
    margin: 0;
  }

  /* Make buttons full width in conflict actions */
  .conflict-actions .btn-block {
    width: 100%;
    justify-content: center;
  }

  /* Icon spacing in buttons */
  .conflict-actions .btn svg {
    margin-inline-end: var(--space-2);
  }

  /* ==========================================================================
     Work Item Allocations
     ========================================================================== */

  .allocation-table-container {
    margin-block-start: var(--space-4);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .allocation-table {
    inline-size: 100%;
    table-layout: fixed;
    border: 1px solid var(--color-border);
    box-shadow: var(--rd-shadow-sm, 0 1px 3px rgb(0 0 0 / 0.1));
    background-color: var(--color-surface);
    margin-block-end: 0;
    border-collapse: collapse;

    /* Dark header like other tables */
    & thead {
      & tr {
        background: #111827;
        color: white;
      }
    }

    & th {
      padding: var(--space-3) var(--space-4);
      font-weight: var(--font-bold);
      font-size: var(--text-sm);
      text-transform: uppercase;
      letter-spacing: 0.025em;
      text-align: left;
    }

    & tbody td {
      padding: var(--space-3) var(--space-4);
      border-block-start: 2px solid var(--color-border);
      font-size: var(--text-sm);
    }

    & tbody tr:first-child td {
      border-block-start: none;
    }

      }

  .allocation-total-bar {
    padding: var(--space-3) var(--space-4);
    font-weight: var(--font-bold);
    font-size: var(--text-sm);
    background: light-dark(oklch(0.92 0.01 286), oklch(0.23 0.01 286));
    border: 1px solid var(--color-border);
    border-block-start: none;
    box-shadow: var(--rd-shadow-sm, 0 1px 3px rgb(0 0 0 / 0.1));
  }

  .allocation-row {
    transition: background-color 0.15s ease;

    &:hover {
      /* Amber in light mode, gray-700 in dark mode */
      background-color: light-dark(#FEF3C7, #374151);
    }
  }

  .allocation-member {
    & .avatar-with-name {
      display: flex;
      align-items: center;
      gap: var(--space-2);
    }

    & .member-name {
      font-weight: var(--font-semibold);
    }
  }

  .allocation-hours,
  .allocation-percentage {
    inline-size: 140px;

    & .input-with-suffix {
      inline-size: 100%;
      display: flex;
      align-items: flex-start;
    }

    & input {
      flex: 1;
      inline-size: auto;
      padding: var(--space-2) var(--space-2_5);
      border: 1px solid var(--color-border);
      font-size: var(--text-sm);
      font-weight: var(--font-medium);
      background-color: var(--color-surface);
      color: var(--color-ink);
      box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
      transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;

      &:focus {
        outline: none;
        border-color: var(--rd-info);
        transform: translate(-1px, -1px);
        box-shadow: 0 1px 3px rgb(0 0 0 / 0.10);
      }

      &::placeholder {
        color: var(--color-ink-faint);
        font-weight: var(--font-normal);
      }
    }

    & .input-suffix {
      position: relative;
      z-index: 1;
      padding: var(--space-2) var(--space-2);
      margin-inline-start: -2px;
      background: var(--rd-warn);
      border: 1px solid var(--color-border);
      font-size: var(--text-xs);
      font-weight: var(--font-bold);
      color: black;
      box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
      display: flex;
      align-items: center;
      height: 100%;
    }
  }

  .allocation-appetite {
    inline-size: 160px;

    & select {
      inline-size: 100%;
      padding: var(--space-2) var(--space-2_5);
      padding-inline-end: var(--space-8);
      border: 1px solid var(--color-border);
      font-size: var(--text-sm);
      font-weight: var(--font-medium);
      background-color: var(--color-surface);
      color: var(--color-ink);
      box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
      transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
      cursor: pointer;
      appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right var(--space-2) center;
      background-size: 14px;

      &:focus {
        outline: none;
        border-color: var(--rd-info);
        transform: translate(-1px, -1px);
        box-shadow: 0 1px 3px rgb(0 0 0 / 0.10);
      }
    }
  }

  .allocation-total-value {
    font-size: var(--text-base);
    font-weight: var(--font-bold);
    color: var(--color-ink);
  }

  .allocation-warning {
    margin-block-start: var(--space-3);
  }

  .allocation-info {
    margin-block-start: var(--space-3);
  }

  /* ==========================================================================
     Workload Grid Allocation Indicators
     ========================================================================== */

  .workload-cell-split {
    position: relative;

    &::after {
      content: "";
      position: absolute;
      inset-block-start: 2px;
      inset-inline-end: 2px;
      inline-size: 0;
      block-size: 0;
      border-style: solid;
      border-inline-start-width: 10px;
      border-block-start-width: 10px;
      border-inline-end-width: 0;
      border-block-end-width: 0;
      border-inline-start-color: transparent;
      border-block-start-color: var(--rd-accent);
    }
  }

  .workload-item-split {
    display: flex;
    align-items: center;
    gap: var(--space-1);

    & .split-indicator {
      font-size: var(--text-xs);
      font-weight: var(--font-bold);
      color: var(--rd-accent);
      padding: 0 var(--space-1);
      background-color: var(--rd-accent-soft);
      border: 1px solid var(--rd-accent);
      line-height: 1.2;
    }
  }

  /* ==========================================================================
     Allocation Badge (for work item cards and lists)
     ========================================================================== */

  .allocation-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    padding: var(--space-0_5) var(--space-2);
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);

    &--split {
      background-color: var(--rd-accent-soft);
      color: var(--rd-accent);
    }

    &--custom {
      background-color: var(--rd-warn-soft);
      color: oklch(0.70 0.18 45);
    }

    & svg {
      flex-shrink: 0;
    }
  }
}
