/* ============================================================
   Exam Result Manager — Complete Stylesheet
   Covers: Frontend (search form, result card) + Admin panel
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
    --erm-primary:     #1a73e8;
    --erm-primary-dk:  #1558b0;
    --erm-green:       #0f9d58;
    --erm-green-lt:    #e6f4ea;
    --erm-red:         #d93025;
    --erm-red-lt:      #fce8e6;
    --erm-amber:       #f9ab00;
    --erm-amber-lt:    #fef7e0;
    --erm-gray-50:     #f8f9fa;
    --erm-gray-100:    #f1f3f4;
    --erm-gray-200:    #e8eaed;
    --erm-gray-500:    #9aa0a6;
    --erm-gray-700:    #5f6368;
    --erm-gray-900:    #202124;
    --erm-white:       #ffffff;
    --erm-shadow-sm:   0 1px 4px rgba(0,0,0,.12);
    --erm-shadow-md:   0 4px 16px rgba(0,0,0,.14);
    --erm-shadow-lg:   0 8px 32px rgba(0,0,0,.18);
    --erm-radius-sm:   8px;
    --erm-radius-md:   14px;
    --erm-radius-lg:   20px;
    --erm-font:        'Segoe UI', 'SolaimanLipi', 'Noto Sans Bengali', Arial, sans-serif;
}

/* ── Reset for plugin scope ────────────────────────────────── */
.erm-container *,
.erm-wrap * {
    box-sizing: border-box;
}

/* ============================================================
   FRONTEND — Container
   ============================================================ */
.erm-container {
    font-family: var(--erm-font);
    max-width: 640px;
    margin: 32px auto;
    padding: 0 16px;
}

/* ── Header ─────────────────────────────────────────────────── */
.erm-header {
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, var(--erm-primary) 0%, #1558b0 100%);
    color: var(--erm-white);
    padding: 24px 28px;
    border-radius: var(--erm-radius-lg) var(--erm-radius-lg) 0 0;
}
.erm-header-icon {
    font-size: 2.4rem;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.3));
}
.erm-header-text h2 {
    margin: 0 0 4px;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--erm-white) !important;
    line-height: 1.3;
}
.erm-header-text p {
    margin: 0;
    font-size: .9rem;
    opacity: .88;
    color: var(--erm-white);
}

/* ── Search Box ─────────────────────────────────────────────── */
.erm-search-box {
    background: var(--erm-white);
    padding: 28px;
    border: 1px solid var(--erm-gray-200);
    border-top: none;
}

.erm-field-group {
    margin-bottom: 18px;
}
.erm-field-group label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--erm-gray-700);
    margin-bottom: 7px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.erm-select,
.erm-roll-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--erm-gray-200);
    border-radius: var(--erm-radius-sm);
    font-size: 1rem;
    font-family: var(--erm-font);
    color: var(--erm-gray-900);
    background: var(--erm-white);
    transition: border-color .2s, box-shadow .2s;
    outline: none;
}
.erm-select:focus,
.erm-roll-input:focus {
    border-color: var(--erm-primary);
    box-shadow: 0 0 0 3px rgba(26,115,232,.18);
}

.erm-input-row {
    display: flex;
    gap: 10px;
}
.erm-input-row .erm-roll-input {
    flex: 1;
}

.erm-search-btn {
    padding: 12px 22px;
    background: var(--erm-primary);
    color: var(--erm-white);
    border: none;
    border-radius: var(--erm-radius-sm);
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    font-family: var(--erm-font);
    transition: background .2s, transform .1s, box-shadow .2s;
    box-shadow: var(--erm-shadow-sm);
}
.erm-search-btn:hover {
    background: var(--erm-primary-dk);
    box-shadow: var(--erm-shadow-md);
}
.erm-search-btn:active {
    transform: scale(.97);
}

/* ── Loading ─────────────────────────────────────────────────── */
.erm-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 28px;
    background: var(--erm-white);
    border: 1px solid var(--erm-gray-200);
    border-top: none;
    gap: 12px;
    color: var(--erm-gray-700);
    font-size: .9rem;
}
.erm-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--erm-gray-200);
    border-top-color: var(--erm-primary);
    border-radius: 50%;
    animation: erm-spin .7s linear infinite;
}
@keyframes erm-spin {
    to { transform: rotate(360deg); }
}

/* ── Error message ───────────────────────────────────────────── */
.erm-error-msg {
    background: var(--erm-red-lt);
    border: 1px solid #f5c6c2;
    border-top: none;
    padding: 16px 24px;
    color: var(--erm-red);
    font-size: .95rem;
    border-radius: 0 0 var(--erm-radius-md) var(--erm-radius-md);
    display: flex;
    align-items: center;
    gap: 8px;
}
.erm-error-msg::before {
    content: '⚠️';
    font-size: 1.1rem;
    flex-shrink: 0;
}

.erm-error {
    color: var(--erm-red);
    font-style: italic;
    font-size: .9rem;
}

/* ── Result Area ─────────────────────────────────────────────── */
.erm-result-area {
    margin-top: 0;
}

