/* ==========================================================
   Alumni Form Builder — Public CSS
   Form + Fully Responsive Alumni Directory Table
   Photo displayed in LAST column
   ========================================================== */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&family=Merriweather:wght@700&display=swap');

/* ── CSS Variables ── */
:root {
    --afb-blue:     #1a3c6e;
    --afb-blue2:    #1e56a0;
    --afb-blue3:    #d6e4f7;
    --afb-gold:     #f0a500;
    --afb-white:    #ffffff;
    --afb-bg:       #f4f7fc;
    --afb-border:   #dde4ef;
    --afb-text:     #1e293b;
    --afb-muted:    #64748b;
    --afb-success:  #16a34a;
    --afb-error:    #dc2626;
    --afb-radius:   10px;
    --afb-shadow:   0 4px 24px rgba(26,60,110,.10);
    --afb-shadow-lg:0 8px 40px rgba(26,60,110,.16);
    --afb-font:     'Nunito', sans-serif;
}

/* ══════════════════════════════════════════════════════════
   REGISTRATION FORM
══════════════════════════════════════════════════════════ */
.afb-form-wrap {
    font-family: var(--afb-font);
    max-width: 1100px;
    margin: 0 auto;
    color: var(--afb-text);
}

.afb-form-header-bar {
    background: linear-gradient(120deg, var(--afb-blue) 0%, var(--afb-blue2) 100%);
    border-radius: var(--afb-radius) var(--afb-radius) 0 0;
    padding: 22px 32px;
    text-align: center;
}
.afb-form-title {
    font-family: 'Merriweather', serif;
    color: var(--afb-white);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-decoration: underline;
    margin: 0;
    padding: 0;
}

.afb-form-container {
    background: var(--afb-white);
    border: 1.5px solid var(--afb-border);
    border-top: none;
    border-radius: 0 0 var(--afb-radius) var(--afb-radius);
    padding: 28px 32px 32px;
    box-shadow: var(--afb-shadow);
}

