/* ========================================================
   วิทยาลัยอาชีวศึกษาเทศบาลเมืองนาสาร (Nasan Vocational College)
   ทำเนียบบุคลากร - ผังโครงสร้างองค์กรแยกตามฝ่ายและแผนก
   Theme: Crimson / Maroon Red, Royal Gold Borders, Crisp White
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700;800&family=Prompt:wght@300;400;500;600&display=swap');

:root {
    --maroon-dark: #450a0a;
    --maroon-primary: #881337;
    --maroon-crimson: #991b1b;
    --maroon-deep: #7f1d1d;
    --maroon-light: #fff1f2;
    --gold-border: #f59e0b;
    --gold-dark: #d97706;
    --gold-light: #fef3c7;
    --slate-bg: #f3f4f6;
    --card-border: #e2e8f0;
    --font-heading: 'Kanit', sans-serif;
    --font-body: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    font-family: var(--font-body);
    color: #1e293b;
    background-color: var(--slate-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6, .navbar-brand, .font-heading {
    font-family: var(--font-heading);
}

/* College Seal / Circular Logo */
.college-seal {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 3px solid #881337;
    background: radial-gradient(circle, #b91c1c 0%, #7f1d1d 100%);
    box-shadow: 0 4px 12px rgba(127, 29, 29, 0.25);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fef08a;
    font-size: 1.8rem;
    flex-shrink: 0;
}

/* Top Navbar */
.navbar-custom {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid #e2e8f0;
}

/* ========================================================
   ORGANIZATIONAL CHART CANVAS (ตามแบบรูปภาพตัวอย่าง)
   ======================================================== */

.org-chart-poster {
    background-color: #ffffff;
    background-image: 
        radial-gradient(circle at 15% 30%, rgba(148, 163, 184, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 85% 65%, rgba(148, 163, 184, 0.08) 0%, transparent 40%);
    border-radius: 20px;
    box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.08), 0 0 1px 1px rgba(0,0,0,0.05);
    position: relative;
    overflow: hidden;
    padding: 2.5rem 1.5rem;
}

/* Watermark Gears & Caps in Background */
.org-chart-poster::before {
    content: '';
    position: absolute;
    top: 5%;
    right: 3%;
    width: 280px;
    height: 280px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23cbd5e1' opacity='0.25'><path d='M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z'/><path d='M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1Z'/></svg>");
    background-repeat: no-repeat;
    background-size: contain;
    pointer-events: none;
    z-index: 0;
}

.org-chart-poster::after {
    content: '';
    position: absolute;
    top: 32%;
    left: 4%;
    width: 240px;
    height: 240px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23cbd5e1' opacity='0.25'><path d='M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z'/><path d='M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1Z'/></svg>");
    background-repeat: no-repeat;
    background-size: contain;
    pointer-events: none;
    z-index: 0;
}

/* Poster Header Section */
.poster-header {
    position: relative;
    z-index: 2;
    margin-bottom: 2.5rem;
}

.college-seal {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7f1d1d 0%, #b91c1c 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    box-shadow: 0 4px 12px rgba(127, 29, 29, 0.3);
    flex-shrink: 0;
}

.college-seal-img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    border-radius: 50%;
    background: #ffffff;
    padding: 3px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.15);
    border: 2.5px solid #b91c1c;
    flex-shrink: 0;
}

/* Big Crimson Banner: ทำเนียบบุคลากร ////// */
.crimson-banner-wrapper {
    max-width: 680px;
    margin: 1rem auto 0.5rem;
    position: relative;
}