/* ── Result Card ─────────────────────────────────────────────── */
.erm-result-card {
    background: var(--erm-white);
    border-radius: 0 0 var(--erm-radius-lg) var(--erm-radius-lg);
    overflow: hidden;
    border: 1px solid var(--erm-gray-200);
    border-top: none;
    animation: erm-fade-in .35s ease;
    box-shadow: var(--erm-shadow-md);
}
@keyframes erm-fade-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Banner */
.erm-result-banner {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    padding: 24px 28px;
}
.erm-card-qualified   .erm-result-banner { background: var(--erm-green-lt); }
.erm-card-not-qualified .erm-result-banner { background: var(--erm-red-lt); }

.erm-result-icon { font-size: 2.6rem; flex-shrink: 0; line-height: 1; }

.erm-result-badge {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.erm-badge-qualified     { background: var(--erm-green); color: #fff; }
.erm-badge-not-qualified { background: var(--erm-red);   color: #fff; }

.erm-greeting {
    margin: 8px 0 4px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--erm-gray-900);
}
.erm-sub-msg {
    margin: 0;
    font-size: .88rem;
    color: var(--erm-gray-700);
}

/* Details */
.erm-result-details {
    padding: 0 28px 4px;
}
.erm-detail-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--erm-gray-100);
}
.erm-detail-row:last-child { border-bottom: none; }

.erm-detail-label {
    min-width: 130px;
    font-size: .82rem;
    font-weight: 600;
    color: var(--erm-gray-500);
    text-transform: uppercase;
    letter-spacing: .04em;
    flex-shrink: 0;
}
.erm-detail-value {
    font-size: .95rem;
    color: var(--erm-gray-900);
    word-break: break-word;
}
.erm-roll-highlight {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--erm-primary);
    font-family: 'Courier New', monospace;
}

/* Actions */
.erm-result-actions {
    padding: 16px 28px 20px;
    text-align: right;
}
.erm-print-btn {
    padding: 9px 20px;
    background: var(--erm-gray-100);
    border: 1px solid var(--erm-gray-200);
    border-radius: var(--erm-radius-sm);
    font-size: .88rem;
    cursor: pointer;
    font-family: var(--erm-font);
    color: var(--erm-gray-700);
    transition: background .2s;
}
.erm-print-btn:hover { background: var(--erm-gray-200); }

/* ── Pagination ──────────────────────────────────────────────── */
.erm-pagination { margin-top: 14px; display: flex; gap: 6px; flex-wrap: wrap; }

/* ============================================================
   ADMIN PANEL
   ============================================================ */
.erm-wrap h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--erm-gray-900);
}
.erm-wrap h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 16px;
    color: var(--erm-gray-900);
}

/* Stats Grid */
.erm-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.erm-stat-card {
    background: var(--erm-white);
    border: 1px solid var(--erm-gray-200);
    border-radius: var(--erm-radius-md);
    padding: 20px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--erm-shadow-sm);
    transition: box-shadow .2s;
}
.erm-stat-card:hover { box-shadow: var(--erm-shadow-md); }
.erm-stat-card.erm-stat-green { border-left: 4px solid var(--erm-green); }
.erm-stat-card.erm-stat-red   { border-left: 4px solid var(--erm-red); }

.erm-stat-icon  { font-size: 1.9rem; flex-shrink: 0; }
.erm-stat-info  { display: flex; flex-direction: column; }
.erm-stat-number { font-size: 1.8rem; font-weight: 800; color: var(--erm-gray-900); line-height: 1; }
.erm-stat-label  { font-size: .78rem; color: var(--erm-gray-500); margin-top: 4px; }

/* Card */
.erm-card {
    background: var(--erm-white);
    border: 1px solid var(--erm-gray-200);
    border-radius: var(--erm-radius-md);
    padding: 24px;
    box-shadow: var(--erm-shadow-sm);
}

/* Two column */
.erm-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
@media (max-width: 768px) {
    .erm-two-col { grid-template-columns: 1fr; }
}

/* Table */
.erm-table { border-collapse: collapse; width: 100%; }
.erm-table th {
    background: var(--erm-gray-50);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--erm-gray-700);
    padding: 10px 12px;
    border-bottom: 2px solid var(--erm-gray-200);
    font-weight: 700;
}
.erm-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--erm-gray-100);
    font-size: .9rem;
    color: var(--erm-gray-900);
    vertical-align: middle;
}
.erm-table tbody tr:hover td { background: var(--erm-gray-50); }

/* Badges */
.erm-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.erm-badge-green { background: var(--erm-green-lt); color: var(--erm-green); }
.erm-badge-red   { background: var(--erm-red-lt);   color: var(--erm-red); }

/* Buttons */
.erm-btn-danger {
    background: var(--erm-red-lt) !important;
    color: var(--erm-red) !important;
    border-color: #f5c6c2 !important;
}
.erm-btn-danger:hover {
    background: var(--erm-red) !important;
    color: var(--erm-white) !important;
}

