html {
    font-size: 14px;
    scroll-behavior: smooth;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    background-color: var(--bs-body-bg);
    transition: background-color 0.3s ease;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ===== Page Transition ===== */
.fade-in {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Fancy Navbar ===== */
.navbar-fancy {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    padding: 0.6rem 1.25rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
    border: none;
    backdrop-filter: blur(10px);
}

.navbar-fancy .navbar-brand {
    font-weight: 700;
    font-size: 1.35rem;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #00d2ff, #7b68ee);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: transform 0.2s ease;
}

.navbar-fancy .navbar-brand:hover {
    transform: scale(1.03);
}

.navbar-fancy .brand-icon {
    font-size: 1.4rem;
    -webkit-text-fill-color: #00d2ff;
    filter: drop-shadow(0 0 6px rgba(0, 210, 255, 0.4));
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(0, 210, 255, 0.3)); }
    50% { filter: drop-shadow(0 0 10px rgba(0, 210, 255, 0.6)); }
}

.navbar-fancy .nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
    font-weight: 500;
    padding: 0.5rem 0.875rem !important;
    border-radius: 0.5rem;
    transition: all 0.25s ease;
    font-size: 0.925rem;
}

.navbar-fancy .nav-link:hover,
.navbar-fancy .nav-link:focus {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.08);
}

.navbar-fancy .nav-link i {
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.navbar-fancy .nav-link:hover i {
    opacity: 1;
}

/* Underline effect — only for non-dropdown nav links */
.navbar-fancy .nav-item:not(.dropdown) > .nav-link {
    position: relative;
}

.navbar-fancy .nav-item:not(.dropdown) > .nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #00d2ff, #7b68ee);
    transition: all 0.3s ease;
    transform: translateX(-50%);
    border-radius: 1px;
}

.navbar-fancy .nav-item:not(.dropdown) > .nav-link:hover::after {
    width: 60%;
}

/* Dropdown caret animation */
.navbar-fancy .dropdown-toggle::after {
    transition: transform 0.3s ease;
}

.navbar-fancy .dropdown.show .dropdown-toggle::after {
    transform: rotate(180deg);
}

/* ===== Fancy Dropdown Menus ===== */
.dropdown-menu-fancy {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.12);
    padding: 0.5rem;
    animation: fadeInDown 0.25s ease;
    overflow: hidden;
}