.crimson-banner {
    background: linear-gradient(90deg, #7f1d1d 0%, #881337 50%, #991b1b 100%);
    color: white;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(127, 29, 29, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.crimson-banner h2 {
    font-size: 2.3rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: 0.04em;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.slanted-stripes {
    display: flex;
    gap: 6px;
    transform: skewX(-25deg);
}

.slanted-stripe {
    width: 10px;
    height: 36px;
    background: #ffffff;
    border-radius: 2px;
}

/* Subtitle Line: — แยกตามฝ่ายและแผนก — */
.subtitle-ribbon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: #450a0a;
    font-weight: 600;
    font-size: 1.15rem;
    margin-top: 0.75rem;
}

.subtitle-ribbon::before,
.subtitle-ribbon::after {
    content: '';
    display: inline-block;
    width: 90px;
    height: 3px;
    background-color: #881337;
    border-radius: 2px;
}

/* ========================================================
   TREE HIERARCHY CARDS & CONNECTING LINES
   ======================================================== */

.org-tree-container {
    position: relative;
    z-index: 2;
    overflow-x: auto;
    padding-bottom: 2rem;
}

.tree-flow {
    min-width: 1180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Single Vertical Stem Line */
.tree-stem-v {
    width: 3px;
    height: 32px;
    background-color: #991b1b;
    margin: 0 auto;
}

/* Executive Person Card (Director & Deputy Director) */
.exec-person-link {
    text-decoration: none;
    display: inline-block;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.exec-person-link:hover {
    transform: translateY(-4px) scale(1.03);
}

.exec-card-frame {
    width: 185px;
    background: white;
    border: 3px solid var(--gold-border);
    box-shadow: 0 8px 18px rgba(0,0,0,0.12);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.exec-card-frame .photo-box {
    width: 100%;
    height: 195px;
    background: #e0e7ff;
    overflow: hidden;
}

.exec-card-frame .photo-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.exec-card-frame .badge-box {
    background: #7f1d1d;
    color: white;
    padding: 0.6rem 0.35rem;
    text-align: center;
    border-top: 2px solid #b91c1c;
}

.exec-card-frame .badge-box .name {
    font-size: 0.95rem;
    font-weight: 700;
    display: block;
    line-height: 1.3;
    word-break: break-word;
}

.exec-card-frame .badge-box .title {
    font-size: 0.82rem;
    color: #fef08a;
    font-weight: 500;
    display: block;
    margin-top: 2px;
}

/* ========================================================
   DEPARTMENT TIERS & BRANCHING
   ======================================================== */

.dept-row-container {
    width: 100%;
    margin-top: 0;
    position: relative;
}

/* Horizontal Connector Line spanning across columns */
.dept-branch-h-bar {
    height: 3px;
    background-color: #991b1b;
    width: 87.5%;
    margin: 0 auto;
    position: relative;
}

/* The Departments Grid */
.dept-columns-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    width: 100%;
    margin-top: 0;
}

.dept-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* Little vertical tick down from the horizontal branch bar */
.dept-column::before {
    content: '';
    display: block;
    width: 3px;
    height: 18px;
    background-color: #991b1b;
}

/* Department Header Banner (Chamfered Roof / Tag Shape) */
.dept-header-banner {
    background: #7f1d1d;
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    padding: 0.5rem 0.75rem;
    width: 96%;
    clip-path: polygon(5% 0%, 95% 0%, 100% 100%, 0% 100%);
    box-shadow: 0 4px 10px rgba(127, 29, 29, 0.25);
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sub-branch horizontal line below department header */
.dept-sub-stem-v {
    width: 3px;
    height: 14px;
    background-color: #991b1b;
    margin: 0 auto;
}

.dept-sub-branch-h {
    height: 2px;
    background-color: #991b1b;
    width: 80%;
    margin: 0 auto;
    position: relative;
}

/* Personnel Cards under Department (Wraps flexibly when > 3 or < 3) */
.dept-staff-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
    margin-top: 0;
    position: relative;
    padding: 0 4px;
}

.staff-branch-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.staff-branch-item::before {
    content: '';
    display: block;
    width: 2px;
    height: 12px;
    background-color: #991b1b;
}

/* Staff Card Frame with legible full Thai name */
.staff-card-link {
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.staff-card-link:hover {
    transform: translateY(-4px) scale(1.04);
}

.staff-card-link:hover .staff-card-frame {
    box-shadow: 0 10px 22px rgba(127, 29, 29, 0.3);
    border-color: #b45309;
}

.staff-card-frame {
    width: 130px;
    background: white;
    border: 2px solid var(--gold-border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.staff-card-frame.is-head-card {
    border-color: #f59e0b !important;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.28) !important;
}

.head-banner-ribbon {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #b45309, #d97706);
    color: #ffffff !important;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    white-space: nowrap;
    z-index: 5;
    border: 1px solid rgba(254, 240, 138, 0.7);
    display: inline-flex;
    align-items: center;
    line-height: 1.3;
    letter-spacing: 0.01em;
}

.staff-card-frame .photo-box {
    width: 100%;
    height: 132px;
    background: #e0e7ff;
    overflow: hidden;
    position: relative;
}

.staff-card-frame .photo-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.staff-card-frame .badge-box {
    background: #7f1d1d;
    color: white;
    padding: 6px 3px 6px 3px;
    text-align: center;
    border-top: 1.5px solid #b91c1c;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 52px;
}

.staff-card-frame .badge-box .name {
    font-size: 0.63rem;
    font-weight: 700;
    display: block;
    line-height: 1.25;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    text-overflow: clip !important;
    color: #ffffff;
    margin-bottom: 2px;
}

.staff-card-frame .badge-box .title {
    font-size: 0.58rem;
    color: #fef08a;
    font-weight: 500;
    display: block;
    line-height: 1.2;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    text-overflow: clip !important;
}

.staff-card-frame .badge-box .head-title {
    font-size: 0.58rem;
    color: #fde047;
    font-weight: 700;
    display: block;
    line-height: 1.25;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    margin-top: 1px;
}

/* View Switcher Bar */
.view-mode-bar {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 50px;
    padding: 4px;
    display: inline-flex;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.view-mode-btn {
    border-radius: 50px;
    padding: 0.45rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: #475569;
    border: none;
    background: transparent;
    transition: all 0.15s ease;
}

.view-mode-btn.active {
    background: #7f1d1d;
    color: white;
    box-shadow: 0 4px 10px rgba(127, 29, 29, 0.25);
}

/* Badges and utilities */
.bg-purple-subtle { background-color: #f3e8ff !important; }
.text-purple { color: #7e22ce !important; }
.border-purple-subtle { border-color: #d8b4fe !important; }

.bg-amber-subtle { background-color: #fef3c7 !important; }
.text-amber-emphasis { color: #92400e !important; }
.border-amber-subtle { border-color: #fde68a !important; }

/* ========================================================
   ADMIN SUITE LAYOUT & SIDEBAR STYLING
   ======================================================== */

.admin-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    background-color: #f8fafc;
}

.admin-sidebar {
    width: 270px;
    min-width: 270px;
    max-width: 270px;
    background: #0f172a !important; /* Premium Dark Slate Navy */
    color: #94a3b8;
    min-height: 100vh;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1040;
    border-right: 1px solid #1e293b;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
}

/* Custom scrollbar for sidebar */
.admin-sidebar::-webkit-scrollbar {
    width: 5px;
}
.admin-sidebar::-webkit-scrollbar-track {
    background: #0f172a;
}
.admin-sidebar::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

/* Admin Sidebar Brand Header */
.admin-sidebar .border-bottom {
    border-color: rgba(255, 255, 255, 0.08) !important;
}

/* Admin Sidebar Navigation Items */
.admin-sidebar .nav-link {
    color: #94a3b8 !important;
    padding: 0.62rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: 8px;
    margin: 2px 14px;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
}

.admin-sidebar .nav-link i {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
    color: #64748b;
    transition: all 0.15s ease;
}

.admin-sidebar .nav-link:hover {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.08);
}

.admin-sidebar .nav-link:hover i {
    color: #f87171;
}

.admin-sidebar .nav-link.active {
    color: #ffffff !important;
    background: linear-gradient(135deg, #7f1d1d 0%, #991b1b 100%) !important;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(153, 27, 27, 0.4);
}

.admin-sidebar .nav-link.active i {
    color: #ffffff !important;
}

/* Group Headers inside sidebar */
.admin-sidebar .text-white-50.text-uppercase {
    color: #64748b !important;
    font-size: 0.68rem !important;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 1.1rem 1.5rem 0.35rem;
}

/* Bottom Logout Link */
.admin-sidebar .border-top {
    border-color: rgba(255, 255, 255, 0.08) !important;
}

.admin-sidebar .nav-link.text-danger {
    color: #f87171 !important;
}

.admin-sidebar .nav-link.text-danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5 !important;
}

.admin-sidebar .nav-link.text-danger i {
    color: #f87171;
}

/* Main Content Area */
.admin-content {
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    background-color: #f8fafc;
    display: flex;
    flex-direction: column;
}

.admin-content header {
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.admin-content main {
    background-color: #f8fafc;
    flex: 1;
}

/* Responsive Handling */
@media (max-width: 991.98px) {
    .admin-wrapper {
        flex-direction: column;
    }
    .admin-sidebar {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        height: auto;
        min-height: auto;
        position: relative;
        box-shadow: none;
    }
    .admin-sidebar:not(.show) {
        display: none !important;
    }
}

/* ========================================================
   TEACHER PORTAL MODERN NAVIGATION BAR
   ======================================================== */
.teacher-navbar {
    background-color: #0f172a !important; /* Premium Dark Slate Navy */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
}

.teacher-navbar .navbar-brand {
    white-space: nowrap !important;
}

.teacher-navbar .navbar-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: nowrap;
}

.teacher-navbar .nav-link {
    color: #94a3b8 !important;
    font-size: 0.86rem;
    font-weight: 500;
    white-space: nowrap !important;
    padding: 0.45rem 0.75rem !important;
    border-radius: 50px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1.3;
}

.teacher-navbar .nav-link i {
    font-size: 1rem;
    line-height: 1;
}

.teacher-navbar .nav-link:hover {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.1);
}

.teacher-navbar .nav-link.active {
    color: #ffffff !important;
    background: #2563eb !important; /* Royal Blue */
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.teacher-navbar .nav-link.nav-link-confirm {
    color: #fef08a !important;
    background: rgba(234, 179, 8, 0.15);
    border: 1px solid rgba(234, 179, 8, 0.35);
}

.teacher-navbar .nav-link.nav-link-confirm:hover {
    color: #ffffff !important;
    background: rgba(234, 179, 8, 0.3);
}

.teacher-navbar .nav-link.nav-link-confirm.active {
    color: #0f172a !important;
    background: #eab308 !important;
    border-color: #eab308;
    box-shadow: 0 2px 10px rgba(234, 179, 8, 0.4);
}

.teacher-navbar .btn-public-view {
    white-space: nowrap !important;
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.4rem 0.9rem;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #e2e8f0;
    background: transparent;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.teacher-navbar .btn-public-view:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border-color: #ffffff;
}

.teacher-navbar .teacher-user-btn {
    white-space: nowrap !important;
    font-size: 0.86rem;
    font-weight: 500;
    padding: 0.3rem 0.75rem;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.teacher-navbar .teacher-user-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

