/* General Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Lato", "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 50%, #cbd5e1 100%);
    overflow-x: hidden;
    color: #1e293b;
    padding-bottom: 0 !important;
}

/* Typography */
h1, h3 {
    font-family: "Playfair Display", Georgia, serif;
    font-weight: 700;
    color: #222;
    margin-top: 1.2em;
    margin-bottom: 0.5em;
}

h2, h4, h5, h6 {
    font-family: "Lato", sans-serif;
    font-weight: 500;
    color: #222;
    margin-top: 1.2em;
    margin-bottom: 0.5em;
}

a {
    font-family: "Lato", sans-serif;
    color: #0077b6;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

/* Focus styles for accessibility */
/* a:focus,
.nav-link:focus,
.dropdown-item:focus,
.dropdown-toggle:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
    border-radius: 4px;
} */

/* Skip link for screen readers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #007bff;
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 10000;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 6px;
}

/* Navbar */
.navbar {
    transition: all 0.3s ease;
}

.nav-item {
    margin-left: 1rem;
    font-size: 1rem;
}

/* Navigation Link Styles with Underline Animation */
.nav-link {
    font-size: large;
    position: relative;
    transition: color 0.3s ease;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #007bff, #0056b3);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform: translateX(-50%);
}

.nav-link:hover::before,
.nav-link.active::before,
.nav-link:focus::before {
    width: 100%;
}

.nav-link:hover,
.nav-link.active,
.nav-link:focus {
    color: #007bff !important;
}

.nav-link.active {
    font-weight: 500;
}

/* Dropdown toggle styles */
.dropdown-toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.dropdown-toggle-arrow {
    cursor: pointer;
    padding: 5px;
    margin-left: 10px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: inherit;
}

.dropdown-toggle-arrow:hover,
.dropdown-toggle-arrow:focus {
    color: #007bff;
}

.dropdown-toggle-arrow.rotated {
    transform: rotate(180deg);
}

/* Brand and logo */
.navbar-brand-wrapper {
    display: flex;
    align-items: center;
}

.navbar-brand {
    padding-left: 2rem;
    transition: transform 0.3s ease;
    font-size: larger;
}

.navbar-brand img {
    height: 6rem;
    width: auto;
}

.navbar-brand:hover,
.navbar-brand:focus {
    transform: scale(1.05);
}

.mobile-logo {
    height: 60px;
    display: block;
    width: auto;
}

.vertical-line {
    width: 3px;
    height: 60px;
    background-color: #514b4b;
    margin: 0 12px;
    position: relative;
    top: 10px;
}

.defence-text {
    font-family: 'Uni Sans', sans-serif;
    font-size: 1.5rem;
    font-weight: bold;
    color: #3d3a3a !important;
    text-transform: uppercase;
    margin: 0;
    line-height: 1;
    display: flex;
    position: relative;
    top: 10px;
}

/* Dropdown item animations */
.dropdown-item {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.dropdown-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, rgba(0, 123, 255, 0.1), rgba(0, 86, 179, 0.1));
    transition: width 0.3s ease;
}

.dropdown-item:hover::before,
.dropdown-item:focus::before {
    width: 100%;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: transparent;
    color: #007bff;
    transform: translateX(5px);
}

/* Offcanvas enhancements for mobile */
.offcanvas-body {
    padding-top: 1rem;
}

/* Search icon styling */
.nav-link i {
    font-size: 1.1em;
    transition: transform 0.3s ease;
}

.nav-link:hover i,
.nav-link:focus i {
    transform: scale(1.1);
}

/* Navbar li spacing */
.navbar li {
    margin: 0 10px;
}

/* Slide down animation */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced Search Dropdown Styles */
.search-dropdown {
    min-width: 350px;
    max-width: 500px;
    padding: 1.5rem;
    border: none;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
    border-radius: 16px;
    background: white;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 1050;
}

.search-container {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    align-items: stretch;
}

.search-input {
    flex: 1;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 0.875rem 1rem;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: #f8f9fa;
    font-family: "Lato", sans-serif;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.search-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.15), 0 4px 8px rgba(0, 0, 0, 0.1);
    outline: none;
    background: white;
}