/* Filter form */
.erm-filter-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--erm-gray-50);
    border: 1px solid var(--erm-gray-200);
    border-radius: var(--erm-radius-sm);
}
.erm-filter-form select,
.erm-filter-form input[type="text"] {
    padding: 8px 12px;
    border: 1px solid var(--erm-gray-200);
    border-radius: var(--erm-radius-sm);
    font-size: .9rem;
    color: var(--erm-gray-900);
    font-family: var(--erm-font);
}

/* Quick links */
.erm-quick-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}

/* Shortcode guide */
.erm-shortcode-guide {
    background: var(--erm-white);
    border: 1px solid var(--erm-gray-200);
    border-radius: var(--erm-radius-md);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--erm-shadow-sm);
}
.erm-shortcode-table-wrap { overflow-x: auto; }

/* Code block */
.erm-code-block {
    background: var(--erm-gray-900);
    color: #a8ff78;
    padding: 14px 18px;
    border-radius: var(--erm-radius-sm);
    font-family: 'Courier New', Courier, monospace;
    font-size: .88rem;
    overflow-x: auto;
    line-height: 1.6;
}
.erm-code-block pre {
    margin: 0;
    color: inherit;
    background: none;
    padding: 0;
    white-space: pre;
}

/* Manual */
.erm-manual { display: flex; flex-direction: column; gap: 20px; }
.erm-manual-section {
    background: var(--erm-white);
    border: 1px solid var(--erm-gray-200);
    border-radius: var(--erm-radius-md);
    padding: 24px;
    box-shadow: var(--erm-shadow-sm);
}
.erm-manual-section ol,
.erm-manual-section ul {
    margin: 0 0 0 20px;
    padding: 0;
    line-height: 1.9;
}

/* Log box */
.erm-log-box {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--erm-gray-200);
    border-radius: var(--erm-radius-sm);
    padding: 12px;
    background: var(--erm-gray-50);
    font-family: 'Courier New', Courier, monospace;
    font-size: .82rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.erm-log-success { color: var(--erm-green); }
.erm-log-warning { color: var(--erm-amber); }
.erm-log-error   { color: var(--erm-red); }

/* Empty state */
.erm-empty {
    text-align: center;
    color: var(--erm-gray-500);
    padding: 24px;
    font-style: italic;
}

/* Copy button feedback */
.erm-copy-btn.copied {
    background: var(--erm-green) !important;
    color: var(--erm-white) !important;
    border-color: var(--erm-green) !important;
}

/* ── Print styles ─────────────────────────────────────────────── */
@media print {
    .erm-search-box,
    .erm-header,
    .erm-result-actions,
    .erm-print-btn { display: none !important; }
    .erm-result-card {
        border: 2px solid #333;
        border-radius: 0;
        box-shadow: none;
    }
}

/* ── Mobile Responsive ───────────────────────────────────────── */
@media (max-width: 600px) {
    .erm-container  { margin: 16px auto; padding: 0 10px; }
    .erm-header     { padding: 18px 16px; gap: 12px; }
    .erm-header-icon { font-size: 1.8rem; }
    .erm-header-text h2 { font-size: 1.1rem; }

    .erm-search-box { padding: 18px; }
    .erm-input-row  { flex-direction: column; }
    .erm-search-btn { width: 100%; }

    .erm-result-banner  { padding: 18px; gap: 12px; }
    .erm-result-details { padding: 0 18px 4px; }
    .erm-detail-label   { min-width: 110px; font-size: .75rem; }
    .erm-result-actions { padding: 12px 18px 16px; }

    .erm-stats-grid { grid-template-columns: 1fr 1fr; }
    .erm-stat-number { font-size: 1.4rem; }

    .erm-filter-form { flex-direction: column; align-items: stretch; }
}

/* ── পদবি ড্রপডাউন ───────────────────────────────────────────── */
.erm-required {
    color: #e53935;
    font-weight: 700;
}

.erm-post-field {
    animation: erm-fade-in .25s ease;
}

@keyframes erm-fade-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── পদবি লোডিং: disabled select ────────────────────────────── */
.erm-select:disabled {
    background: var(--erm-gray-100, #f5f5f5);
    color: var(--erm-gray-400, #aaa);
    cursor: wait;
}

/* ── Admin: পদবি ট্যাগ ───────────────────────────────────────── */
.erm-tag {
    display: inline-block;
    background: #e8f0fe;
    color: #1a73e8;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: .78rem;
    font-weight: 600;
    margin: 2px 3px 2px 0;
}

/* ── Disclaimer ──────────────────────────────────────────────── */
.erm-disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 20px 4px;
    padding: 12px 16px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 8px;
    font-size: .82rem;
    color: #795548;
    line-height: 1.55;
}
.erm-disclaimer-icon {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 1px;
}
.erm-disclaimer p {
    margin: 0;
}

/* ── Not-Found কার্ড: icon আপডেট ────────────────────────────── */
.erm-card-not-qualified .erm-result-icon {
    filter: grayscale(0);
}

@media (max-width: 600px) {
    .erm-disclaimer {
        margin: 0 12px 4px;
        font-size: .78rem;
    }
}
