/* --- Global Styles & Variables --- */
:root {
    --color-primary: #004d99; /* Deep Institutional Blue */
    --color-secondary: #ffc107; /* Gold/Saffron Accent */
    --color-text-dark: #343a40;
    --color-text-light: #ffffff;
    --color-bg-light: #f8f9fa; /* Off-White Background */
    --font-stack: 'Poppins', sans-serif;
    --nav-height: 50px; /* Approximate height of the nav bar for calculation */
}

body {
    font-family: var(--font-stack);
    margin: 0;
    padding: 0;
    background-color: var(--color-bg-light);
    color: var(--color-text-dark);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

a {
    text-decoration: none;
    color: var(--color-primary);
    transition: color 0.3s ease;
}

/* --- Top Bar & Header --- */
.top-bar {
    background-color: #003366;
    padding: 8px 0;
    font-size: 0.85em;
}

.top-bar .container {
    display: flex;
    justify-content: flex-end;
    gap: 20px;
}

.top-bar a {
    color: #cce0ff;
    padding: 3px 0;
}

.top-bar a:hover {
    color: var(--color-secondary);
}

.top-bar i {
    margin-right: 5px;
}

header {
    background-color: var(--color-bg-light);
    padding: 15px 0;
    border-bottom: 5px solid var(--color-primary);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.svims-logo, .ttd-logo {
    height: 90px;
    width: auto;
    object-fit: contain;
}

.branding-center {
    text-align: center;
    flex-grow: 1;
    margin: 0 20px;
}

.site-title {
    color: var(--color-primary);
    font-size: 2.2em;
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.subtitle {
    color: #6c757d;
    font-size: 1em;
    margin: 5px 0 0 0;
    font-weight: 300;
}

/* --- Navigation Menu (Desktop) --- */
.menu-toggle {
    display: none;
}

nav {
    background-color: var(--color-primary);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.main-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: space-between;
}

nav li {
    position: relative;
    /* Important: The hover effect must be on the main 'li' for the submenu to stay visible */
}

nav li a {
    display: block;
    color: var(--color-text-light);
    padding: 15px 16px; 
    font-weight: 600;
    transition: background-color 0.3s, color 0.3s;
    font-size: 0.9em; 
}

nav li a:hover {
    background-color: #003a73;
}

/* --- Dropdown Styles (Standard Vertical) --- */
.dropdown {
    display: none;
    position: absolute;
    top: 100%;
    /* margin-top: -5px; is the old trick, now superseded by the .has-dropdown::after or ::before */
    
    background-color: var(--color-text-light);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    min-width: 250px;
    z-index: 1000;
    list-style: none;
    padding: 10px 0; /* Adjusted padding for cleaner look */
    border-top: 4px solid var(--color-secondary);
}

/* FIX: Use an invisible pseudo-element to bridge the tiny gap above all dropdowns */
.has-dropdown:hover > .dropdown {
    display: block;
}

/* Fallback/Standard fix for gap */
.has-dropdown::after {
    content: '';
    position: absolute;
    top: 45px; /* Adjust to cover the gap below the link */
    left: 0;
    width: 100%;
    height: 10px; /* Invisible hover strip */
    z-index: 1000;
    /* background: rgba(255,0,0,0.1); /* Uncomment to visualize the hover area */
}

.dropdown li a {
    color: var(--color-text-dark);
    padding: 10px 15px;
    font-weight: 400;
}

.dropdown li a:hover {
    background-color: var(--color-bg-light);
    color: var(--color-primary);
}

/* --- Submenu (Nested Dropdowns, for About menu) --- */
.has-submenu {
    position: relative;
}

.submenu {
    display: none;
    position: absolute;
    top: 0;
    left: 100%; /* Appears to the right of the parent item */
    background-color: var(--color-text-light);
    box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.2);
    min-width: 200px;
    z-index: 1010;
    list-style: none;
    padding: 10px 0;
    border-left: 3px solid var(--color-primary);
}

.has-submenu:hover > .submenu {
    display: block;
}

.has-submenu > a i {
    float: right;
    margin-top: 3px;
}

/* --- Departments Grid (Wide, 6-Column) --- */

/* THE CRUCIAL FIX FOR WIDE MENUS */
.departments-menu-item {
    /* Set the parent li (Departments) to handle the wide hover area */
    overflow: visible; 
}

.departments-menu-item:hover > .departments-grid {
    display: grid;
}

.departments-grid {
    display: none; /* Must be controlled by the hover above */
    grid-template-columns: repeat(6, 1fr); 
    min-width: 1200px; 
    padding: 15px;
    gap: 4px;
    /* This calculation centers the wide grid and aligns it correctly under the menu bar */
    left: -200px; 
    top: 100%; /* Ensure it starts right below the nav bar */
}

.departments-grid li {
    padding: 5px 0;
    white-space: nowrap;
}

.departments-grid li a {
    font-size: 0.85em; 
}

.departments-grid li a i {
    color: var(--color-secondary);
    margin-right: 5px;
}


/* --- Main Content Layout --- */
main {
    padding-top: 30px;
}

.hero-section {
    display: flex;
    gap: 30px;
    margin-bottom: 40px;
}

.slider {
    flex: 3;
    overflow: hidden;
    position: relative;
    max-height: 450px;
    border-radius: 10px;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.slide img {
    width: 100%;
    height: 450px;
    object-fit: cover;
    display: none;
}

.slide.active img {
    display: block;
}

.latest-updates {
    flex: 1.2;
    background-color: var(--color-text-light);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.05);
    border-left: 5px solid var(--color-secondary);
}

.latest-updates .title {
    color: var(--color-primary);
    font-size: 1.4em;
    margin-top: 0;
    margin-bottom: 15px;
    font-weight: 600;
}

.latest-updates ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.latest-updates li {
    padding: 8px 0;
    border-bottom: 1px dotted #ccc;
    font-size: 0.95em;
}

.latest-updates li i {
    color: var(--color-secondary);
    margin-right: 5px;
}


.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr; 
    gap: 30px;
    margin-bottom: 40px;
}

.section-title {
    color: var(--color-primary);
    font-size: 1.8em;
    border-bottom: 2px solid var(--color-secondary);
    padding-bottom: 5px;
    margin-bottom: 15px;
}

.about-svims, .director-message {
    background-color: var(--color-text-light);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.director-card {
    text-align: center;
}

.director-photo {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid var(--color-secondary);
    margin-bottom: 15px;
}

.director-card .name {
    color: var(--color-primary);
    margin: 5px 0;
    font-size: 1.2em;
}

.director-card .title, .qualification {
    margin: 3px 0;
    font-size: 0.9em;
    color: #6c757d;
}

.btn-primary {
    display: inline-block;
    background-color: var(--color-primary);
    color: var(--color-text-light);
    padding: 8px 20px;
    border-radius: 5px;
    margin-top: 15px;
    transition: background-color 0.3s;
}

.btn-primary:hover {
    background-color: #003a73;
    color: var(--color-text-light);
}

.quick-access-cards {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.card-link {
    background-color: var(--color-primary);
    color: var(--color-text-light);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    font-weight: 600;
    font-size: 1.1em;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, background-color 0.3s;
}

.card-link i {
    display: block;
    font-size: 2em;
    margin-bottom: 10px;
    color: var(--color-secondary);
}

.card-link:hover {
    background-color: #003a73;
    transform: translateY(-5px);
}

/* --- Footer --- */
footer {
    background-color: var(--color-primary);
    color: var(--color-text-light);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    padding: 40px 20px;
    gap: 30px;
}

.footer-col {
    flex: 1;
}

.footer-col h4 {
    color: var(--color-secondary);
    font-size: 1.2em;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.footer-col p, .footer-col li {
    font-size: 0.9em;
    margin-bottom: 10px;
}

.footer-col ul {
    list-style: none;
    padding: 0;
}

.footer-col a {
    color: #cce0ff;
    transition: color 0.3s;
}

.footer-col a:hover {
    color: var(--color-secondary);
}

.footer-col i {
    margin-right: 8px;
}

.ttd-footer-logo {
    height: 80px;
    margin-bottom: 10px;
}

.copyright {
    background-color: #003366;
    text-align: center;
    padding: 15px 0;
    font-size: 0.8em;
}

.copyright a {
    color: #cce0ff;
}

/* --- Responsiveness (Mobile & Tablet) --- */
@media (max-width: 1250px) {
    /* Adjust department grid for slightly smaller screens */
    .departments-grid {
        grid-template-columns: repeat(4, 1fr); 
        min-width: 900px;
        left: -150px; 
    }
}

@media (max-width: 992px) {
    /* Tablet/Mobile Styles */
    .site-title {
        font-size: 1.6em;
    }
    .svims-logo, .ttd-logo {
        height: 70px;
    }
    
    .hero-section {
        flex-direction: column;
        gap: 20px;
    }
    
    .slider img {
        height: 300px;
    }

    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .menu-toggle {
        display: block;
        background-color: #003366;
        color: white;
        text-align: center;
        padding: 12px;
        cursor: pointer;
    }
    
    nav {
        display: none;
        position: absolute;
        width: 100%;
        z-index: 1001;
    }

    .main-menu {
        flex-direction: column;
    }

    .dropdown {
        position: static;
        box-shadow: none;
        background-color: #003a73;
        min-width: unset;
        margin-top: 0; 
        padding-top: 0; 
    }
    
    /* Remove pseudo-element fix on mobile */
    .has-dropdown::after {
        content: none;
    }

    .dropdown li a {
        padding-left: 30px;
        color: #cce0ff;
    }

    /* Submenus on mobile stack vertically */
    .submenu {
        position: static;
        box-shadow: none;
        background-color: #00264d; /* Slightly darker shade */
        border-left: none;
    }
    .submenu li a {
        padding-left: 45px;
    }

    /* Department dropdown uses a single column on mobile */
    .departments-grid {
        grid-template-columns: 1fr; 
        min-width: unset;
        left: 0;
    }
    .departments-grid li a {
        font-size: 0.9em;
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
    }
}