/* ============================================================
   CareFlow Profile Editor — Redesigned UX
   ============================================================ */

/* ── Reset & root ── */
.pe-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: #f4f6f9;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    color: #1a2332;
}

/* ── Top bar ── */
.pe-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 24px;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.pe-topbar-left,
.pe-topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 220px;
}

.pe-topbar-right { justify-content: flex-end; }

.pe-topbar-center {
    flex: 1;
    text-align: center;
}

.pe-topbar-type-label {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.pe-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: #64748b;
    background: transparent;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.pe-back-btn:hover { background: #f1f5f9; color: #1a2332; }

.pe-topbar-identity {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pe-topbar-name {
    font-size: 15px;
    font-weight: 700;
    color: #1a2332;
    line-height: 1.2;
}

/* ── Status badges ── */
.pe-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.pe-status-success  { background: #dcfce7; color: #15803d; }
.pe-status-warning  { background: #fef9c3; color: #a16207; }
.pe-status-info     { background: #dbeafe; color: #1d4ed8; }
.pe-status-muted    { background: #f1f5f9; color: #64748b; }
.pe-status-danger   { background: #fee2e2; color: #b91c1c; }

/* ── Flash messages ── */
.pe-flash {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
}
.pe-flash-success { background: #dcfce7; color: #15803d; border-bottom: 1px solid #bbf7d0; }
.pe-flash-error   { background: #fee2e2; color: #b91c1c; border-bottom: 1px solid #fecaca; }

/* ── Layout: sidebar + content ── */
.pe-layout {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* ── Sidebar ── */
.pe-sidebar {
    width: 240px;
    min-width: 240px;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    padding: 24px 0;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
}

.pe-nav-heading {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #94a3b8;
    padding: 0 20px 8px;
    margin: 0;
}

.pe-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: #475569;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .12s, color .12s, border-color .12s;
}
.pe-nav-item:hover {
    background: #f8fafc;
    color: #1a2332;
    text-decoration: none;
}
.pe-nav-item--active {
    background: #eff6ff;
    color: #1d4ed8;
    border-left-color: #2563eb;
    font-weight: 600;
}

.pe-nav-icon {
    width: 16px;
    text-align: center;
    font-size: 14px;
    opacity: .7;
}

/* ── Content area ── */
.pe-content {
    flex: 1;
    padding: 32px;
    max-width: 860px;
    overflow-y: auto;
}

/* ── Section panels ── */
.pe-section-panel { display: none; }
.pe-section-panel--active { display: block; }
.pe-section-panel--hidden { display: none; }

.pe-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e2e8f0;
}

.pe-section-icon {
    font-size: 20px;
    color: #2563eb;
    width: 28px;
    text-align: center;
}

.pe-section-title {
    font-size: 20px;
    font-weight: 700;
    color: #1a2332;
    margin: 0;
}

/* ── Forms ── */
.pe-section-form { max-width: 720px; }

.pe-field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pe-field-grid {
    display: grid;
    gap: 20px;
}
.pe-field-grid-2 { grid-template-columns: 1fr 1fr; }
.pe-field-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

.pe-label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.pe-required { color: #ef4444; }

.pe-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    color: #1a2332;
    background: #ffffff;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
    box-sizing: border-box;
}
.pe-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.pe-textarea { resize: vertical; min-height: 90px; }
.pe-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

.pe-hint {
    font-size: 12px;
    color: #94a3b8;
    margin: 0;
}

/* ── Image upload ── */
.pe-image-upload {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}
.pe-image-preview {
    width: 96px;
    height: 96px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
}
.pe-image-thumb { width: 100%; height: 100%; object-fit: cover; }
.pe-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: #cbd5e1;
    font-size: 11px;
}
.pe-image-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 4px;
}
.pe-file-input { display: none; }

/* ── Tag selector (checkboxes styled as pills) ── */
.pe-tag-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.pe-tag-option {
    display: flex;
    align-items: center;
    gap: 0;
    cursor: pointer;
}
.pe-tag-option input[type="checkbox"] { display: none; }
.pe-tag-option span {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid #d1d5db;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    background: #f8fafc;
    transition: background .12s, border-color .12s, color .12s;
    user-select: none;
}
.pe-tag-option input[type="checkbox"]:checked + span {
    background: #eff6ff;
    border-color: #2563eb;
    color: #1d4ed8;
}
.pe-tag-option:hover span {
    border-color: #93c5fd;
    background: #f0f9ff;
}

/* ── Checkbox list ── */
.pe-checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.pe-checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    font-weight: 500;
}
.pe-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #2563eb;
    cursor: pointer;
}

/* ── Toggle switch ── */
.pe-toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}
.pe-toggle-input { display: none; }
.pe-toggle-track {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background: #d1d5db;
    position: relative;
    transition: background .2s;
    flex-shrink: 0;
}
.pe-toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    transition: left .2s;
}
.pe-toggle-input:checked ~ .pe-toggle-track { background: #2563eb; }
.pe-toggle-input:checked ~ .pe-toggle-track .pe-toggle-thumb { left: 23px; }
.pe-toggle-text { font-size: 14px; font-weight: 500; color: #374151; }

/* ── Info banner ── */
.pe-info-banner {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    color: #1d4ed8;
    line-height: 1.5;
}

/* ── Section footer (save button row) ── */
.pe-section-footer {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── Buttons ── */
.pe-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: 1.5px solid transparent;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    white-space: nowrap;
}
.pe-btn-primary {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}
.pe-btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
    box-shadow: 0 2px 8px rgba(59,130,246,.3);
    color: #ffffff;
    text-decoration: none;
}
.pe-btn-outline {
    background: transparent;
    color: #374151;
    border-color: #d1d5db;
}
.pe-btn-outline:hover {
    background: #f8fafc;
    border-color: #9ca3af;
    color: #1a2332;
    text-decoration: none;
}
.pe-btn-sm { padding: 7px 14px; font-size: 13px; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .pe-layout { flex-direction: column; }
    .pe-sidebar {
        width: 100%;
        min-width: 0;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        padding: 12px 0;
    }
    .pe-section-nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 12px; }
    .pe-nav-heading { display: none; }
    .pe-nav-item { border-left: none; border-bottom: 2px solid transparent; border-radius: 6px; padding: 8px 12px; font-size: 13px; }
    .pe-nav-item--active { border-bottom-color: #2563eb; }
    .pe-content { padding: 20px 16px; }
    .pe-field-grid-2, .pe-field-grid-3 { grid-template-columns: 1fr; }
    .pe-topbar { padding: 0 12px; }
    .pe-topbar-center { display: none; }
    .pe-topbar-left, .pe-topbar-right { min-width: 0; }
}
