/* CHISWDocs — Social Worker Docs Portal */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');

:root {
    --teal:      #5fa9a2;
    --teal-dark: #42817b;
    --lavender:  #8887a3;
    --pink:      #d6a7d0;
    --purple:    #a82a9c;
    --bg-light:  #f3f1fa;
    --bg-mid:    #eeecf9;
    --text:      #3c3c3c;
    --text-light:#666;
    --white:     #ffffff;
    --border:    rgba(136,135,163,0.2);
    --radius:    12px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: 'Poppins', Arial, sans-serif;
    font-size: 15px;
    color: var(--text);
    background: #fff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--teal); }
a:hover { color: var(--teal-dark); }

.pad {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ── HEADER ─────────────────────────────────────────────────────────── */
.hdrTop {
    background: var(--pink);
    color: var(--white);
    padding: 7px 0;
    font-size: 0.82rem;
    text-align: right;
}
.hdrTop a { color: var(--white); text-decoration: none; }
.hdrTop a:hover { text-decoration: underline; }

.hdrMain {
    padding: 14px 0;
    border-bottom: 3px solid var(--bg-mid);
}
.hdrMain .pad {
    display: flex;
    align-items: center;
    gap: 18px;
}
#hdrLogo {
    display: flex;
    align-items: center;
    gap: 18px;
    text-decoration: none;
    flex-shrink: 0;
}
#hdrLogo img { display: block; height: 50px; width: auto; }
.hdrTitle {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--teal);
    line-height: 1.2;
}
.hdrTitle span {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ── ADMIN NAV ──────────────────────────────────────────────────────── */
#navBar {
    background: var(--bg-mid);
    border-bottom: 1px solid var(--border);
    padding: 0;
}
#navBar .pad { display: flex; align-items: stretch; gap: 0; flex-wrap: wrap; }
#navBar a {
    display: inline-flex;
    align-items: center;
    color: var(--text);
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    padding: 11px 16px;
    position: relative;
    transition: color 0.15s;
}
#navBar a::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: var(--teal);
    transform: scaleX(0);
    transition: transform 0.2s;
}
#navBar a:hover { color: var(--teal); }
#navBar a:hover::after,
#navBar a.active::after { transform: scaleX(1); }
#navBar a.active { color: var(--teal); }

/* ── MAIN CONTENT AREA ──────────────────────────────────────────────── */
#page { flex: 1; }
.contentArea {
    padding: 36px 0 60px;
}

h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 24px;
}
h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 16px;
}

/* ── FLASH MESSAGE ──────────────────────────────────────────────────── */
.displayMsg {
    background: var(--teal);
    color: var(--white);
    border-radius: var(--radius);
    padding: 14px 22px;
    margin: 0 0 28px;
    font-weight: 600;
}
.displayMsg.error { background: #c0392b; }

/* ── TABLES ─────────────────────────────────────────────────────────── */
.niceTable {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-light);
    border-radius: var(--radius);
    overflow: hidden;
}
.niceTable th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
}
.niceTable td {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.7);
    font-size: 0.9rem;
    vertical-align: middle;
}
.niceTable tr:last-child td { border-bottom: none; }
.niceTable tbody tr:hover { background: rgba(255,255,255,0.6); }

/* ── FORMS ──────────────────────────────────────────────────────────── */
.formCard {
    background: var(--bg-light);
    border-radius: var(--radius);
    padding: 28px 32px 32px;
    margin-bottom: 32px;
}
.formCard h3 { margin-bottom: 20px; color: var(--teal); }

label {
    display: block;
    margin-bottom: 14px;
    font-size: 0.9rem;
}
.fieldLabel {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 0.85rem;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
select,
textarea {
    display: block;
    width: 100%;
    max-width: 380px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--white);
    transition: border-color 0.15s;
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--teal);
}
input[type="file"] { padding: 6px 8px; max-width: 420px; }
select { max-width: 260px; }

