
html {
    overflow-y: scroll;
}

/* Reset default browser styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #2b2d42;
    background-color: #f8f9fa;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Password overlay styles */
.password-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(0.5rem);
    overflow: hidden;
}

.password-modal {
    background-color: white;
    padding: 2rem;
    border-radius: 0.625rem;
    box-shadow: 0 0.3125rem 1.25rem rgba(0, 0, 0, 0.3);
    max-width: 25rem;
    width: 90%;
    text-align: center;
    animation: modalFadeIn 0.4s ease-out;
    max-height: 100vh;
    overflow-y: auto;
}

.password-modal h2 {
    margin-top: 0;
    color: #2b2d42;
    font-family: 'Inter', sans-serif;
}

.password-modal p {
    color: #555;
    margin-bottom: 1.5rem;
    font-family: 'Montserrat', sans-serif;
}

.password-input {
    width: 100%;
    padding: 0.75rem 0.9375rem;
    margin-bottom: 1rem;
    border: 0.0625rem solid #ddd;
    border-radius: 0.375rem;
    font-size: 1rem;
    box-sizing: border-box;
}

.password-input:focus {
    border-color: #2b2d42;
    outline: none;
}

.password-submit {
    background-color: #2b2d42;
    color: white;
    border: none;
    padding: 0.75rem 1.25rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    width: 100%;
}

.password-submit:hover {
    background-color: #1a1c2c;
}

.password-error {
    color: #e63946;
    margin-top: 1rem;
    font-size: 0.9rem;
    min-height: 1.2rem;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-1.25rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Disable transitions during theme changes for instant theme switching */
html.no-transition,
html.no-transition * {
    transition: none !important;
    animation: none !important;
}

.content-blur {
    transition: filter 0.3s ease;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.content-blur.blur-active {
    filter: blur(0.5rem);
    pointer-events: none;
    user-select: none;
}

/* Main navigation bar styles */
.main-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background-color: #2b2d42;
    color: white;
    display: flex;
    align-items: center;
    overflow: hidden;
    box-shadow: 0 0.125rem 0.625rem rgba(0, 0, 0, 0.1);
    will-change: height, background-color, box-shadow;
    height: 4.375rem; /* Default height */
    transition: height 0.3s ease-out, background-color 0.3s ease-out, box-shadow 0.3s ease-out;
}

/* Compact mode for the navbar (reduced height) */
.main-nav.compact {
    height: 3.75rem; /* Smaller height in compact mode */
}

.nav-container {
    max-width: 87.5rem;
    margin: 0 auto;
    padding: 0 2rem;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    display: block;
    margin: 0;
    padding: 0;
    transform: scale(1);
    transform-origin: left center;
    line-height: 1.2;
    position: relative;
    will-change: transform;
    transition: transform 0.3s ease-out, line-height 0.3s ease-out;
}

.main-nav.compact .nav-brand {
    transform: scale(0.95);
    line-height: 1;
}

.nav-subtitle {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.85);
    margin: 0.15rem 0 0 2rem;
    font-weight: 400;
    font-family: 'Montserrat', sans-serif;
    font-style: italic;
    letter-spacing: 0.01875rem;
    position: relative;
    display: inline-block;
    padding-left: 1rem;
    opacity: 1;
    transform: translateY(0);
    height: auto;
    will-change: transform, opacity, height;
    overflow: hidden;
    transition: opacity 0.3s ease-out, transform 0.3s ease-out, height 0.3s ease-out, margin 0.3s ease-out;
}

.main-nav.compact .nav-subtitle {
    opacity: 0;
    transform: translateY(-0.625rem);
    height: 0;
    margin-top: 0;
    transition-delay: 0s;
}

.main-nav:not(.compact) .nav-subtitle {
    transition-delay: 0.1s;
}

.nav-subtitle::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 60%;
    width: 0.125rem;
    background-color: rgba(255,255,255,0.4);
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