/* Message */
.afb-message {
    padding: 13px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 20px;
}
.afb-message.afb-success { background: #dcfce7; color: #15803d; border-left: 4px solid #16a34a; }
.afb-message.afb-error   { background: #fee2e2; color: #b91c1c; border-left: 4px solid #dc2626; }

/* Field rows */
.afb-field-row { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 16px; }
.afb-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.afb-w100 { flex: 1 1 100%; }
.afb-w50  { flex: 1 1 calc(50% - 9px); }
.afb-w33  { flex: 1 1 calc(33.333% - 12px); }
.afb-w66  { flex: 1 1 calc(66.666% - 9px); }
.afb-w25  { flex: 1 1 calc(25% - 14px); }
.afb-w75  { flex: 1 1 calc(75% - 5px); }

/* Labels */
.afb-label   { font-size: 13px; font-weight: 700; color: var(--afb-text); }
.afb-sublabel { font-size: 11.5px; color: var(--afb-muted); }
.afb-required { color: #e53935; margin-left: 2px; }

/* Inputs */
.afb-input, .afb-select, .afb-textarea {
    font-family: var(--afb-font);
    font-size: 13.5px;
    color: var(--afb-text);
    background: var(--afb-white);
    border: 1.5px solid var(--afb-border);
    border-radius: 7px;
    padding: 9px 13px;
    width: 100%;
    box-sizing: border-box;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    appearance: none;
    -webkit-appearance: none;
}
.afb-input:focus, .afb-select:focus, .afb-textarea:focus {
    border-color: var(--afb-blue2);
    box-shadow: 0 0 0 3px rgba(30,86,160,.12);
}
.afb-input::placeholder { color: #aab; }
.afb-textarea { resize: vertical; min-height: 120px; line-height: 1.6; }

.afb-select-wrap { position: relative; }
.afb-select { padding-right: 36px; cursor: pointer; }
.afb-chevron {
    position: absolute; right: 12px; top: 50%;
    transform: translateY(-50%); pointer-events: none;
    color: #94a3b8; font-size: 20px; line-height: 1;
}

/* Address block */
.afb-address-block {
    border: 1.5px solid var(--afb-border);
    border-radius: 8px;
    padding: 14px 16px 6px;
    margin-bottom: 16px;
    background: #fafcff;
}
.afb-address-label { font-size: 13px; font-weight: 700; color: var(--afb-text); margin-bottom: 10px; }

/* File upload */
.afb-file-drop-area {
    border: 2px dashed var(--afb-border);
    border-radius: 8px;
    background: #fafcff;
    position: relative;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}
.afb-file-drop-area:hover { border-color: var(--afb-blue2); background: #eff5ff; }
.afb-file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 2; }
.afb-file-ui { text-align: center; padding: 28px; pointer-events: none; }
.afb-file-text { font-size: 13px; color: var(--afb-muted); margin-top: 8px; }
.afb-file-preview img { max-width: 120px; max-height: 120px; border-radius: 8px; margin-top: 10px; border: 2px solid var(--afb-border); object-fit: cover; }

/* Submit */
.afb-submit-row { margin-top: 8px; }
.afb-submit-btn {
    background: linear-gradient(135deg, var(--afb-blue) 0%, var(--afb-blue2) 100%);
    color: var(--afb-white);
    border: none;
    border-radius: 8px;
    padding: 12px 36px;
    font-family: var(--afb-font);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: .5px;
    transition: opacity .2s, transform .15s;
}
.afb-submit-btn:hover { opacity: .9; transform: translateY(-1px); }

/* Phone */
.afb-phone-input { width: 100%; box-sizing: border-box; }
.iti { width: 100%; }

/* ══════════════════════════════════════════════════════════
   ALUMNI DIRECTORY — RESPONSIVE TABLE
   Photo in LAST column
══════════════════════════════════════════════════════════ */
.afb-dir-wrap {
    font-family: var(--afb-font);
    max-width: 100%;
    color: var(--afb-text);
}

/* ── Directory Header ── */
.afb-dir-header {
    background: linear-gradient(120deg, var(--afb-blue) 0%, var(--afb-blue2) 100%);
    border-radius: var(--afb-radius) var(--afb-radius) 0 0;
    padding: 24px 28px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}
.afb-dir-title-row { display: flex; align-items: center; gap: 14px; }
.afb-dir-icon { font-size: 36px; line-height: 1; }
.afb-dir-title {
    font-family: 'Merriweather', serif;
    color: var(--afb-white);
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 2px;
    padding: 0;
    line-height: 1.2;
}
.afb-dir-sub { color: rgba(255,255,255,.75); font-size: 13px; margin: 0; }

/* Search */
.afb-dir-search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,.15);
    border: 1.5px solid rgba(255,255,255,.35);
    border-radius: 50px;
    padding: 9px 18px;
    min-width: 240px;
    backdrop-filter: blur(4px);
    transition: background .2s;
}
.afb-dir-search-box:focus-within {
    background: rgba(255,255,255,.25);
    border-color: rgba(255,255,255,.7);
}
.afb-search-ico { color: rgba(255,255,255,.8); flex-shrink: 0; }
.afb-dir-search-box input {
    background: none;
    border: none;
    outline: none;
    color: var(--afb-white);
    font-family: var(--afb-font);
    font-size: 13.5px;
    font-weight: 500;
    width: 100%;
    min-width: 0;
}
.afb-dir-search-box input::placeholder { color: rgba(255,255,255,.6); }

/* ── Stats Bar ── */
.afb-stats-bar {
    display: flex;
    gap: 0;
    background: var(--afb-blue3);
    border-left: 1.5px solid var(--afb-border);
    border-right: 1.5px solid var(--afb-border);
}
.afb-stat-pill {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    border-right: 1px solid #c4d4ea;
}
.afb-stat-pill:last-child { border-right: none; }
.afb-sp-n { font-size: 20px; font-weight: 800; color: var(--afb-blue); line-height: 1.1; }
.afb-sp-l { font-size: 11px; color: var(--afb-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }

/* ── Table Scroller ── */
.afb-table-scroller {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1.5px solid var(--afb-border);
    border-top: none;
    background: var(--afb-white);
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: #bcd0ea var(--afb-bg);
}
.afb-table-scroller::-webkit-scrollbar { height: 6px; }
.afb-table-scroller::-webkit-scrollbar-track { background: var(--afb-bg); }
.afb-table-scroller::-webkit-scrollbar-thumb { background: #bcd0ea; border-radius: 3px; }

/* ── Table Core ── */
.afb-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    min-width: 600px;           /* ensures columns don't crush on medium */
}

/* ── Header Row ── */
.afb-thead-row {
    background: var(--afb-blue);
    position: sticky;
    top: 0;
    z-index: 10;
}
.afb-th {
    padding: 13px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    color: rgba(255,255,255,.92);
    letter-spacing: .6px;
    text-transform: uppercase;
    white-space: nowrap;
    border-right: 1px solid rgba(255,255,255,.1);
    user-select: none;
}
.afb-th:last-child { border-right: none; }

.afb-th-grip    { width: 32px; }
.afb-th-sn      { width: 52px; text-align: center; }
.afb-th-photo   { width: 90px; text-align: center; }
.afb-th-actions { width: 160px; text-align: center; }

/* Sortable header */
.afb-th-sortable { cursor: pointer; transition: background .15s; }
.afb-th-sortable:hover { background: rgba(255,255,255,.12); }
.afb-th-sortable.asc  .afb-sort-arrow { transform: rotate(180deg); opacity: 1; }
.afb-th-sortable.desc .afb-sort-arrow { transform: rotate(0deg);   opacity: 1; }
.afb-sort-arrow {
    display: inline-block;
    margin-left: 5px;
    opacity: .4;
    transition: transform .2s, opacity .2s;
    vertical-align: middle;
}

/* ── Table Rows ── */
.afb-tr {
    border-bottom: 1px solid var(--afb-border);
    transition: background .15s;
}
.afb-tr:nth-child(even) { background: #f8fafd; }
.afb-tr:nth-child(odd)  { background: var(--afb-white); }
.afb-tr:hover           { background: #edf3fb; }
.afb-tr:last-child      { border-bottom: none; }

/* ── Table Cells ── */
.afb-td {
    padding: 12px 16px;
    vertical-align: middle;
    color: var(--afb-text);
    border-right: 1px solid var(--afb-border);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.afb-td:last-child { border-right: none; }

/* Serial */
.afb-td-sn { text-align: center; }
.afb-sn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--afb-blue);
    color: var(--afb-white);
    border-radius: 50%;
    font-size: 11px;
    font-weight: 800;
}

/* Name cell */
.afb-name-cell { font-weight: 700; color: var(--afb-blue); }

/* Email link */
.afb-link-email {
    color: var(--afb-blue2);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px dashed var(--afb-blue3);
    transition: color .15s;
}
.afb-link-email:hover { color: var(--afb-blue); }

/* Badges */
.afb-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .4px;
}
.afb-badge-year  { background: #fef3c7; color: #92400e; }
.afb-badge-class { background: #dbeafe; color: #1e40af; }

/* Drag grip */
.afb-td-grip { width: 32px; cursor: grab; text-align: center; }
.afb-td-grip:active { cursor: grabbing; }

/* ── PHOTO CELL — Last Column ── */
.afb-td-photo-cell { text-align: center; padding: 8px 12px; }

.afb-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(26,60,110,.18);
    border: 2.5px solid var(--afb-white);
    outline: 2px solid var(--afb-blue3);
}
.afb-avatar-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.afb-avatar-init {
    background: linear-gradient(135deg, var(--afb-blue), var(--afb-blue2));
    color: var(--afb-white);
    font-size: 20px;
    font-weight: 800;
    font-family: 'Merriweather', serif;
}

/* ── Action Buttons ── */
.afb-td-actions { text-align: center; }
.afb-act-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 6px;
    border: none;
    font-family: var(--afb-font);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all .18s;
    margin: 2px;
    white-space: nowrap;
}
.afb-act-edit   { background: #dbeafe; color: #1d4ed8; }
.afb-act-delete { background: #fee2e2; color: #b91c1c; }
.afb-act-edit:hover   { background: #1d4ed8; color: #fff; }
.afb-act-delete:hover { background: #b91c1c; color: #fff; }

/* ── Empty / No Results ── */
.afb-empty, .afb-no-results {
    text-align: center;
    padding: 56px 20px;
    color: var(--afb-muted);
    background: var(--afb-white);
    border: 1.5px solid var(--afb-border);
    border-top: none;
}
.afb-empty-ico { font-size: 44px; margin-bottom: 12px; }
.afb-empty h3  { margin: 0 0 6px; font-size: 18px; color: var(--afb-text); }
.afb-empty p, .afb-no-results p { margin: 0; font-size: 14px; }
.afb-no-results svg { margin-bottom: 8px; display: block; margin-left: auto; margin-right: auto; }

/* ── Table Footer ── */
.afb-table-footer {
    background: var(--afb-bg);
    border: 1.5px solid var(--afb-border);
    border-top: none;
    border-radius: 0 0 var(--afb-radius) var(--afb-radius);
    padding: 10px 20px;
    font-size: 12.5px;
    color: var(--afb-muted);
    font-weight: 500;
}

/* Sortable placeholder (drag) */
.afb-tr.ui-sortable-helper {
    box-shadow: 0 8px 32px rgba(26,60,110,.22);
    background: #eff5ff !important;
    opacity: .9;
}
.ui-sortable-placeholder {
    background: var(--afb-blue3) !important;
    outline: 2px dashed var(--afb-blue2);
    visibility: visible !important;
}

/* ══════════════════════════════════════════════════════════
   EDIT MODAL
══════════════════════════════════════════════════════════ */
.afb-modal { position: fixed; inset: 0; z-index: 999999; display: flex; align-items: center; justify-content: center; }
.afb-modal-backdrop { position: absolute; inset: 0; background: rgba(10,20,40,.55); backdrop-filter: blur(5px); }
.afb-modal-box {
    position: relative;
    background: var(--afb-white);
    border-radius: 14px;
    width: 92%;
    max-width: 740px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0,0,0,.3);
    animation: afbSlideIn .28s cubic-bezier(.22,1,.36,1);
}
@keyframes afbSlideIn {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}
.afb-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    background: linear-gradient(120deg, var(--afb-blue), var(--afb-blue2));
    border-radius: 14px 14px 0 0;
}
.afb-modal-head h3 { margin: 0; color: var(--afb-white); font-size: 16px; font-weight: 700; }
.afb-modal-x {
    background: rgba(255,255,255,.2);
    border: none;
    color: var(--afb-white);
    width: 30px; height: 30px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
    transition: background .2s;
}
.afb-modal-x:hover { background: rgba(255,255,255,.35); }
.afb-modal-body { padding: 24px; }

/* Edit form grid */
.afb-edit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.afb-eg { display: flex; flex-direction: column; gap: 5px; }
.afb-eg.afb-eg-full { grid-column: 1 / -1; }
.afb-eg label { font-size: 12px; font-weight: 700; color: var(--afb-muted); text-transform: uppercase; letter-spacing: .5px; }
.afb-eg input,
.afb-eg select,
.afb-eg textarea {
    font-family: var(--afb-font);
    font-size: 13.5px;
    border: 1.5px solid var(--afb-border);
    border-radius: 7px;
    padding: 9px 12px;
    color: var(--afb-text);
    outline: none;
    transition: border-color .2s;
    box-sizing: border-box;
    width: 100%;
}
.afb-eg input:focus,
.afb-eg select:focus,
.afb-eg textarea:focus { border-color: var(--afb-blue2); }
.afb-eg textarea { min-height: 80px; resize: vertical; }

.afb-modal-foot {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--afb-border);
}
.afb-modal-cancel {
    background: #f1f5f9; color: var(--afb-muted);
    border: none; border-radius: 8px;
    padding: 10px 24px;
    font-family: var(--afb-font); font-size: 13.5px; font-weight: 700;
    cursor: pointer; transition: background .2s;
}
.afb-modal-cancel:hover { background: #e2e8f0; }
.afb-modal-save {
    background: linear-gradient(135deg, var(--afb-blue), var(--afb-blue2));
    color: var(--afb-white);
    border: none; border-radius: 8px;
    padding: 10px 28px;
    font-family: var(--afb-font); font-size: 13.5px; font-weight: 700;
    cursor: pointer; transition: opacity .2s;
}
.afb-modal-save:hover { opacity: .88; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
══════════════════════════════════════════════════════════ */

/* ── Tablet (≤ 900px) ── */
@media (max-width: 900px) {
    .afb-dir-header { flex-direction: column; align-items: flex-start; }
    .afb-dir-search-box { width: 100%; min-width: 0; box-sizing: border-box; }

    .afb-stats-bar { flex-wrap: wrap; }
    .afb-stat-pill { flex: 1 1 50%; border-right: none; border-bottom: 1px solid #c4d4ea; }
    .afb-stat-pill:nth-child(odd) { border-right: 1px solid #c4d4ea; }
    .afb-stat-pill:nth-last-child(-n+2) { border-bottom: none; }
}

/* ── Mobile (≤ 600px): STACKED CARD TABLE ── */
@media (max-width: 600px) {
    /* Form */
    .afb-form-container { padding: 18px 16px; }
    .afb-w33, .afb-w50, .afb-w66, .afb-w25, .afb-w75 { flex: 1 1 100%; }
    .afb-form-title { font-size: 18px; letter-spacing: 1px; }

    /* Hide the regular table, show stacked rows */
    .afb-table-scroller { overflow-x: visible; border: none; }
    .afb-tbl { display: block; min-width: 0; }
    .afb-tbl thead { display: none; } /* Hide column headers */
    .afb-tbl tbody { display: block; }

    /* Each row becomes a card */
    .afb-tr {
        display: block;
        background: var(--afb-white);
        border: 1.5px solid var(--afb-border);
        border-radius: var(--afb-radius);
        margin-bottom: 14px;
        padding: 0;
        box-shadow: 0 2px 12px rgba(26,60,110,.08);
        overflow: hidden;
    }
    .afb-tr:nth-child(even) { background: var(--afb-white); }
    .afb-tr:hover { background: #f8fafd; }

    /* Each cell: show data-label as a left-column header */
    .afb-td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 14px;
        border-right: none;
        border-bottom: 1px solid var(--afb-border);
        max-width: none;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        font-size: 13.5px;
    }
    .afb-td:last-child { border-bottom: none; }

    /* Left label from data-label */
    .afb-td::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 800;
        color: var(--afb-blue);
        text-transform: uppercase;
        letter-spacing: .6px;
        min-width: 110px;
        flex-shrink: 0;
        margin-right: 10px;
    }

    /* Hide grip & sn columns on mobile (not useful on cards) */
    .afb-td-grip,
    .afb-td-sn { display: none; }

    /* Photo cell: center the avatar */
    .afb-td-photo-cell {
        justify-content: space-between;
        padding: 14px;
        background: linear-gradient(120deg, var(--afb-blue3) 0%, #e8f0fb 100%);
    }
    .afb-avatar {
        width: 60px;
        height: 60px;
    }
    .afb-avatar-init { font-size: 22px; }

    /* Actions */
    .afb-td-actions { justify-content: flex-end; gap: 8px; flex-wrap: wrap; background: #f8fafd; }
    .afb-act-btn { padding: 7px 14px; font-size: 12px; }

    /* Serial pill in card mode */
    .afb-sn { width: 24px; height: 24px; font-size: 10px; }

    /* Stats: 2-column grid */
    .afb-stats-bar { display: grid; grid-template-columns: 1fr 1fr; }
    .afb-stat-pill { border-right: 1px solid #c4d4ea; border-bottom: 1px solid #c4d4ea; }
    .afb-stat-pill:nth-child(2n) { border-right: none; }
    .afb-stat-pill:nth-last-child(-n+2) { border-bottom: none; }

    /* No results */
    .afb-no-results { border: 1.5px solid var(--afb-border); border-radius: var(--afb-radius); border-top: 1.5px solid var(--afb-border); }
    .afb-table-footer { border-radius: 0; border-top: none; }

    /* Modal */
    .afb-modal-box { width: 96%; max-height: 94vh; border-radius: 12px; }
    .afb-edit-grid { grid-template-columns: 1fr; }
    .afb-eg.afb-eg-full { grid-column: 1; }

    /* Directory header */
    .afb-dir-title { font-size: 18px; }
    .afb-dir-icon { font-size: 28px; }
}

/* ── Very small (≤ 380px) ── */
@media (max-width: 380px) {
    .afb-form-container { padding: 14px 12px; }
    .afb-td::before { min-width: 90px; font-size: 10px; }
}