/* ── BUTTONS ─────────────────────────────────────────────────────────── */
.btn, button[type="submit"], button.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--teal);
    color: var(--white);
    border: none;
    border-radius: 20px;
    padding: 8px 20px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.btn:hover, button[type="submit"]:hover { background: var(--teal-dark); color: var(--white); }
.btn-sm { padding: 5px 14px; font-size: 0.8rem; }
.btn-danger { background: #c0392b; }
.btn-danger:hover { background: #96281b; }
.btn-secondary { background: var(--lavender); }
.btn-secondary:hover { background: #6e6d8a; }
.btn-outline {
    background: transparent;
    color: var(--teal);
    border: 2px solid var(--teal);
}
.btn-outline:hover { background: var(--teal); color: var(--white); }
.btnRow { display: flex; gap: 10px; align-items: center; margin-top: 20px; flex-wrap: wrap; }

/* ── COUNTRY CHECKBOX GRID ──────────────────────────────────────────── */
.countryGrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-top: 6px;
    background: var(--white);
    max-width: 600px;
}
.countryGrid label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 0.875rem;
    cursor: pointer;
}
.countryGrid input[type="checkbox"] { width: auto; margin: 0; }
.gridLegend {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.gridLegend a { font-size: 0.8rem; font-weight: 400; }

/* ── DRAG-TO-REORDER ─────────────────────────────────────────────────── */
.sectionPanel {
    background: var(--bg-light);
    border-radius: var(--radius);
    margin-bottom: 28px;
    overflow: hidden;
}
.sectionPanel-header {
    background: var(--teal);
    color: var(--white);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sectionPanel-header h3 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--white);
}
.sectionPanel-body { padding: 16px 20px 20px; }
.sortable-list {
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
    min-height: 40px;
}
.sortable-list.empty-hint::before {
    content: 'No documents yet — upload one below.';
    display: block;
    color: var(--text-light);
    font-size: 0.85rem;
    font-style: italic;
    padding: 8px 0;
}
.docRow {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 6px;
    transition: box-shadow 0.15s;
}
.docRow:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.docRow.sortable-ghost { opacity: 0.4; }
.dragHandle {
    cursor: grab;
    color: var(--lavender);
    font-size: 1.1rem;
    flex-shrink: 0;
    padding: 2px 4px;
}
.dragHandle:active { cursor: grabbing; }
.docRow-title {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 600;
}
.docRow-meta {
    font-size: 0.78rem;
    color: var(--text-light);
    white-space: nowrap;
}
.docRow-actions { display: flex; gap: 6px; flex-shrink: 0; }
.saveIndicator {
    font-size: 0.78rem;
    color: var(--teal);
    margin-left: 8px;
    opacity: 0;
    transition: opacity 0.3s;
}
.saveIndicator.visible { opacity: 1; }

/* ── DROP ZONE ───────────────────────────────────────────────────────── */
.dropZone {
    border: 2px dashed var(--lavender);
    border-radius: 10px;
    padding: 30px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: var(--white);
    max-width: 520px;
    user-select: none;
}
.dropZone:hover,
.dropZone.drag-over {
    border-color: var(--teal);
    background: var(--bg-light);
}
.dropZone-icon { font-size: 2rem; margin-bottom: 8px; }
.dropZone-text { font-size: 0.9rem; color: var(--text); }
.dropZone-text strong { color: var(--teal); }
.dropZone-hint { margin-top: 5px; font-size: 0.78rem; color: var(--text-light); }

.fileList { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; max-width: 520px; }
.fileItem {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-light);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.875rem;
}
.fileItem-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fileItem-size { color: var(--text-light); font-size: 0.8rem; white-space: nowrap; flex-shrink: 0; }
.fieldNote { color: var(--text-light); font-size: 0.78rem; margin-top: 4px; display: block; }
.fieldHint { color: var(--text-light); font-size: 0.78rem; margin: -8px 0 14px; }