.search-input::placeholder {
    color: #6c757d;
    font-style: italic;
}

.search-btn {
    border-radius: 12px;
    padding: 0.875rem 1.25rem;
    border: none;
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    transition: all 0.3s ease;
    min-width: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.2);
}

.search-btn:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 123, 255, 0.3);
}

.search-btn:active {
    transform: translateY(0);
}

.search-results {
    max-height: 450px;
    overflow-y: auto;
    border-top: 1px solid #e9ecef;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
}

.search-results::-webkit-scrollbar {
    width: 6px;
}

.search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.search-result-item {
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid transparent;
    background: #f8f9fa;
    position: relative;
    overflow: hidden;
}

.search-result-item:hover {
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.08), rgba(0, 86, 179, 0.08));
    border-color: rgba(0, 123, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
}

.search-result-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(135deg, #007bff, #0056b3);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.search-result-item:hover::before {
    opacity: 1;
}

.search-result-title {
    font-weight: 600;
    color: #007bff;
    margin-bottom: 0.375rem;
    font-size: 1rem;
    line-height: 1.3;
    font-family: "Lato", sans-serif;
}

.search-result-category {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 0.375rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-result-description {
    font-size: 0.875rem;
    color: #495057;
    line-height: 1.5;
    margin-bottom: 0;
}

.search-loading {
    text-align: center;
    color: #6c757d;
    padding: 2rem;
    font-size: 0.95rem;
}

.search-loading i {
    color: #007bff;
    margin-right: 0.5rem;
}

.search-no-results {
    text-align: center;
    color: #6c757d;
    padding: 2.5rem;
    font-style: italic;
    font-size: 0.95rem;
}

/* Enhanced Mobile/Offcanvas Search Styles */
@media (max-width: 1199.2px) {
    .search-dropdown {
        min-width: 100%;
        max-width: 100%;
        position: static !important;
        transform: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        display: none;
        margin: 1rem 0;
        border-left: 4px solid #007bff;
        background: linear-gradient(135deg, #ffffff, #f8f9fa);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
        border-radius: 16px;
        padding: 1.5rem;
    }
    
    .search-dropdown.show {
        display: block;
        animation: slideDown 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }
    
    .search-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .search-input {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
        border-radius: 12px;
        background: white;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }
    
    .search-btn {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
        border-radius: 12px;
        background: linear-gradient(135deg, #007bff, #0056b3);
        box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
    }
    
    .search-btn:hover {
        background: linear-gradient(135deg, #0056b3, #004085);
        transform: translateY(-1px);
    }
    
    .search-results {
        max-height: 350px;
        margin-top: 1rem;
        padding-top: 1rem;
    }
    
    .search-result-item {
        margin-bottom: 1rem;
        padding: 1.25rem;
        border-radius: 12px;
        background: white;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }
    
    .search-result-item:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 16px rgba(0, 123, 255, 0.12);
    }
    
    .search-result-title {
        font-size: 1.05rem;
        margin-bottom: 0.5rem;
    }
    
    .search-result-category {
        font-size: 0.85rem;
        margin-bottom: 0.5rem;
    }
    
    .search-result-description {
        font-size: 0.9rem;
        line-height: 1.6;
    }
    
    /* Special styling for offcanvas */
    .offcanvas .search-dropdown {
        margin: 1rem -1rem;
        border-radius: 0;
        border-left: none;
        border-top: 4px solid #007bff;
        box-shadow: inset 0 4px 8px rgba(0, 123, 255, 0.1);
    }
    
    /* Search icon in offcanvas */
    .offcanvas .nav-link i {
        font-size: 1.2rem;
    }
}

@media (max-width: 576px) {
    .search-dropdown {
        margin: 0.75rem 0;
        padding: 1.25rem;
        border-radius: 12px;
    }
    
    .search-input {
        font-size: 0.95rem;
        padding: 0.875rem;
    }
    
    .search-btn {
        padding: 0.875rem;
        font-size: 0.95rem;
    }
    
    .search-result-item {
        padding: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .search-result-title {
        font-size: 0.95rem;
    }
    
    .search-result-category {
        font-size: 0.8rem;
    }
    
    .search-result-description {
        font-size: 0.85rem;
    }
    
    .offcanvas .search-dropdown {
        margin: 0.75rem -0.75rem;
        padding: 1rem;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .search-dropdown {
        padding: 1rem;
    }
    
    .search-container {
        gap: 0.75rem;
    }
    
    .search-input {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .search-btn {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .search-results {
        max-height: 300px;
    }
    
    .search-result-item {
        padding: 0.875rem;
    }
}

/* Search result highlighting */
mark {
    background-color: rgba(255, 193, 7, 0.4);
    padding: 0.15em 0.3em;
    border-radius: 4px;
    font-weight: 600;
    color: #856404;
}

/* Desktop Styles */
@media (min-width: 1199.2px) {
    /* Hide dropdown arrows on desktop */
    .dropdown-toggle-arrow {
        display: none;
    }
    
    /* Desktop dropdown styles */
    .navbar-nav .search-dropdown {
        min-width: 500px !important;
        max-width: 600px;
    }
    .navbar-nav .dropdown-menu {
        display: block;
        opacity: 0;
        visibility: hidden;
        transform: translateY(10px);
        transition: all 0.3s ease;
        position: absolute;
        top: 100%;
        left: 0;
        margin-top: 0;
        border: none;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        border-radius: 8px;
        z-index: 1000;
        min-width: 220px;
        max-width: 400px;
        width: auto;
    }
    
    .navbar-nav .dropdown:hover > .dropdown-menu,
    .navbar-nav .dropdown:focus-within > .dropdown-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
    
    .navbar-nav .dropdown-toggle::after {
        display: none;
    }
    
    /* Desktop search dropdown positioning */
    .search-dropdown {
        position: absolute;
        top: 100%;
        right: 0;
        left: auto;
        margin-top: 0.5rem;
        z-index: 1050;
    }
    
    /* Submenu styles */
    .dropdown-submenu {
        position: relative;
    }
    
    .dropdown-submenu .submenu {
        display: block;
        opacity: 0;
        visibility: hidden;
        transform: translateX(10px);
        transition: all 0.3s ease;
        position: absolute;
        top: 0;
        left: 100%;
        margin-left: 5px;
        border: none;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        border-radius: 8px;
        min-width: 220px;
        max-width: 400px;
        width: auto;
        z-index: 1001;
    }
    
    .dropdown-submenu:hover > .submenu,
    .dropdown-submenu:focus-within > .submenu {
        opacity: 1;
        visibility: visible;
        transform: translateX(0);
    }
    
    /* Third level submenu desktop styles */
    .dropdown-submenu .dropdown-submenu .submenu-level-2 {
        position: absolute;
        top: 0;
        left: 100%;
        margin-left: 5px;
        background: white;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        border-radius: 8px;
        min-width: 220px;
        max-width: 400px;
        width: auto;
        z-index: 1002;
        opacity: 0;
        visibility: hidden;
        transform: translateX(10px);
        transition: all 0.3s ease;
        display: block;
    }
    
    .dropdown-submenu .dropdown-submenu:hover > .submenu-level-2,
    .dropdown-submenu .dropdown-submenu:focus-within > .submenu-level-2 {
        opacity: 1;
        visibility: visible;
        transform: translateX(0);
    }
    
    .dropdown-submenu .dropdown-submenu .dropdown-toggle-arrow {
        display: none;
    }
    
    .dropdown-submenu .dropdown-submenu {
        position: relative;
    }
    
    /* Allow text wrapping in desktop dropdowns */
    .dropdown-item {
        white-space: normal;
        word-wrap: break-word;
        word-break: break-word;
        hyphens: auto;
        padding: 0.5rem 1rem;
        line-height: 1.4;
    }
}

/* Mobile Styles */
@media (max-width: 991px) {
    /* Show dropdown arrows on mobile */
    .dropdown-toggle-arrow {
        display: inline-block;
    }
    
    /* Main dropdown styles */
    .dropdown-menu {
        position: static !important;
        transform: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        display: none;
        box-shadow: none;
        border: none;
        background: rgba(248, 249, 250, 0.95);
        margin: 0.5rem 0;
        border-radius: 8px;
        padding: 0.5rem 0;
        border-left: 3px solid #007bff;
        width: 100%;
    }
    
    .dropdown-menu.show {
        display: block;
        animation: slideDown 0.3s ease-out;
    }
    
    /* Submenu styles */
    .dropdown-submenu .submenu {
        position: static !important;
        transform: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        display: none;
        box-shadow: none;
        margin: 0.25rem 0 0.25rem 1rem;
        background: rgba(233, 236, 239, 0.95);
        border-radius: 6px;
        padding: 0.25rem 0;
        border-left: 2px solid #6c757d;
        width: calc(100% - 1rem);
    }
    
    .dropdown-submenu .submenu.show {
        display: block;
        animation: slideDown 0.2s ease-out;
    }
    
    /* Third level submenu mobile styles */
    .submenu-level-2 {
        position: static !important;
        transform: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        display: none;
        box-shadow: none;
        margin: 0.25rem 0 0.25rem 1.5rem;
        background: rgba(220, 225, 230, 0.95);
        border-radius: 6px;
        padding: 0.25rem 0;
        border-left: 2px solid #28a745;
        width: calc(100% - 1.5rem);
    }
    
    .submenu-level-2.show {
        display: block;
        animation: slideDown 0.2s ease-out;
    }
    
    /* Mobile dropdown item styling */
    .dropdown-item {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
        margin: 0 0.5rem;
        white-space: normal;
        word-wrap: break-word;
        word-break: break-word;
        hyphens: auto;
        line-height: 1.4;
    }
    
    .dropdown-submenu .dropdown-item {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        flex-wrap: wrap;
    }
    
    /* Remove desktop hover effects on mobile */
    .dropdown-item:hover,
    .dropdown-item:focus {
        transform: none;
        background-color: rgba(0, 123, 255, 0.1);
    }
    
    /* Mobile navigation item styling */
    .nav-item {
        margin: 0;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    .nav-item:last-child {
        border-bottom: none;
    }
    
    .nav-link {
        padding: 1rem 0;
        font-size: 1.1rem;
    }
}

/* Small mobile styles */
@media (max-width: 576px) {
    .mobile-logo { 
        height: 45px; 
    }
    
    .vertical-line { 
        height: 45px; 
    }
    
    .defence-text { 
        font-size: 1.2rem; 
    }
    
    .navbar-brand {
        padding-left: 1rem;
        font-size: 1.2rem;
    }
    
    .navbar-brand img {
        height: 45px;
    }
    
    .navbar .container-fluid {
        height: 4rem;
        margin-top: 0;
    }
    
    .dropdown-item {
        font-size: 0.9rem;
        padding: 0.6rem 0.8rem;
    }
}

/* Extra small mobile styles */
@media (max-width: 480px) {
    .dropdown-item {
        font-size: 0.85rem;
        padding: 0.5rem 0.7rem;
        margin: 0 0.3rem;
    }
    
    .dropdown-submenu .submenu {
        margin: 0.25rem 0 0.25rem 0.5rem;
        width: calc(100% - 0.5rem);
    }
    
    .submenu-level-2 {
        margin: 0.25rem 0 0.25rem 0.75rem;
        width: calc(100% - 0.75rem);
    }

    .top-br{
        display: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .nav-link::before {
        background: currentColor;
    }
    
    .dropdown-item::before {
        background: currentColor;
        opacity: 0.2;
    }
    
    .search-dropdown {
        border: 2px solid #000;
    }
    
    .search-input {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .nav-link::before,
    .dropdown-item::before {
        transition: none;
    }
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Additional improvements for better text handling */
.dropdown-toggle-wrapper {
    align-items: flex-start;
}

/* Ensure dropdown items have proper spacing */
.dropdown-menu .dropdown-item:not(:last-child) {
    margin-bottom: 0.1rem;
}

/* Prevent text cutoff in very long menu items */
.dropdown-item {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* On hover, show full text */
.dropdown-item:hover,
.dropdown-item:focus {
    text-overflow: clip;
    overflow: visible;
}