/* Optimized navigation links with smooth transitions */
.nav-link {
    color: white;
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem;
    border-radius: 0.375rem;
    position: relative;
    overflow: hidden;
    will-change: padding, width, height;
    min-width: 2.5rem;
    min-height: 1.875rem;
    width: auto;
    height: auto;
    transition: padding 0.3s ease-out, width 0.3s ease-out, height 0.3s ease-out, background-color 0.3s ease-out, transform 0.3s ease-out;
    -webkit-touch-callout: none; /* Disable callout, iOS Safari */
    -webkit-user-select: none;   /* Disable selection, Safari */
    -khtml-user-select: none;    /* Konqueror HTML */
    -moz-user-select: none;      /* Old versions of Firefox */
    -ms-user-select: none;       /* Internet Explorer/Edge */
    user-select: none;           /* Non-prefixed version, currently supported by Chrome, Opera and Firefox */
    touch-action: manipulation;  /* Disable double-tap to zoom */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

.nav-link.compact {
    padding: 0.5rem;
    width: 2.5rem;
    height: 2.5rem;
    gap: 0;
    justify-content: center;
}

/* Smooth text animation */
.nav-link-text {
    white-space: nowrap;
    will-change: width, opacity, margin;
    opacity: 1;
    width: auto;
    overflow: hidden;
    transition: width 0.3s ease-out, opacity 0.3s ease-out, margin 0.3s ease-out;
}

.nav-link.compact .nav-link-text {
    width: 0;
    opacity: 0;
    margin-left: 0;
}

/* Smooth icon animation */
.nav-link-icon {
    width: 1.25rem;
    height: 1.25rem;
    fill: currentColor;
    flex-shrink: 0;
    transform: rotate(0deg) scale(1);
    transition: transform 0.3s ease-out;
}

/* Apply hover effects only on devices that support hover */
@media (hover: hover) {
    .nav-link:hover .nav-link-icon {
        transform: rotate(15deg) scale(1);
        transition-duration: 0.3s;
    }

    .nav-link:hover {
        background-color: #353850;
    }

    .nav-link.compact:hover {
        background-color: rgba(255, 255, 255, 0.1);
        transform: scale(1.05);
    }
}

.nav-link.compact .nav-link-icon {
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0.125rem;
    background-color: rgba(255, 255, 255, 0.7);
    transform: scaleX(var(--after-scale, 0));
    transform-origin: var(--after-origin, left);
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 1000;
}

/* Animation for active link */
.nav-link.active {
    background-color: #353850;
}

.nav-link.active::after {
    --after-scale: 1;
    background-color: #fff;
}

/* Transition bar for animation */
.nav-transition-bar {
    position: absolute;
    bottom: 0;
    height: 0.125rem;
    background-color: #fff;
    z-index: 1001;
}

/* Hide original bars during animation */
.nav-link.active.animating::after {
    opacity: 0;
}

.nav-link.active .nav-link-icon {
    transform: scale(1.1);
}

/* Optimized styles for compact mode */
.nav-link.compact.active {
    background-color: #353850;
    border-radius: 0.5rem;
}

/* Page transition animation - optimized */
.page-transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 0.1875rem;
    background: linear-gradient(90deg, #2b2d42, #4361ee, #2b2d42);
    z-index: 2000;
    transform: translateX(-100%);
    pointer-events: none;
    opacity: 0;
}

.page-transition-overlay.animate {
    opacity: 1;
    animation: pageLoadProgress 1s ease-out forwards;
}

@keyframes pageLoadProgress {
    0% {
        transform: translateX(-100%);
    }
    50% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Main content area */
.main-content {
    min-height: calc(100vh - 7.5rem); /* Adjusted for footer and default navbar height */
    margin-top: 4.375rem; /* Default margin-top, will be updated by JS */
    flex: 1;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out, margin-top 0.3s ease-out; /* Add margin-top transition */
}

.main-content.loading {
    opacity: 0.7;
    transform: translateY(0.3125rem);
    pointer-events: none;
}

/* Optimized alert styles - always in bottom right corner */
.alerts-container {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 1100;
    display: flex;
    flex-direction: column-reverse;
    max-width: 21.875rem;
    width: calc(100% - 2.5rem);
    pointer-events: none;
}

.alert {
    position: relative;
    padding: 0;
    border-radius: 0.5rem;
    font-weight: 500;
    overflow: hidden;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.15);
    animation: slideIn 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
    transform: translateX(100%);
    opacity: 0;
    margin-top: 0.625rem;
    pointer-events: auto;
}

.alert-content {
    padding: 0.875rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 0.25rem solid #10b981;
}

.alert-error {
    background-color: #fee2e2;
    color: #b91c1c;
    border-left: 0.25rem solid #ef4444;
}

.alert-info {
    background-color: #dbeafe;
    color: #1e40af;
    border-left: 0.25rem solid #3b82f6;
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
    border-left: 0.25rem solid #f59e0b;
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0 0 0 0.75rem;
    color: inherit;
    opacity: 0.7;
    line-height: 1;
}

.alert-close:hover {
    opacity: 1;
}

.alert-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 0.25rem;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.1);
    transform-origin: left;
}

