/* ============================================================
   PIP System — Disciplinary & PIP Records
   ============================================================ */

/* ── Shared layout wrapper ── */
.pip-page {
    padding: 1.5rem;
    max-width: 1300px;
    margin: 0 auto;
}

/* ── Page header banner ── */
.pip-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #fff;
    padding: 1.75rem 2rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    text-align: left;
}
.pip-header h1 {
    font-size: 1.45rem;
    font-weight: 700;
    margin: 0 0 .25rem;
    color: #fff;
    text-align: left;
}
.pip-header p {
    font-size: .875rem;
    opacity: .75;
    margin: 0;
    color: #fff;
    text-align: left;
}
.pip-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
}
.pip-header-red-bg   { background: linear-gradient(135deg, #7f1d1d 0%, #b91c1c 100%); }
.pip-header-green-bg { background: linear-gradient(135deg, #064e3b 0%, #059669 100%); }
.pip-header .pip-meta { font-size: .82rem; opacity: .75; }

/* ── Stat cards row ── */
.pip-stat-row {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.pip-stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 1.2rem 1.5rem;
    flex: 1 1 140px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    border-left: 4px solid #64748b;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.pip-stat-card.pip-sc-red    { border-left-color: #ef4444; }
.pip-stat-card.pip-sc-amber  { border-left-color: #f59e0b; }
.pip-stat-card.pip-sc-green  { border-left-color: #10b981; }
.pip-stat-val {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    color: #1e293b;
}
.pip-stat-lbl {
    font-size: .75rem;
    color: #64748b;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.pip-stat-action {
    font-size: 1.05rem;
    font-weight: 700;
    color: #065f46;
}

/* ── Filter bar ── */
.pip-filter-bar {
    background: #fff;
    border-radius: 10px;
    padding: .85rem 1.25rem;
    display: flex;
    flex-direction: row;
    gap: .6rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.pip-filter-form {
    display: flex;
    flex-direction: row;
    gap: .4rem;
    align-items: center;
    align-self: center;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
}
.pip-search-input {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: .45rem .75rem;
    font-size: .875rem;
    background: #fff;
    color: #374151;
    outline: none;
    width: 220px;
    height: 36px;
    box-sizing: border-box;
    vertical-align: middle;
}
.pip-search-input:focus { border-color: #6366f1; }

.pip-filter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 .9rem;
    border-radius: 6px;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #374151;
    text-decoration: none;
    white-space: nowrap;
    box-sizing: border-box;
    vertical-align: middle;
}
.pip-filter-btn:hover            { background: #f1f5f9; color: #1e293b; }
.pip-filter-btn.pip-fb-active    { background: #1e293b; color: #fff; border-color: #1e293b; }
.pip-filter-btn.pip-fb-green     { background: #10b981; color: #fff; border-color: #10b981; }
.pip-filter-btn.pip-fb-red       { background: #ef4444; color: #fff; border-color: #ef4444; }

/* Override base-site styles on the search submit button — blue, same height as siblings */
button.pip-filter-btn {
    background: #3b82f6 !important;
    color: #fff !important;
    border: 1px solid #3b82f6 !important;
    border-radius: 6px !important;
    font-family: inherit !important;
    font-size: .8rem !important;
    font-weight: 600 !important;
    height: 36px !important;
    padding: 0 .9rem !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: none !important;
    outline: none !important;
    line-height: 1 !important;
    vertical-align: middle !important;
    margin: 0 !important;
}
button.pip-filter-btn:hover {
    background: #2563eb !important;
    color: #fff !important;
    border-color: #2563eb !important;
}

/* ── Data table ── */
.pip-table-wrap {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    overflow: hidden;
}
.pip-table-wrap table {
    width: 100%;
    border-collapse: collapse;
}
.pip-table-wrap th {
    background: #f8fafc;
    padding: .7rem 1rem;
    text-align: left;
    font-size: .72rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid #e2e8f0;
}
.pip-table-wrap td {
    padding: .8rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: .86rem;
    vertical-align: middle;
    color: #374151;
}
.pip-table-wrap tr:last-child td { border-bottom: none; }
.pip-table-wrap tbody tr:hover td { background: #f8fafc; }
.pip-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
}
.pip-empty-state i { font-size: 2.5rem; margin-bottom: 1rem; display: block; }

/* ── Badges ── */
.pip-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}
.pip-badge-risk    { background: #fee2e2; color: #b91c1c; }
.pip-badge-warn    { background: #fef3c7; color: #92400e; }
.pip-badge-ok      { background: #d1fae5; color: #065f46; }
.pip-badge-minor   { background: #fef9c3; color: #713f12; }
.pip-badge-moderate{ background: #ffedd5; color: #9a3412; }
.pip-badge-serious { background: #fee2e2; color: #991b1b; }
.pip-badge-active  { background: #fee2e2; color: #b91c1c; }
.pip-badge-expired { background: #f1f5f9; color: #94a3b8; }
.pip-badge-pip-active    { background: #dbeafe; color: #1e40af; }
.pip-badge-pip-completed { background: #d1fae5; color: #065f46; }
.pip-badge-pip-expired   { background: #f1f5f9; color: #94a3b8; }
.pip-badge-pip-cancelled { background: #f5f3ff; color: #5b21b6; }

/* ── Write-up count circles ── */
.pip-wu-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 700;
    font-size: .85rem;
}
.pip-wu-0  { background: #f1f5f9; color: #94a3b8; }
.pip-wu-1  { background: #fef3c7; color: #b45309; }
.pip-wu-2  { background: #ffedd5; color: #c2410c; }
.pip-wu-3p { background: #fee2e2; color: #991b1b; }

/* ── Action buttons ── */
.pip-action-row {
    display: flex;
    flex-direction: row;
    gap: .35rem;
    flex-wrap: wrap;
}
.pip-btn {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: .75rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.5;
    transition: opacity .15s;
}
.pip-btn:hover      { opacity: .85; }
.pip-btn-view    { background: #e0e7ff; color: #3730a3; }
.pip-btn-writeup { background: #fee2e2; color: #991b1b; }
.pip-btn-pip     { background: #d1fae5; color: #065f46; }
.pip-btn-back    { background: #f1f5f9; color: #475569; }
.pip-btn-doc     { background: #e0e7ff; color: #3730a3; }
.pip-btn-red     { background: #ef4444; color: #fff; }
.pip-btn-green   { background: #10b981; color: #fff; }
.pip-btn-ghost   { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.3); }

/* ── PIP detail controls row (back-link left, status form right) ── */
.pip-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.pip-controls-right {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.pip-status-form {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin: 0;
    padding: 0;
}

/* ── PIP detail info cards row (auto-fit, no stretch) ── */
.pip-detail-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}
.pip-detail-cards .pip-info-card {
    flex: 0 1 auto;
    min-width: 180px;
}
.pip-detail-full {
    margin-bottom: 1rem;
}

/* ── Header badge group ── */
.pip-header-badges {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .4rem;
}
.pip-badge-days {
    background: rgba(255,255,255,.2);
    color: #fff;
    border: 1px solid rgba(255,255,255,.4);
}

/* ── Goals progress text ── */
.pip-progress-text {
    margin-top: .25rem;
    font-size: .73rem;
    color: #94a3b8;
}
.pip-goals-count-label {
    font-size: .78rem;
    color: #64748b;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

/* ── Section cards (detail pages) ── */
.pip-section-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    margin-bottom: 1.25rem;
    overflow: hidden;
}
.pip-section-head {
    padding: .85rem 1.25rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #475569;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.pip-section-body { padding: 1.25rem; }

/* ── Info grid (detail pages) ── */
.pip-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.pip-info-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    padding: 1.2rem;
}
.pip-info-card.pip-full { grid-column: 1 / -1; }
.pip-info-label {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #94a3b8;
    margin-bottom: .3rem;
}
.pip-info-value {
    font-size: .93rem;
    color: #1e293b;
    line-height: 1.5;
    white-space: pre-line;
}

/* ── Risk banner ── */
.pip-risk-banner {
    background: #fee2e2;
    border: 1px solid #fecaca;
    border-left: 4px solid #ef4444;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    color: #991b1b;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .75rem;
}
.pip-risk-banner-hidden { display: none !important; }
.pip-risk-banner-show   { display: flex !important; }

/* ── Summary chips ── */
.pip-chip-row {
    display: flex;
    gap: .6rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.pip-chip {
    padding: .35rem .9rem;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 600;
}
.pip-chip-gray  { background: #f1f5f9; color: #475569; }
.pip-chip-red   { background: #fee2e2; color: #b91c1c; }
.pip-chip-amber { background: #fef3c7; color: #92400e; }
.pip-chip-green { background: #d1fae5; color: #065f46; }

/* ── Records table (employee_records page) ── */
.pip-rec-table { width: 100%; border-collapse: collapse; }
.pip-rec-table th {
    padding: .65rem 1rem;
    text-align: left;
    font-size: .73rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid #f1f5f9;
}
.pip-rec-table td {
    padding: .8rem 1rem;
    border-bottom: 1px solid #f8fafc;
    font-size: .85rem;
    vertical-align: middle;
}
.pip-rec-table tr:last-child td { border-bottom: none; }
.pip-rec-table tbody tr:hover td { background: #fafafa; }
.pip-link { color: #6366f1; text-decoration: none; font-weight: 500; }
.pip-link:hover { text-decoration: underline; }

/* ── Form pages ── */
.pip-form-page { max-width: 760px; margin: 0 auto; padding: 1.5rem; }
.pip-form-header {
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    color: #fff;
}
.pip-form-header h1 { font-size: 1.3rem; font-weight: 700; margin: 0 0 .25rem; color: #fff; }
.pip-form-header p  { font-size: .85rem; opacity: .75; margin: 0; color: #fff; }
.pip-form-header-red  { background: linear-gradient(135deg, #7f1d1d 0%, #b91c1c 100%); }
.pip-form-header-green{ background: linear-gradient(135deg, #064e3b 0%, #059669 100%); }

.pip-form-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    padding: 1.75rem;
    margin-bottom: 1.25rem;
}
.pip-form-card h3 {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #94a3b8;
    margin: 0 0 1.1rem;
    padding-bottom: .6rem;
    border-bottom: 1px solid #f1f5f9;
}
.pip-form-group { margin-bottom: 1.1rem; }
.pip-form-group label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: .35rem;
}
.pip-form-group .pip-help { font-size: .74rem; color: #94a3b8; margin-top: .25rem; }
.pip-form-control {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: .875rem;
    outline: none;
    transition: border-color .15s;
    box-sizing: border-box;
    background: #fff;
    color: #374151;
}
.pip-form-control:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.pip-errorlist { color: #ef4444; font-size: .78rem; list-style: none; padding: 0; margin: .25rem 0 0; }

/* Severity note */
.pip-severity-note {
    font-size: .72rem;
    font-weight: 400;
    color: #94a3b8;
    font-style: italic;
}

/* Form select/input/textarea rendered by Django widgets */
.pip-form-card select,
.pip-form-card input[type=text],
.pip-form-card input[type=date],
.pip-form-card textarea {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: .875rem;
    outline: none;
    background: #fff;
    color: #374151;
    box-sizing: border-box;
    transition: border-color .15s;
}
.pip-form-card select:focus,
.pip-form-card input[type=text]:focus,
.pip-form-card input[type=date]:focus,
.pip-form-card textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
.pip-form-card select { appearance: auto; }
.pip-form-card textarea { resize: vertical; min-height: 90px; }

/* Severity radios */
.pip-severity-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.pip-sev-opt input[type=radio] { display: none; }
.pip-sev-opt label {
    display: flex; align-items: center; gap: .4rem;
    padding: .5rem 1.1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    font-size: .85rem;
    font-weight: 600;
    transition: all .15s;
    user-select: none;
}
.pip-sev-opt input:checked + label.pip-sev-minor    { border-color: #f59e0b; background: #fef3c7; color: #92400e; }
.pip-sev-opt input:checked + label.pip-sev-moderate { border-color: #f97316; background: #ffedd5; color: #9a3412; }
.pip-sev-opt input:checked + label.pip-sev-serious  { border-color: #ef4444; background: #fee2e2; color: #991b1b; }
.pip-sev-opt label:hover { border-color: #94a3b8; }

/* Expiration radios */
.pip-exp-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.pip-exp-opt input[type=radio] { display: none; }
.pip-exp-opt label {
    padding: .5rem 1.2rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    font-size: .85rem;
    font-weight: 600;
    transition: all .15s;
    user-select: none;
    color: #475569;
}
.pip-exp-opt input:checked + label { border-color: #6366f1; background: #e0e7ff; color: #3730a3; }
.pip-exp-opt label:hover { border-color: #94a3b8; }

/* Upload zone */
.pip-upload-zone {
    border: 2px dashed #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    color: #94a3b8;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    position: relative;
}
.pip-upload-zone:hover { border-color: #6366f1; background: #f5f3ff; }
.pip-upload-zone input[type=file] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer;
    width: 100%; height: 100%;
}
.pip-upload-zone i { font-size: 1.8rem; display: block; margin-bottom: .5rem; }
.pip-upload-note { font-size: .76rem; }

/* Form actions */
.pip-form-actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.pip-submit-btn {
    padding: .55rem 1.4rem; border-radius: 7px; font-size: .875rem; font-weight: 600;
    border: none; cursor: pointer; color: #fff; transition: opacity .15s;
}
.pip-submit-btn:hover { opacity: .85; }
.pip-submit-red   { background: #ef4444; }
.pip-submit-green { background: #059669; }

/* Date row grid */
.pip-date-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Goals */
.pip-goal-row {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: .85rem;
    margin-bottom: .6rem;
    position: relative;
}
.pip-goal-num { font-size: .72rem; font-weight: 700; color: #94a3b8; text-transform: uppercase; margin-bottom: .4rem; }
.pip-goal-remove {
    position: absolute; top: .6rem; right: .6rem;
    background: none; border: none; color: #ef4444;
    cursor: pointer; font-size: .85rem; padding: 2px 6px;
}
.pip-add-goal-btn {
    background: #f0fdf4; border: 1px dashed #86efac; color: #059669;
    border-radius: 7px; padding: .5rem 1rem; font-size: .82rem; font-weight: 600;
    cursor: pointer; width: 100%; transition: background .15s;
}
.pip-add-goal-btn:hover { background: #dcfce7; }

/* Progress bar */
.pip-progress-wrap { background: #f1f5f9; border-radius: 10px; height: 8px; margin-top: .5rem; overflow: hidden; }
.pip-progress-fill { height: 100%; background: #10b981; border-radius: 10px; transition: width .3s; }

/* Goal checkboxes */
.pip-goal-item { display: flex; align-items: flex-start; gap: .75rem; padding: .75rem 0; border-bottom: 1px solid #f1f5f9; }
.pip-goal-item:last-child { border-bottom: none; }
.pip-goal-check-form { display: inline; }
.pip-goal-checkbox {
    width: 20px; height: 20px; border: 2px solid #e2e8f0; border-radius: 4px;
    cursor: pointer; appearance: none; -webkit-appearance: none;
    background: #fff; position: relative; flex-shrink: 0; margin-top: 2px; transition: all .15s;
}
.pip-goal-checkbox:checked { background: #10b981; border-color: #10b981; }
.pip-goal-checkbox:checked::after {
    content: '✓'; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%,-50%); color: #fff; font-size: .75rem; font-weight: 700;
}
.pip-goal-text { flex: 1; }
.pip-goal-desc { font-size: .88rem; color: #1e293b; }
.pip-goal-desc.pip-done { text-decoration: line-through; color: #94a3b8; }
.pip-goal-due  { font-size: .73rem; color: #94a3b8; margin-top: 2px; }
.pip-goals-empty { text-align: center; color: #94a3b8; font-size: .85rem; padding: 1rem 0; }

/* Status select */
.pip-status-select {
    border: 1px solid #e2e8f0; border-radius: 6px; padding: 0 .6rem;
    font-size: .82rem; background: #fff; height: 34px; box-sizing: border-box;
    vertical-align: middle;
}
.pip-status-update-btn {
    background: #1e293b; color: #fff; border: none; border-radius: 6px;
    padding: 0 .9rem; font-size: .82rem; font-weight: 600; cursor: pointer;
    height: 34px; box-sizing: border-box; vertical-align: middle;
}
.pip-status-update-btn:hover { background: #334155; }

/* PIP rows in employee_records */
.pip-record-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: .75rem 1.25rem; border-bottom: 1px solid #f1f5f9;
}
.pip-record-row:last-child { border-bottom: none; }

/* Employee profile section */
.pip-profile-section {
    margin-top: 2rem;
    background: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    overflow: hidden;
}
.pip-profile-section-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Responsive */
@media (max-width: 640px) {
    .pip-info-grid   { grid-template-columns: 1fr; }
    .pip-date-row    { grid-template-columns: 1fr; }
    .pip-stat-row    { flex-direction: column; }
}
