/* ===========================================================================
   Applications — new user-friendly screen
   Consistent with the app design system (see styles.css CSS variables).
   =========================================================================== */

/* ---------- Header ---------- */
.app-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.app-header h1 {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.25rem;
}

.app-header h1 i {
    color: var(--primary-color);
    margin-right: 0.35rem;
}

.app-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

.app-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.btn-outline {
    background: #eef2ff;
    color: #4338ca;
    border: 1px solid #c7d2fe;
}

.btn-outline:hover {
    background: #e0e7ff;
}

.btn-outline-green {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.btn-outline-green:hover {
    background: #d1fae5;
}

.btn-ghost {
    background: #fff;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-ghost:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* ---------- Stats bar ---------- */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.6rem;
    margin-bottom: 1.1rem;
}

.stat-chip {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.65rem 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.stat-chip:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.stat-chip .stat-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.stat-chip .stat-num {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-chip .stat-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

/* ---------- Toolbar ---------- */
.toolbar {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1.1rem;
}

.toolbar-search,
.toolbar-program {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0 0.75rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.toolbar-search:focus-within,
.toolbar-program:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.toolbar-search i,
.toolbar-program i {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.toolbar-search input {
    border: none;
    outline: none;
    padding: 0.55rem 0;
    font-size: 0.9rem;
    min-width: 240px;
    background: transparent;
    color: var(--text-primary);
}

.toolbar-program select {
    border: none;
    outline: none;
    background: transparent;
    padding: 0.55rem 0;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    min-width: 170px;
}

/* ---------- Kanban board ---------- */
.board {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    overflow-x: auto;
    padding-bottom: 1rem;
    scroll-behavior: smooth;
}

.board-column {
    flex: 0 0 315px;
    background: #f1f2f7;
    border-radius: 14px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 250px);
    min-height: 120px;
    transition: box-shadow 0.3s, outline 0.3s;
}

.board-column.flash {
    outline: 3px solid rgba(79, 70, 229, 0.55);
    box-shadow: var(--shadow-lg);
}

.board-column-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.15rem 0.2rem 0.65rem;
}

.board-column-head .col-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.board-column-head .col-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.board-column-head .col-count {
    margin-left: auto;
    background: #fff;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 0.1rem 0.55rem;
    border: 1px solid var(--border-color);
}

.board-column-body {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.15rem;
    flex: 1;
}

.board-empty {
    border: 1.5px dashed #d1d5db;
    border-radius: 10px;
    padding: 1.4rem 0.75rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.78rem;
    background: rgba(255, 255, 255, 0.5);
}

/* ---------- Applicant card ---------- */
.app-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.8rem;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    position: relative;
}

.app-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.app-card-top {
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
}

.app-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
    overflow: hidden;
    position: relative;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.app-avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.app-card-main {
    flex: 1;
    min-width: 0;
}

.app-card-name {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-card-email {
    font-size: 0.74rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.05rem;
}

.app-card-program {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: #4338ca;
    background: #eef2ff;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    margin-top: 0.4rem;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-card-program.unknown {
    color: #b45309;
    background: #fef3c7;
}

.app-card-meta {
    display: flex;
    gap: 0.7rem;
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 0.45rem;
    flex-wrap: wrap;
}

.app-card-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.app-card-assigned {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: #065f46;
    background: #d1fae5;
    border-radius: 999px;
    padding: 0.12rem 0.55rem;
    margin-top: 0.45rem;
}

.app-card-snippet {
    margin-top: 0.5rem;
    border-radius: 8px;
    padding: 0.4rem 0.55rem;
    font-size: 0.72rem;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    color: #475569;
}

.app-card-snippet strong {
    color: var(--text-primary);
}

.app-card-snippet .snippet-status {
    font-weight: 700;
    border-radius: 999px;
    padding: 0.05rem 0.45rem;
    font-size: 0.65rem;
}

.app-card-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border-color);
}

.mini-btn {
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--text-secondary);
    border-radius: 8px;
    padding: 0.28rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.15s;
}

.mini-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    background: #eef2ff;
}

.mini-btn.primary {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.mini-btn.primary:hover {
    background: var(--primary-dark);
}

.mini-btn.success {
    background: var(--secondary-color);
    color: #fff;
    border-color: var(--secondary-color);
}

.mini-btn.success:hover {
    filter: brightness(0.92);
}

.mini-btn.danger {
    color: #b91c1c;
    border-color: #fecaca;
    background: #fef2f2;
}

.mini-btn.danger:hover {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
}

.mini-btn.warning {
    color: #b45309;
    border-color: #fde68a;
    background: #fffbeb;
}

.mini-btn.warning:hover {
    background: #f59e0b;
    color: #fff;
    border-color: #f59e0b;
}

.mini-btn.ghost {
    color: #6b7280;
}

.mini-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.mini-btn:disabled:hover {
    color: var(--text-secondary);
    border-color: var(--border-color);
    background: #fff;
}

/* ---------- Drawer ---------- */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(560px, 100vw);
    background: #fff;
    z-index: 2001;
    box-shadow: -12px 0 40px rgba(15, 23, 42, 0.25);
    transform: translateX(105%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
}

.drawer.open {
    transform: translateX(0);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.drawer-hero {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    padding: 1.4rem 1.5rem;
    position: relative;
}

.drawer-hero .close-x {
    position: absolute;
    top: 0.9rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.15s;
}

.drawer-hero .close-x:hover {
    background: rgba(255, 255, 255, 0.32);
}

.drawer-hero-top {
    display: flex;
    gap: 0.9rem;
    align-items: center;
}

.drawer-avatar {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    overflow: hidden;
    position: relative;
    background: rgba(255, 255, 255, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.6);
}

.drawer-avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.drawer-hero h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.25;
}

.drawer-hero .hero-email {
    font-size: 0.82rem;
    opacity: 0.9;
    word-break: break-all;
}

.drawer-hero .hero-badges {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.55rem;
}

.hero-badge {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    padding: 0.12rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 600;
}

.drawer-section {
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.drawer-section:last-child {
    border-bottom: none;
}

.drawer-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-secondary);
    margin: 0 0 0.7rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.drawer-section-title i {
    color: var(--primary-color);
}

.drawer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem 1.25rem;
}