.alert-success .alert-progress-bar {
    background-color: rgba(16, 185, 129, 0.3);
}

.alert-error .alert-progress-bar {
    background-color: rgba(239, 68, 68, 0.3);
}

.alert-info .alert-progress-bar {
    background-color: rgba(59, 130, 246, 0.3);
}

.alert-warning .alert-progress-bar {
    background-color: rgba(245, 158, 11, 0.3);
}

/* Animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 0;
    }
    to {
        transform: translateX(100%);
        opacity: 1;
    }
}

@keyframes progressBar {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInDown {
    from {
        transform: translateX(-50%) translateY(-1.25rem);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Optimized system notification styles */
#custom-messages-container {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 9999;
    max-width: 25rem;
    width: calc(100% - 2.5rem);
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    align-items: flex-end;
    pointer-events: none;
}

#custom-messages-container > div {
    animation: slideInUp 0.3s ease-out;
    margin-left: auto;
    max-width: 100%;
    pointer-events: auto;
}

.refresh-notification {
    position: fixed;
    top: 1.25rem;
    left: 50% !important;
    max-width: 600px !important;
    width: calc(100% - 2.5rem) !important;
    background: rgba(76, 201, 240, 0.95);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    z-index: 10000;
    font-weight: 500;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.15);
    animation: slideInDown 0.3s ease-out forwards;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.refresh-notification > div {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}



/* Optimized footer styles */
.main-footer {
    background-color: #2b2d42;
    color: white;
    padding: 1.5rem 1rem;
    text-align: center;
    margin-top: auto;
    width: 100%;
}

