/* Recruitment module — page-specific styles only.
   Layout, buttons, cards, modals and tables come from styles.css + invoices.css. */

/* ── Tabs ──────────────────────────────────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 20px;
}
.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    font-family: inherit;
}
.tab-btn:hover { color: #1a1a2e; }
.tab-btn.active { color: #1a1a2e; border-bottom-color: #3498db; }
.tab-btn svg { width: 16px; height: 16px; }
.tab-count {
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 600;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Candidate list ────────────────────────────────────────────────────── */
.col-check { width: 36px; }
.col-check input { cursor: pointer; }

.bulk-bar { display: flex; align-items: center; gap: 12px; }

.stage-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
    background: #f3f4f6;
    color: #4b5563;
    white-space: nowrap;
}
.stage-pill.applied     { background: #f3f4f6; color: #4b5563; }
.stage-pill.screening   { background: #ede9fe; color: #5b21b6; }
.stage-pill.assessment  { background: #fef3c7; color: #92400e; }
.stage-pill.interview   { background: #dbeafe; color: #1e40af; }
.stage-pill.offer       { background: #cffafe; color: #155e75; }
.stage-pill.contract    { background: #e0e7ff; color: #3730a3; }
.stage-pill.onboarding  { background: #d1fae5; color: #065f46; }
.stage-pill.active      { background: #bbf7d0; color: #14532d; }
.stage-pill.rejected,
.stage-pill.withdrawn   { background: #fef2f2; color: #991b1b; }

.status-pill.sending { background: #fef3c7; color: #92400e; }
.status-pill.partial { background: #ffedd5; color: #9a3412; }
.status-pill.failed  { background: #fef2f2; color: #991b1b; }

.field-hint { font-size: 11px; color: #6b7280; line-height: 1.5; }
.field-hint code {
    background: #f3f4f6;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 11px;
}
.mono { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 12px; }

/* ── Import review ─────────────────────────────────────────────────────── */
.import-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.import-actions-right { display: flex; gap: 8px; }
.review-wrap { max-height: 340px; overflow-y: auto; }
.review-table input,
.review-table textarea {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    padding: 4px 6px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
}
.review-table input:hover,
.review-table textarea:hover { border-color: #e5e7eb; }
.review-table input:focus,
.review-table textarea:focus { border-color: #3498db; background: #fff; outline: none; }
.review-table tr.needs-attention td { background: #fffbeb; }
.review-table tr.needs-attention input.field-email { border-color: #f59e0b; }

/* ── Campaign builder ──────────────────────────────────────────────────── */
/* The email itself is 600px wide. The preview column is sized so it renders at
   1:1 rather than shrunk, because a scaled-down preview cannot answer "does this
   look right". Below 1280px there is not room for both panes, so the layout
   collapses to one and the header toggle switches between them. */
.modal-builder {
    width: min(1560px, 96vw);
    max-width: 96vw;
    height: 92vh;
    display: flex;
    flex-direction: column;
}
.builder-header-actions { display: flex; align-items: center; gap: 12px; }

.mode-toggle {
    display: flex;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 2px;
}
.mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.mode-btn:hover { color: #1a1a2e; }
.mode-btn.active { background: #ffffff; color: #1a1a2e; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.mode-btn svg { width: 14px; height: 14px; }

.builder {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 664px;
    overflow: hidden;
    border-top: 1px solid #e5e7eb;
}
.builder-left {
    overflow-y: auto;
    padding: 16px 20px;
    border-right: 1px solid #e5e7eb;
}
.builder-right {
    display: flex;
    flex-direction: column;
    background: #eef0f3;
    overflow: hidden;
}

/* Preview mode: the compose pane steps out so the email gets the full width. */
.modal-builder[data-mode="preview"] .builder { grid-template-columns: minmax(0, 1fr); }
.modal-builder[data-mode="preview"] .builder-left { display: none; }

.builder-section {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 12px;
    background: #fff;
}
.builder-section > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #1a1a2e;
    cursor: pointer;
    list-style: none;
}
.builder-section > summary::-webkit-details-marker { display: none; }
.builder-section > summary::before {
    content: '';
    width: 0;
    height: 0;
    border-left: 5px solid #9ca3af;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform 0.15s ease;
}
.builder-section[open] > summary::before { transform: rotate(90deg); }
.builder-section > summary svg { width: 15px; height: 15px; color: #6b7280; }
.builder-section-body { padding: 0 14px 14px 14px; }

.ai-compose-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.ai-compose-bar .form-input { flex: 1; }

.block-editor { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.block-item {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 10px;
    background: #fafbfc;
}
.block-item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.block-type {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #6b7280;
}
.block-item textarea,
.block-item input {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 8px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
}
.block-item textarea:focus,
.block-item input:focus { border-color: #3498db; outline: none; }
.block-item .block-readonly { font-size: 12px; color: #6b7280; font-style: italic; }
.block-kv-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 6px; }

.defaults-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px;
}
.default-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 4px;
}
.default-field .form-input { font-size: 13px; }

.attachment-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.attachment-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
}
.attachment-row .attachment-size { color: #9ca3af; font-size: 11px; }

.recipient-toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
.merge-wrap { max-height: 300px; overflow: auto; }
.merge-table th { white-space: nowrap; }
.merge-table td { vertical-align: top; }
.merge-table input,
.merge-table textarea {
    width: 100%;
    min-width: 130px;
    border: 1px solid transparent;
    background: transparent;
    padding: 4px 6px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 12px;
}
.merge-table input:hover,
.merge-table textarea:hover { border-color: #e5e7eb; }
.merge-table input:focus,
.merge-table textarea:focus { border-color: #3498db; background: #fff; outline: none; }
.merge-table .cell-missing input,
.merge-table .cell-missing textarea { border-color: #ef4444; background: #fef2f2; }
.merge-table tr.row-sent td { background: #f0fdf4; }
.merge-table tr.row-failed td { background: #fef2f2; }
.merge-table .recipient-name { font-weight: 600; white-space: nowrap; }
.merge-table .recipient-email { color: #6b7280; font-size: 11px; }

/* ── Preview pane ──────────────────────────────────────────────────────── */
.preview-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}
.preview-toolbar .form-input-sm {
    flex: 1;
    padding: 6px 8px;
    font-size: 12px;
    min-width: 0;
}
.preview-toggle {
    display: flex;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}
.toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: none;
    background: #fff;
    padding: 6px 12px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.toggle-btn:hover { background: #f9fafb; color: #1a1a2e; }
.toggle-btn.active { background: #1a1a2e; color: #fff; }
.toggle-btn svg { width: 14px; height: 14px; }

.preview-missing {
    padding: 10px 12px;
    background: #fef2f2;
    color: #991b1b;
    font-size: 12px;
    border-bottom: 1px solid #fecaca;
    flex-shrink: 0;
}
.preview-missing[hidden] { display: none; }

.preview-stage {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* The "device": inbox chrome plus the email, sharing one card and one scrollbar.
   Width changes rather than transform: scale, so the email reflows exactly as it
   would in a real client rather than being a shrunken picture of the desktop
   layout. */
.preview-device {
    width: 624px;
    max-width: 100%;
    background: #fff;
    border: 1px solid #dfe3e8;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
    overflow: hidden;
    transition: width 0.2s ease;
}
.preview-stage.mobile .preview-device { width: 414px; }

.inbox-chrome {
    padding: 16px 20px 14px;
    border-bottom: 1px solid #eef0f3;
    background: #fff;
}
.inbox-subject {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a2e;
    line-height: 1.4;
    margin-bottom: 10px;
    word-break: break-word;
}
.inbox-subject:empty::before { content: 'No subject'; color: #c0c5cc; font-weight: 500; }
.inbox-from { display: flex; align-items: center; gap: 10px; }
.inbox-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #e6f4f9;
    color: #12708c;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}
.inbox-from-text { display: flex; flex-direction: column; min-width: 0; }
.inbox-from-name { font-size: 13px; font-weight: 600; color: #1a1a2e; }
.inbox-from-meta {
    font-size: 11px;
    color: #8a9099;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.inbox-preheader {
    margin-top: 10px;
    font-size: 12px;
    color: #8a9099;
    line-height: 1.5;
    font-style: italic;
}
.inbox-preheader:empty { display: none; }

#previewFrame {
    display: block;
    width: 100%;
    height: 600px;
    border: 0;
    background: #fff;
}

/* ── Candidate picker ──────────────────────────────────────────────────── */
.picker-list {
    max-height: 380px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}
.picker-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    font-size: 13px;
}
.picker-row:last-child { border-bottom: none; }
.picker-row:hover { background: #fafbfc; }
.picker-row.already { opacity: 0.45; cursor: not-allowed; }
.picker-row .picker-meta { color: #6b7280; font-size: 11px; }

.alert {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    font-size: 12px;
    line-height: 1.55;
}
.alert svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #14532d; padding: 10px 12px; border-radius: 6px; }

/* Not enough width for two panes: show one at a time, driven by the header
   toggle. The preview is never hidden outright, just switched to. */
@media (max-width: 1280px) {
    .builder { grid-template-columns: minmax(0, 1fr); }
    .modal-builder[data-mode="split"] .builder-right { display: none; }
    .modal-builder[data-mode="preview"] .builder-left { display: none; }
    .builder-left { border-right: none; }
}

/* Visually hidden but available to screen readers. */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Keyboard users need to see where they are. */
.mode-btn:focus-visible,
.toggle-btn:focus-visible,
.tab-btn:focus-visible {
    outline: 2px solid #3498db;
    outline-offset: -2px;
}

@media (prefers-reduced-motion: reduce) {
    .preview-device,
    .mode-btn,
    .toggle-btn,
    .builder-section > summary::before { transition: none; }
}