/* ── ROLE BADGES ─────────────────────────────────────────────────────────── */
.roleBadge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.roleBadge.superadmin { background: var(--purple); color: var(--white); }
.roleBadge.admin      { background: var(--lavender); color: var(--white); }

.dropZone-sm {
    padding: 10px 16px;
    max-width: 100%;
}
.dropZone-sm .dropZone-icon,
.dropZone-sm .dropZone-hint { display: none; }

/* ── UPLOAD FORM WITHIN SECTION ─────────────────────────────────────── */
.inlineUploadForm {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: 4px;
}
.inlineUploadForm h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
    margin: 0 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.inlineUploadForm input[type="text"],
.inlineUploadForm input[type="file"] {
    max-width: 100%;
}

/* ── LOGIN FORM ─────────────────────────────────────────────────────── */
.loginWrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
}
.loginCard {
    background: var(--bg-light);
    border-radius: var(--radius);
    padding: 40px 44px 44px;
    width: 100%;
    max-width: 400px;
}
.loginCard h2 { margin-bottom: 28px; font-size: 1.3rem; }
.loginCard .btn { width: 100%; justify-content: center; margin-top: 8px; }
.loginError { color: #c0392b; font-size: 0.875rem; margin-top: -8px; margin-bottom: 12px; }

/* ── PUBLIC PORTAL ──────────────────────────────────────────────────── */
.portalWrap { padding: 36px 0 60px; }

.countryFilterBar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 36px;
    flex-wrap: wrap;
}
.countryFilterBar label { margin: 0; font-weight: 600; font-size: 0.9rem; white-space: nowrap; }
.countryFilterBar select { max-width: 220px; margin: 0; }

.countryBlock {
    margin-bottom: 44px;
}
.countryBlock-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 18px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--bg-mid);
}
.sectionBlock { margin-bottom: 22px; }
.sectionBlock-name {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--teal);
    margin: 0 0 10px;
}
.docList {
    list-style: decimal;
    padding-left: 22px;
    margin: 0;
}
.docList li {
    padding: 5px 0;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--bg-mid);
}
.docList li:last-child { border-bottom: none; }
.docList a {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}
.docList a:hover { color: var(--teal); text-decoration: underline; }
.uploadDate {
    color: var(--text-light);
    font-size: 0.8rem;
    margin-left: 8px;
    font-weight: 400;
}
.docDownload {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--bg-mid);
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.85rem;
    margin-left: 6px;
    transition: background 0.15s, color 0.15s;
    vertical-align: middle;
}
.docDownload:hover { background: var(--teal); color: var(--white); }

/* ── DASHBOARD STATS ─────────────────────────────────────────────────── */
.statGrid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 36px;
}
.statCard {
    background: var(--bg-light);
    border-radius: var(--radius);
    padding: 22px 24px;
    text-align: center;
}
.statNum {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--teal);
    line-height: 1;
    display: block;
}
.statLabel {
    font-size: 0.8rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 6px;
}

/* ── FOOTER ─────────────────────────────────────────────────────────── */
#footer {
    background: var(--teal);
    color: rgba(255,255,255,0.9);
    padding: 14px 0;
    margin-top: auto;
    font-size: 0.85rem;
}
#footer .pad {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
#footer a { color: rgba(255,255,255,0.9); text-decoration: none; }
#footer a:hover { text-decoration: underline; }

/* ── RESPONSIVE ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .hdrTitle { font-size: 1.1rem; }
    #navBar a { padding: 10px 10px; font-size: 0.8rem; }
    .statGrid { grid-template-columns: 1fr 1fr; }
    .formCard { padding: 20px; }
    .loginCard { padding: 28px 24px; }
    input[type="text"], input[type="email"], input[type="password"], select { max-width: 100%; }
}
@media (max-width: 480px) {
    .statGrid { grid-template-columns: 1fr; }
    #footer .pad { flex-direction: column; gap: 6px; text-align: center; }
    .hdrMain .pad { gap: 12px; }
    #hdrLogo img { height: 38px; }
}