.dropdown-menu-fancy .dropdown-item {
    border-radius: 0.5rem;
    padding: 0.6rem 1rem;
    font-weight: 450;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.dropdown-menu-fancy .dropdown-item i {
    color: #7b68ee;
    font-size: 0.9rem;
}

.dropdown-menu-fancy .dropdown-item:hover {
    background: linear-gradient(135deg, #e8f4fd, #f0e6ff);
    transform: translateX(4px);
    color: #0f3460;
}

.dropdown-menu-fancy .dropdown-divider {
    margin: 0.25rem 0.5rem;
    opacity: 0.15;
}

[data-bs-theme="dark"] .dropdown-menu-fancy {
    --bs-dropdown-bg: #1a1a2e;
    --bs-dropdown-color: rgba(255, 255, 255, 0.85);
    --bs-dropdown-link-color: rgba(255, 255, 255, 0.85);
    --bs-dropdown-link-hover-color: #e0e0e0;
    --bs-dropdown-link-hover-bg: transparent;
    background: #1a1a2e !important;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
}

[data-bs-theme="dark"] .dropdown-menu-fancy .dropdown-item {
    color: rgba(255, 255, 255, 0.85);
}

[data-bs-theme="dark"] .dropdown-menu-fancy .dropdown-item i {
    color: #00d2ff;
}

[data-bs-theme="dark"] .dropdown-menu-fancy .dropdown-item:hover {
    background: linear-gradient(135deg, #1a3a5c, #2d1b69);
    color: #e0e0e0;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Theme Toggle Button ===== */
#themeToggle {
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1rem;
    transition: transform 0.3s ease, background 0.3s ease;
}

#themeToggle:hover {
    transform: rotate(20deg) scale(1.1);
}

/* ===== Footer ===== */
.footer-fancy {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.footer-fancy i {
    color: #00d2ff;
}

.footer-link {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: color 0.2s ease;
    font-size: 0.875rem;
}

.footer-link:hover {
    color: #00d2ff;
}

/* ===== Mobile Responsive Adjustments ===== */
@media (max-width: 767.98px) {
    /* Navbar compact layout */
    .navbar-fancy {
        padding: 0.4rem 0.75rem;
    }

    .navbar-fancy .navbar-brand {
        font-size: 1.15rem;
    }

    .navbar-fancy .brand-icon {
        font-size: 1.2rem;
    }

    /* Smooth collapse container */
    .navbar-collapse {
        background: rgba(26, 26, 46, 0.97);
        border-radius: 0.75rem;
        padding: 0.5rem 0.75rem;
        margin-top: 0.5rem;
        backdrop-filter: blur(12px);
        max-height: 75vh;
        overflow-y: auto;
    }

    /* Larger tap targets for nav items */
    .navbar-fancy .nav-link {
        padding: 0.65rem 1rem !important;
        font-size: 0.95rem;
        border-radius: 0.5rem;
    }

    /* Visual separator between nav groups */
    .navbar-nav .nav-item + .nav-item {
        border-top: 1px solid rgba(255, 255, 255, 0.06);
    }

    /* Dropdown menus inline on mobile */
    .navbar-collapse .dropdown-menu-fancy {
        border-radius: 0.5rem;
        box-shadow: none;
        background: rgba(255, 255, 255, 0.06) !important;
        border: none;
        margin-top: 0.25rem;
        margin-bottom: 0.25rem;
        padding: 0.25rem 0.5rem;
    }

    /* Larger touch-friendly dropdown items */
    .navbar-collapse .dropdown-menu-fancy .dropdown-item {
        color: rgba(255, 255, 255, 0.85);
        padding: 0.7rem 1rem;
        font-size: 0.9rem;
        border-radius: 0.4rem;
    }

    .navbar-collapse .dropdown-menu-fancy .dropdown-item i {
        color: #00d2ff;
    }

    .navbar-collapse .dropdown-menu-fancy .dropdown-item:hover,
    .navbar-collapse .dropdown-menu-fancy .dropdown-item:active {
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
        transform: none;
    }

    .navbar-collapse .dropdown-menu-fancy .dropdown-divider {
        border-color: rgba(255, 255, 255, 0.08);
        margin: 0.15rem 0.5rem;
    }

    /* Content area breathing room */
    main {
        padding-top: 1rem !important;
    }

    /* Footer compact on mobile */
    .footer-fancy {
        font-size: 0.8rem;
        padding: 0.25rem 0;
    }

    .footer-link {
        font-size: 0.8rem;
    }
}

/* Small phones (≤ 375px) */
@media (max-width: 375px) {
    .navbar-fancy .navbar-brand span {
        font-size: 1rem;
    }

    .navbar-fancy .brand-icon {
        font-size: 1.1rem;
    }

    #themeToggle {
        width: 32px;
        height: 32px;
        font-size: 0.875rem;
    }
}

/* Safe area for notched devices (iOS, etc.) */
@supports (padding: env(safe-area-inset-bottom)) {
    .footer-fancy {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .navbar-fancy {
        padding-top: env(safe-area-inset-top);
    }
}

/* ===== Skip-to-Content (Accessibility) ===== */
.skip-to-content {
    position: absolute;
    top: -100%;
    left: 1rem;
    z-index: 9999;
    padding: 0.75rem 1.5rem;
    background: #0f3460;
    color: #fff;
    border-radius: 0 0 0.5rem 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: top 0.3s ease;
}

.skip-to-content:focus {
    top: 0;
    outline: 2px solid #00d2ff;
    outline-offset: 2px;
}

/* ===== Active Nav Link Indicator ===== */
.navbar-fancy .active-link {
    color: #fff !important;
    background: rgba(0, 210, 255, 0.12);
}

.navbar-fancy .nav-item:not(.dropdown) > .active-link::after {
    width: 60%;
    background: linear-gradient(90deg, #00d2ff, #7b68ee);
}

.dropdown-menu-fancy .active-link {
    background: linear-gradient(135deg, #e8f4fd, #f0e6ff) !important;
    color: #0f3460 !important;
    font-weight: 600;
}

[data-bs-theme="dark"] .dropdown-menu-fancy .active-link {
    background: linear-gradient(135deg, #1a3a5c, #2d1b69) !important;
    color: #e0e0e0 !important;
}

/* ===== Scroll-to-Top Button ===== */
.scroll-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1050;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #0f3460, #1a1a2e);
    color: #00d2ff;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    cursor: pointer;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 210, 255, 0.3);
}

@media (max-width: 767.98px) {
    .scroll-to-top {
        bottom: 1.25rem;
        right: 1.25rem;
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* ===== Focus Visible Improvements ===== */
:focus-visible {
    outline: 2px solid #00d2ff;
    outline-offset: 2px;
}

.navbar-fancy .nav-link:focus-visible,
.dropdown-menu-fancy .dropdown-item:focus-visible {
    outline: 2px solid #00d2ff;
    outline-offset: -2px;
}