.drawer-field {
    min-width: 0;
}

.drawer-field label {
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.15rem;
}

.drawer-field .value {
    font-size: 0.88rem;
    color: var(--text-primary);
    overflow-wrap: break-word;
    word-break: break-word;
}

.drawer-field .value a {
    color: var(--primary-color);
}

/* Workflow stepper */
.workflow-stepper {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}

.stepper-step {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.stepper-step .step-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    flex-shrink: 0;
}

.stepper-step.done .step-dot {
    background: var(--secondary-color);
    color: #fff;
}

.stepper-step.active .step-dot {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
}

.stepper-step.active {
    color: var(--primary-color);
}

.stepper-link {
    width: 18px;
    height: 2px;
    background: #e5e7eb;
    flex-shrink: 0;
    border-radius: 2px;
}

.stepper-link.done {
    background: var(--secondary-color);
}

/* Doc chips */
.doc-chips {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.doc-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.3rem 0.65rem;
    font-size: 0.76rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.15s;
    max-width: 100%;
}

.doc-chip:hover {
    border-color: var(--primary-color);
    background: #eef2ff;
}

.doc-chip i {
    color: var(--primary-color);
}

.doc-chip .doc-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
}

/* Reviews */
.review-item {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
}

.review-item-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.review-item-head .rv-email {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.review-item-head .rv-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: auto;
}

.review-item .rv-note {
    font-size: 0.82rem;
    color: #334155;
    margin-top: 0.35rem;
    white-space: pre-wrap;
}

.vote-pill {
    font-size: 0.68rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
}

.vote-pill.approve { background: #d1fae5; color: #065f46; }
.vote-pill.reject { background: #fee2e2; color: #991b1b; }
.vote-pill.abstain { background: #f3f4f6; color: #4b5563; }

.vote-opt {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    cursor: pointer;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.35rem 0.7rem;
    transition: border-color 0.15s, background 0.15s;
}

.vote-opt:hover {
    border-color: var(--primary-color);
    background: #eef2ff;
}

.vote-opt input {
    accent-color: var(--primary-color);
}

/* Drawer action buttons */
.drawer-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.drawer-actions .btn {
    font-size: 0.82rem;
}

.btn-approve {
    background: var(--secondary-color);
}

.btn-approve:hover {
    filter: brightness(0.92);
}

.btn-reject {
    background: var(--danger-color);
}

.btn-reject:hover {
    filter: brightness(0.92);
}

.btn-warning {
    background: var(--warning-color);
    color: #fff;
}

.btn-warning:hover {
    filter: brightness(0.92);
}

/* ---------- Modal ---------- */
.modal-root {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.5);
    padding: 1rem;
}

.modal-root.open {
    display: flex;
}

.modal-card {
    background: #fff;
    border-radius: 16px;
    width: min(520px, 100%);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.3);
    animation: modalIn 0.22s ease-out;
}

.modal-card.wide {
    width: min(920px, 100%);
}

@keyframes modalIn {
    from { transform: translateY(24px) scale(0.98); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-head h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-head h3 i {
    color: var(--primary-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    transition: background 0.15s;
}

.modal-close:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.2rem 1.4rem;
    overflow-y: auto;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.4rem;
    border-top: 1px solid var(--border-color);
}

.modal-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin: 0 0 1rem;
    line-height: 1.5;
}

.field-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.form-input {
    width: 100%;
    box-sizing: border-box;
}

textarea.form-input {
    resize: vertical;
    min-height: 90px;
    font-family: inherit;
}

/* Audit table */
.audit-table-wrap {
    overflow-x: auto;
    margin-top: 0.6rem;
}

.audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.audit-table th {
    text-align: left;
    padding: 0.5rem 0.6rem;
    background: var(--bg-color);
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
}

.audit-table td {
    padding: 0.5rem 0.6rem;
    border-top: 1px solid var(--border-color);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
    }

    .toolbar-search input {
        min-width: 160px;
    }

    .board-column {
        flex-basis: 280px;
    }

    .drawer {
        width: 100vw;
    }

    .drawer-grid {
        grid-template-columns: 1fr;
    }
}
