/* =============================================
   Teacher Manager - Frontend v1.4
   Uses CSS variables from settings
   ============================================= */

/* ---- Grid ---- */
.tm-teachers-grid { display:grid; gap:var(--tm-gap,28px); padding:20px 0; }
.tm-cols-1 { grid-template-columns:1fr; }
.tm-cols-2 { grid-template-columns:repeat(2,1fr); }
.tm-cols-3 { grid-template-columns:repeat(3,1fr); }
.tm-cols-4 { grid-template-columns:repeat(4,1fr); }
@media(max-width:992px){ .tm-cols-3,.tm-cols-4{grid-template-columns:repeat(2,1fr);} }
@media(max-width:600px){ .tm-cols-2,.tm-cols-3,.tm-cols-4{grid-template-columns:1fr;} }

/* ---- Original Card ---- */
.tm-teacher-card { background:var(--tm-card-bg,#fff); border-radius:var(--tm-card-radius,12px); box-shadow:var(--tm-shadow); overflow:hidden; transition:transform 0.3s,box-shadow 0.3s; font-family:var(--tm-font); }
.tm-teacher-photo { width:100%; aspect-ratio:var(--tm-photo-ratio,3/4); overflow:hidden; background:#f5f5f5; position:relative; }
.tm-teacher-photo img { width:100%; height:100%; object-fit:cover; }
.tm-no-photo-front { width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:60px;background:linear-gradient(135deg,#e8e8e8,#f5f5f5); }
.tm-teacher-content { padding:18px; }
.tm-teacher-groups { display:flex;gap:5px;flex-wrap:wrap;margin-bottom:8px; }
.tm-group-tag { display:inline-block;background:color-mix(in srgb,var(--tm-primary,#4338ca) 10%,#fff);color:var(--tm-primary,#4338ca);font-size:0.75em;padding:2px 10px;border-radius:12px;font-weight:500; }
.tm-teacher-name { margin:0 0 5px;font-size:var(--tm-name-size,16px);font-weight:var(--tm-name-weight,700);color:var(--tm-name-color,#222);line-height:1.3;font-family:var(--tm-font);cursor:pointer; }
.tm-teacher-name:hover { color:var(--tm-primary); }
.tm-teacher-position { margin:0 0 10px;color:var(--tm-pos-color,#0066cc);font-size:var(--tm-pos-size,13px);font-weight:500; }
.tm-teacher-education { margin:10px 0;padding:10px;background:#f8f9fa;border-radius:8px;font-size:var(--tm-edu-size,13px); }
.tm-teacher-education strong { display:block;margin-bottom:5px;color:#444; }
.tm-teacher-education ul { margin:0;padding-left:18px; }
.tm-teacher-education li { margin-bottom:3px;color:#555;line-height:1.5; }
.tm-teacher-contact { margin-top:12px;display:flex;flex-direction:column;gap:5px; }
.tm-contact-link { display:inline-block;color:#555;text-decoration:none;font-size:0.85em;transition:color 0.2s; }
a.tm-contact-link:hover { color:var(--tm-primary); }

/* =============================================
   SPU Grouped Style
   ============================================= */
.tm-grouped-wrapper { max-width:1200px;margin:0 auto;padding:10px 0; }
.tm-group-section { margin-bottom:50px; }
.tm-group-header { display:flex;align-items:center;gap:12px;margin-bottom:24px;padding-bottom:14px;border-bottom:3px solid var(--tm-primary,#4338ca); }
.tm-group-header-bar { width:6px;height:32px;background:var(--tm-primary,#4338ca);border-radius:3px;flex-shrink:0; }
.tm-group-title { margin:0;font-size:1.35em;font-weight:800;color:var(--tm-primary,#1e1b4b);line-height:1.2;font-family:var(--tm-font); }
.tm-group-count { font-size:0.78em;padding:3px 12px;border-radius:20px;background:color-mix(in srgb,var(--tm-primary,#4338ca) 8%,#fff);color:var(--tm-primary);font-weight:600;white-space:nowrap; }

.tm-spu-grid { display:grid; gap:var(--tm-gap,28px); }
.tm-spu-grid.tm-cols-1{grid-template-columns:1fr;} .tm-spu-grid.tm-cols-2{grid-template-columns:repeat(2,1fr);}
.tm-spu-grid.tm-cols-3{grid-template-columns:repeat(3,1fr);} .tm-spu-grid.tm-cols-4{grid-template-columns:repeat(4,1fr);}
@media(max-width:992px){.tm-spu-grid.tm-cols-3,.tm-spu-grid.tm-cols-4{grid-template-columns:repeat(2,1fr);}}
@media(max-width:600px){.tm-spu-grid.tm-cols-2,.tm-spu-grid.tm-cols-3,.tm-spu-grid.tm-cols-4{grid-template-columns:1fr;}}

.tm-hidden-card { display:none; }
.tm-hidden-card.tm-visible { display:block; }

/* SPU Card */
.tm-spu-card { text-align:center;transition:transform 0.3s,box-shadow 0.3s;font-family:var(--tm-font); }
.tm-spu-photo { width:100%;aspect-ratio:var(--tm-photo-ratio,3/4);border-radius:var(--tm-photo-radius,12px);overflow:hidden;background:linear-gradient(135deg,#f0f0f5,#e8e8f0);margin-bottom:14px;box-shadow:var(--tm-shadow);transition:box-shadow 0.3s;position:relative;cursor:pointer; }
.tm-spu-card:hover .tm-spu-photo { box-shadow:0 12px 28px color-mix(in srgb,var(--tm-primary) 15%,transparent); }
.tm-spu-photo img { width:100%;height:100%;object-fit:cover;display:block;transition:transform 0.4s; }
.tm-spu-card:hover .tm-spu-photo img { transform:scale(1.03); }
.tm-spu-no-photo { width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:56px;background:linear-gradient(135deg,#e8e8f0,#f0f0f5); }
.tm-spu-photo::after { content:'';position:absolute;bottom:0;left:0;right:0;height:0;background:var(--tm-primary);transition:height 0.3s; }
.tm-spu-card:hover .tm-spu-photo::after { height:4px; }

/* Photo Hover Overlay — dark only */
.tm-photo-overlay { position:absolute;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.25);opacity:0;transition:opacity 0.3s;z-index:2;border-radius:inherit; }
.tm-spu-photo:hover .tm-photo-overlay,
.tm-teacher-photo:hover .tm-photo-overlay { opacity:1; }

.tm-spu-info { padding:0 4px; }
.tm-spu-tags { display:flex;gap:5px;flex-wrap:wrap;justify-content:center;margin-bottom:6px; }
.tm-spu-name { margin:0 0 4px;font-size:var(--tm-name-size,16px);font-weight:var(--tm-name-weight,700);color:var(--tm-name-color,#1f2937);line-height:1.4;font-family:var(--tm-font);cursor:pointer;transition:color 0.2s; }
.tm-spu-name:hover { color:var(--tm-primary); }
.tm-spu-position { margin:0;font-size:var(--tm-pos-size,13px);color:var(--tm-pos-color,#6b7280);line-height:1.5; }
.tm-spu-education { margin-top:8px;text-align:left; }
.tm-spu-edu-item { font-size:var(--tm-edu-size,13px);color:#6b7280;line-height:1.6;padding-left:12px;border-left:2px solid #e5e7eb;margin-bottom:4px; }
.tm-spu-contact-text { margin-top:8px;font-size:0.8em;color:#6b7280;text-align:left; }
.tm-spu-contact-text div { margin-bottom:2px; }
.tm-spu-contact { margin-top:10px;display:flex;justify-content:center;gap:8px; }
.tm-spu-contact a,.tm-spu-contact span { display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:8px;background:#f3f4f6;text-decoration:none;font-size:14px;transition:all 0.2s;cursor:pointer; }
.tm-spu-contact a:hover { background:var(--tm-primary);transform:translateY(-2px);box-shadow:0 4px 8px color-mix(in srgb,var(--tm-primary) 25%,transparent); }

/* Show More */
.tm-show-more-wrap { text-align:center;margin-top:24px; }
.tm-show-more-btn { padding:10px 32px;border-radius:8px;border:2px solid var(--tm-primary);background:transparent;color:var(--tm-primary);font-size:0.88em;font-weight:600;cursor:pointer;transition:all 0.2s;font-family:var(--tm-font); }
.tm-show-more-btn:hover,.tm-show-more-btn.tm-expanded { background:var(--tm-primary);color:#fff; }

/* Animation */
@keyframes tmFadeIn { from{opacity:0;transform:translateY(12px);} to{opacity:1;transform:translateY(0);} }
.tm-spu-grid-item { animation:tmFadeIn 0.4s ease both; }
.tm-spu-grid-item:nth-child(1){animation-delay:0s;} .tm-spu-grid-item:nth-child(2){animation-delay:.05s;} .tm-spu-grid-item:nth-child(3){animation-delay:.1s;}
.tm-spu-grid-item:nth-child(4){animation-delay:.15s;} .tm-spu-grid-item:nth-child(5){animation-delay:.2s;} .tm-spu-grid-item:nth-child(6){animation-delay:.25s;}


/* =============================================
   POPUP MODAL
   ============================================= */

/* Overlay */
.tm-popup-overlay {
    display:none; position:fixed; top:0; left:0; right:0; bottom:0;
    background:rgba(0,0,0,0.6); z-index:99999;
    justify-content:center; align-items:center; padding:20px;
    backdrop-filter:blur(4px); -webkit-backdrop-filter:blur(4px);
}
.tm-popup-overlay.tm-popup-active { display:flex; }

/* Container */
.tm-popup-container {
    background:#fff; border-radius:16px; max-width:860px; width:100%;
    max-height:90vh; overflow-y:auto; position:relative;
    box-shadow:0 25px 60px rgba(0,0,0,0.25);
    transform:translateY(30px) scale(0.95); opacity:0;
    transition:transform 0.35s cubic-bezier(0.34,1.56,0.64,1), opacity 0.3s ease;
}
.tm-popup-container.tm-popup-show {
    transform:translateY(0) scale(1); opacity:1;
}

/* Close button */
.tm-popup-close {
    position:absolute; top:12px; right:14px; z-index:10;
    width:36px; height:36px; border-radius:50%;
    border:none; background:rgba(0,0,0,0.06); color:#666;
    font-size:22px; line-height:1; cursor:pointer;
    transition:all 0.2s; display:flex; align-items:center; justify-content:center;
}
.tm-popup-close:hover { background:var(--tm-primary,#4338ca); color:#fff; transform:rotate(90deg); }

/* Body — 2 column layout */
.tm-popup-body {
    display:grid; grid-template-columns:320px 1fr; min-height:400px;
}

/* Column 1 — Photo + Education */
.tm-popup-col1 {
    background:linear-gradient(180deg, #f8f9fb 0%, #f1f3f8 100%);
    border-radius:16px 0 0 16px; padding:28px; display:flex; flex-direction:column; gap:20px;
    border-right:1px solid #eee;
}

.tm-popup-photo-wrap {
    width:100%; aspect-ratio:3/4; border-radius:12px; overflow:hidden;
    box-shadow:0 8px 24px rgba(0,0,0,0.1);
}
.tm-popup-photo { width:100%; height:100%; object-fit:cover; display:block; }
.tm-popup-no-photo {
    width:100%; height:100%; display:flex; align-items:center; justify-content:center;
    background:linear-gradient(135deg,#e0e0e8,#eee); font-size:80px;
}

.tm-popup-edu-section { }
.tm-popup-section-title {
    margin:0 0 10px; font-size:0.85em; font-weight:700;
    color:var(--tm-primary,#4338ca); text-transform:uppercase; letter-spacing:0.5px;
    font-family:var(--tm-font);
}
.tm-popup-edu-item {
    display:flex; align-items:flex-start; gap:8px;
    font-size:0.82em; color:#555; line-height:1.6; margin-bottom:6px;
    font-family:var(--tm-font);
}
.tm-popup-edu-bullet {
    flex-shrink:0; width:7px; height:7px; border-radius:50%;
    background:var(--tm-primary,#4338ca); margin-top:7px; opacity:0.6;
}

/* Column 2 — Info */
.tm-popup-col2 {
    padding:32px 30px; display:flex; flex-direction:column; justify-content:center;
}
.tm-popup-groups { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:10px; }
.tm-popup-groups .tm-group-tag { font-size:0.8em; padding:3px 12px; }

.tm-popup-name {
    margin:0 0 6px; font-size:1.5em; font-weight:800;
    color:var(--tm-name-color,#1f2937); line-height:1.3; font-family:var(--tm-font);
}
.tm-popup-position {
    margin:0 0 16px; font-size:1em; color:var(--tm-primary,#4338ca); font-weight:500;
    font-family:var(--tm-font);
}

.tm-popup-divider {
    width:50px; height:3px; background:var(--tm-primary,#4338ca);
    border-radius:2px; margin-bottom:20px; opacity:0.4;
}

.tm-popup-contact-section { margin-bottom:18px; }
.tm-popup-contact-list { display:flex; flex-direction:column; gap:8px; }
.tm-popup-contact-item {
    display:flex; align-items:center; gap:12px;
    padding:10px 14px; border-radius:10px; background:#f8f9fb;
    text-decoration:none; color:inherit; transition:all 0.2s;
    font-family:var(--tm-font);
}
a.tm-popup-contact-item:hover { background:color-mix(in srgb,var(--tm-primary) 8%,#fff); transform:translateX(4px); }
.tm-popup-icon { font-size:20px; flex-shrink:0; }
.tm-popup-label { display:block; font-size:0.7em; color:#999; text-transform:uppercase; letter-spacing:0.5px; font-weight:600; }
.tm-popup-value { display:block; font-size:0.92em; color:#333; font-weight:500; }

.tm-popup-social-section { }

/* Bio section */
.tm-popup-bio-section { margin-bottom:18px; }
.tm-popup-bio-content { font-size:0.9em; color:#444; line-height:1.7; font-family:var(--tm-font); }
.tm-popup-bio-content p { margin:0 0 8px; }
.tm-popup-bio-content ul,.tm-popup-bio-content ol { margin:4px 0 8px 18px; padding:0; }
.tm-popup-bio-content li { margin-bottom:3px; }
.tm-popup-bio-content a { color:var(--tm-primary); }
.tm-popup-social-list { display:flex; gap:8px; flex-wrap:wrap; }
.tm-popup-social-btn {
    display:inline-flex; align-items:center; gap:6px;
    padding:8px 18px; border-radius:8px; font-size:0.85em; font-weight:600;
    text-decoration:none; transition:all 0.2s; font-family:var(--tm-font);
}
.tm-popup-social-btn span { font-size:16px; }
.tm-popup-fb { background:#e8f0fe; color:#1877f2; }
.tm-popup-fb:hover { background:#1877f2; color:#fff; }
.tm-popup-web { background:#ecfdf5; color:#059669; }
.tm-popup-web:hover { background:#059669; color:#fff; }

/* Scrollbar in popup */
.tm-popup-container::-webkit-scrollbar { width:6px; }
.tm-popup-container::-webkit-scrollbar-thumb { background:#ddd; border-radius:3px; }
.tm-popup-container::-webkit-scrollbar-thumb:hover { background:#bbb; }

/* Loading spinner */
.tm-popup-loading {
    display:flex; align-items:center; justify-content:center;
    min-height:300px; padding:40px;
}
.tm-popup-spinner {
    width:36px; height:36px;
    border:3px solid #e5e7eb; border-top-color:var(--tm-primary,#4338ca);
    border-radius:50%; animation:tmPopSpin 0.7s linear infinite;
}
@keyframes tmPopSpin { to { transform:rotate(360deg); } }

/* =============================================
   POPUP RESPONSIVE
   ============================================= */
@media(max-width:768px) {
    .tm-popup-body {
        grid-template-columns:1fr; /* Stack to single column */
    }
    .tm-popup-col1 {
        border-radius:16px 16px 0 0; border-right:none; border-bottom:1px solid #eee;
        padding:20px;
    }
    .tm-popup-photo-wrap { max-width:260px; margin:0 auto; }
    .tm-popup-col2 { padding:20px; }
    .tm-popup-name { font-size:1.25em; }
    .tm-popup-container { max-width:95vw; border-radius:14px; }
}
@media(max-width:480px) {
    .tm-popup-overlay { padding:10px; }
    .tm-popup-photo-wrap { max-width:200px; }
    .tm-popup-col1 { padding:16px; }
    .tm-popup-col2 { padding:16px; }
}