.footer-container {
    max-width: 87.5rem;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.main-footer p {
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
    margin: 0;
}

/* RESPONSIVE DESIGN */

/* Tablet and smaller desktops */
@media (max-width: 768px) {
    .nav-container {
        padding: 0 1rem;
    }

    .nav-links {
        gap: 0.5rem;
    }

    .nav-link {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }

    .nav-link.compact {
        width: 2.25rem;
        height: 2.25rem;
        padding: 0.4rem;
    }

    .nav-link-icon {
        width: 1.125rem;
        height: 1.125rem;
    }

    .nav-brand {
        font-size: 1.2rem;
    }

    .nav-subtitle {
        display: none; /* Hide subtitle on smaller screens */
    }

    .footer-container {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .copyright-text, .version {
        text-align: center;
        width: 100%;
    }
}

/* Mobile devices */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }

    .main-nav {
        height: 3.75rem;
    }

    .main-nav.compact {
        height: 3.5rem;
    }

    .nav-container {
        padding: 0 0.5rem;
        gap: 0.5rem;
    }

    .nav-brand-container {
        flex-shrink: 1;
        min-width: auto;
        margin-right: 0.1rem;
        padding: 0;
    }

    .nav-links {
        gap: 0.15rem;
        flex-wrap: nowrap;
        justify-content: flex-end;
    }

    /* Hide text on nav links, show only icons */
    .nav-link-text {
        display: none;
    }

    .nav-link {
        width: 2.4rem;
        height: 2.4rem;
        padding: 0.35rem;
        justify-content: center;
        gap: 0;
        border-radius: 0.3rem;
        min-width: 2.4rem;
        min-height: 2.4rem;
    }

    .nav-link-icon {
        width: 1.2rem;
        height: 1.2rem;
    }

    .nav-brand {
        font-size: 0.85rem;
        white-space: nowrap;
        overflow: visible;
        text-overflow: clip;
        width: auto;
        max-width: none;
        font-weight: 700;
        letter-spacing: -1.5px;
        padding: 0 !important;
        margin: 0 !important;
        line-height: 1.1;
    }

    .password-modal {
        padding: 1.5rem;
        width: 95%;
    }

    .password-modal h2 {
        font-size: 1.3rem;
    }

    /* Mobile notification positioning */
    .alerts-container,
    #custom-messages-container {
        bottom: 1rem;
        right: 0.75rem;
        left: 0.75rem;
        max-width: none;
        width: auto;
    }

    .alert-content {
        font-size: 0.85rem;
        padding: 0.75rem 0.9rem;
    }

    .refresh-notification {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        width: calc(100% - 1.5rem);
        max-width: none;
        gap: 0.5rem;
    }

    .refresh-notification > div {
        gap: 0.5rem;
    }

    .spinner {
        width: 1rem;
        height: 1rem;
        border: 2px solid rgba(255, 255, 255, 0.3);
        border-top-color: white;
    }
}

/* Extra small devices (< 375px width) */
@media (max-width: 374px) {
    .nav-container {
        padding: 0 0.25rem;
        gap: 0.15rem;
    }

    .nav-brand-container {
        margin-right: 0.1rem;
    }

    .nav-links {
        gap: 0.08rem;
    }

    .nav-link {
        width: 2rem;
        height: 2rem;
        padding: 0.3rem;
        min-width: 2rem;
        min-height: 2rem;
    }

    .nav-link-icon {
        width: 1rem;
        height: 1rem;
    }

    .nav-brand {
        font-size: 0.75rem;
        white-space: nowrap;
        overflow: visible;
        text-overflow: clip;
        width: auto;
        max-width: none;
        font-weight: 700;
        letter-spacing: -1.8px;
        padding: 0 !important;
        margin: 0 !important;
        line-height: 1;
    }

    .main-nav {
        height: 3.5rem;
    }

    .main-nav.compact {
        height: 3.25rem;
    }

    .spinner {
        width: 0.85rem;
        height: 0.85rem;
        border: 1.5px solid rgba(255, 255, 255, 0.3);
        border-top-color: white;
    }
}

/* Disable animations for alerts header */
.alerts-header {
    opacity: 1 !important;
    animation: none !important;
    transform: none !important;
}

/* Notifications Container and Styles (Light Mode) */
.notifications-container {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.notification {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    color: #1f2937;
    padding: 14px 20px;
    border-radius: 10px;
    border-left: 5px solid #2563eb;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    pointer-events: auto;
    opacity: 0;
    transform: translateX(420px) scale(0.9);
    max-width: 340px;
    word-wrap: break-word;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.3px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.notification.show {
    opacity: 1;
    transform: translateX(0) scale(1);
}

.notification:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.notification-success {
    border-left-color: #10b981;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    color: #065f46;
}

.notification-success:hover {
    border-left-color: #059669;
}

.notification-error {
    border-left-color: #ef4444;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    color: #7f1d1d;
}

.notification-error:hover {
    border-left-color: #dc2626;
}

.notification-info {
    border-left-color: #2563eb;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: #1e40af;
}

.notification-info:hover {
    border-left-color: #1d4ed8;
}

/* Responsive notifications - mobile devices */
@media (max-width: 768px) {
    .notifications-container {
        bottom: 70px;
        right: 10px;
        left: 10px;
        max-width: calc(100% - 20px);
    }
    
    .notification {
        max-width: 100%;
        padding: 12px 16px;
        font-size: 13px;
    }
}
