/* --- Global Variables & Base Styles --- */
:root {
    --primary-blue: #007bff;
    --primary-blue-dark: #0056b3;
    --primary-blue-light: #e6f2ff;
    --accent-green: #28a745;
    --accent-red: #dc3545;
    --text-dark: #343a40;
    --text-light: #f8f9fa;
    --glass-bg: rgba(255, 255, 255, 0.08); /* Semi-transparent white for glass effect */
    --glass-border: rgba(255, 255, 255, 0.15); /* Lighter border for contrast */
    --text-header: #ffffff; /* White for main headers */
    
    /* UPDATED: Brighter secondary text for readability */
    --text-secondary: rgba(255, 255, 255, 0.85); /* Was #c0c0c0 */
    
    --input-bg-dark: rgba(255, 255, 255, 0.05);
    --input-border-dark: rgba(255, 255, 255, 0.2);
    --input-placeholder-dark: #a0a0a0;
    --blue-glow: rgba(0, 123, 255, 0.6);
    --purple-glow: rgba(128, 0, 128, 0.6);
    --card-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    --transition-speed: 0.3s ease;
    
--sidebar-width-open: 260px;
    --sidebar-width-closed: 0px; 
    /* Enhanced Glass Background */
    --sidebar-bg: rgba(15, 22, 36, 0.7); /* Darker, slightly blue-tinted glass */
    --sidebar-border: rgba(255, 255, 255, 0.1);
    --sidebar-link-color: rgba(255, 255, 255, 0.75); /* Slightly brighter text */
    --sidebar-link-hover-bg: rgba(0, 123, 255, 0.15); /* Subtle blue glow background on hover */
    --sidebar-link-hover-color: #ffffff; /* White text on hover */
    --sidebar-link-active-bg: rgba(0, 123, 255, 0.25); /* Stronger blue for active */
    --sidebar-link-active-border: var(--primary-blue); /* Blue left border for active */
    --sidebar-transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); 
}

body {
    font-family: 'Poppins', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    line-height: 1.6;
    color: var(--text-dark);
    overflow-x: hidden;
    background-color: #0d1117; /* Very dark background for the overall app */
}

/* --- Login Page Specific Styles --- */
.login-body {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, var(--blue-glow) 0%, transparent 40%),
                radial-gradient(circle at bottom right, var(--purple-glow) 0%, transparent 40%),
                #1a1a2e; /* Dark background color */
    background-size: 200% 200%;
    animation: gradientAnimation 15s ease infinite alternate;
    position: relative;
    overflow: hidden;
}

@keyframes gradientAnimation {
    0% { background-position: 0% 0%; }
    100% { background-position: 100% 100%; }
}

.login-body::before, .login-body::after {
    content: '';
    position: absolute;
    width: 100vw;
    height: 100vh;
    top: 0;
    left: 0;
    background-image: 
        linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 50px 50px;
    opacity: 0.3;
    animation: gridMovement 60s linear infinite;
    z-index: 0;
}
.login-body::after {
    background-size: 70px 70px; /* Different size for depth */
    animation-direction: reverse;
    opacity: 0.2;
}

@keyframes gridMovement {
    from { background-position: 0 0; }
    to { background-position: 50px 50px; } /* Moves 1 grid unit */
}
/* --- NEW: Animated Border --- */

.login-logo {
    max-width: 180px;
    margin: 0 auto 0 auto;
    display: block;
}

.login-header {
    margin-bottom: 35px;
}

.login-header h2 {
    font-size: 32px;
    font-weight: 700;
    margin-top: 10px; /* ADD THIS LINE - 10px is just a guess, change it to whatever you like */
    margin-bottom: 10px;
    color: var(--text-header);
}

.login-header p {
    font-size: 16px;
    color: var(--text-secondary); /* Uses new brighter color */
}

/* --- Form Groups --- */
.form-group {
    margin-bottom: 25px;
    position: relative;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    font-size: 15px;
    color: var(--text-secondary); /* Uses new brighter color */
}

.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="text"] {
    width: 100%;
    padding: 14px 45px 14px 18px;
    border: 1px solid var(--input-border-dark);
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 16px;
    background-color: var(--input-bg-dark);
    color: var(--text-light);
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed), background-color var(--transition-speed);
}
.form-group input::placeholder {
    color: var(--input-placeholder-dark);
    opacity: 0.7;
}

.form-group input[type="email"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.4);
    background-color: rgba(255, 255, 255, 0.1);
}

/* --- NEW: Custom Validation Styles --- */

/* This adds a red border to the input when it's invalid */
.form-group input.is-invalid {
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.4); /* Red glow */
}

/* This is the new glassy error message bubble */
/* This is the new glassy error message bubble */
.form-error-message {
    display: none; /* Hidden by default */
    width: 100%;
    margin-top: 10px;
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 500;
    
    /* Our Glassy UI */
    background: rgba(220, 53, 69, 0.25); /* Red glass */
    border: 1px solid rgba(220, 53, 69, 0.6); /* Red border */
    border-radius: 6px;
    color: var(--text-header);
    backdrop-filter: blur(5px);
    
    /* Fade-in animation */
    animation: fadeIn 0.3s ease-out;

    /* THE FIX: This makes its 100% width behave the same as the input field */
    box-sizing: border-box; 
}
/* --- End of Custom Validation Styles --- */

.password-icon-toggle {
    position: absolute;
    top: 48px;
    right: 18px;
    cursor: pointer;
    width: 20px;
    height: 20px;
}
.password-icon-toggle svg {
    width: 100%;
    height: 100%;
    fill: var(--input-placeholder-dark);
    transition: fill var(--transition-speed);
}
.password-icon-toggle:hover svg {
    fill: var(--primary-blue);
}


/* --- Form Options (Remember Me & Forgot) --- */
.form-options {
    display: flex;
    justify-content: space-between; /* UPDATED */
    align-items: center;
    margin-top: -10px;
    margin-bottom: 30px;
    font-size: 15px;
    color: var(--text-secondary);
}

/* NEW: Forgot Password Link Style */
.forgot-password a {
    color: var(--primary-blue);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color var(--transition-speed);
}
.forgot-password a:hover {
    color: var(--primary-blue-dark);
    text-decoration: underline;
}

/* --- Toggle Switch CSS --- */
.toggle-switch-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}
.toggle-switch-container span {
    margin-left: 10px;
}
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 28px;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555;
    transition: var(--transition-speed);
    border-radius: 28px;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: var(--transition-speed);
    border-radius: 50%;
}
input:checked + .toggle-slider {
    background-color: var(--primary-blue);
}
input:checked + .toggle-slider:before {
    transform: translateX(21px);
}
/* --- END: Toggle Switch CSS --- */

/* --- NEW: Multi-Color, Seamless Trailing Border Animation --- */

/* --- Ensure this is your MAIN login wrapper style --- */
.login-wrapper {
    position: relative; 
    z-index: 10;
    width: 90%;
    max-width: 480px;
    
    /* RESTORE these */
    background: var(--glass-bg); 
    backdrop-filter: blur(10px); 
    
    border: 1px solid var(--glass-border); /* Keep original border for fallback */
    border-radius: 16px; 
    box-shadow: var(--card-shadow);
    padding: 0; /* Keep padding 0 */
    text-align: center;
    color: var(--text-light);
    overflow: hidden; /* Keep this */
}

/* --- Ensure this is your ::before pseudo-element style --- */
/* This is the rotating multi-color gradient layer */
.login-wrapper::before {
    content: '';
    position: absolute;
    top: 50%; 
    left: 50%;
    width: 250%; 
    height: 250%; 
    
    background: conic-gradient(
        from 0deg,
        transparent 0%,
        transparent 30%, 
        #00c6ff 50%, 
        #ffea00 75%, 
        #00ff80 90%, 
        transparent 100%
    );
    
    animation: rotate-multi-color-border 4s linear infinite;
    transform-origin: center center; 
    transform: translate(-50%, -50%); 
    z-index: 1; 
}

/* --- Ensure this is your ::after pseudo-element style --- */
/* This is the crucial "mask" and content container layer */
.login-wrapper::after {
    content: '';
    position: absolute;
    top: 2px; 
    left: 2px; 
    right: 2px; 
    bottom: 2px; 
    
    /* CHANGE: Use the body's dark background for definite opacity */
    background: #1a1a2e; /* Match the color used in .login-body */
    
    border-radius: 14px; 
    z-index: 2; 
}

/* --- ADD THIS NEW RULE --- */
.login-content-for-padding {
    position: relative; /* Needed for z-index */
    z-index: 3; /* On top of the ::after mask */
    padding: 40px; /* Original padding */
}

@keyframes rotate-multi-color-border {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}
/* --- End of Multi-Color, Seamless Trailing Border Animation --- */

/* --- Submit Button --- */
.btn-submit {
    width: 100%;
    padding: 15px;
    background: linear-gradient(90deg, #007bff, #00c6ff);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
    letter-spacing: 0.8px;
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.4);
}

.btn-submit:hover {
    background: linear-gradient(90deg, #0056b3, #0099cc);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 123, 255, 0.6);
}

/* --- UPDATED: Glassy Notifications --- */
.notification {
    width: calc(100% - 30px);
    padding: 15px;
    margin: 0 auto 25px auto;
    border-radius: 8px;
    font-weight: 500;
    box-sizing: border-box;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
    
    /* NEW Glassy Style */
    backdrop-filter: blur(5px);
    color: var(--text-header); /* Bright white text */
    font-weight: 500;
}

.notification.error {
    background: rgba(220, 53, 69, 0.25); /* Red glass */
    border: 1px solid rgba(220, 53, 69, 0.6); /* Red border */
}

.notification.success {
    background: rgba(40, 167, 69, 0.25); /* Green glass */
    border: 1px solid rgba(40, 167, 69, 0.6); /* Green border */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    
.login-wrapper {
        width: 95%;
        padding: 0; /* Keep padding 0 */
        max-width: 400px;
    }
    .login-content-for-padding {
        padding: 30px 25px; 
    }
    .login-logo {
        max-width: 150px;
        margin-bottom: 25px;
    }
    .login-header h2 {
        font-size: 26px;
    }
    .login-header p {
        font-size: 14px;
    }
    .form-group label {
        font-size: 13px;
    }
    .form-group input {
        padding: 12px 40px 12px 15px;
        font-size: 15px;
    }
    .password-icon-toggle {
        top: 45px;
        right: 15px;
    }
    .btn-submit {
        padding: 13px;
        font-size: 16px;
    }
    .notification {
        width: calc(100% - 20px);
        margin-bottom: 20px;
        padding: 12px;
        font-size: 14px;
    }
    .form-options {
        font-size: 14px; /* Adjust font size on mobile */
    }
    .forgot-password a {
        font-size: 13px; /* Adjust font size on mobile */
    }
}


/* --- Dashboard/App Header Styles (Updated for Dark Theme Consistency) --- */
.navbar {
    background: #1a1a2e;
    padding: 15px 40px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-light);
}

.navbar .logo {
    font-size: 28px;
    font-weight: 700;
    color: #e0e0e0;
    letter-spacing: 0.8px;
}

.navbar .user-info {
    font-size: 15px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
}

.navbar .user-info strong {
    color: var(--primary-blue);
    margin-right: 5px;
}

.navbar .user-info a {
    color: #ff6b6b;
    text-decoration: none;
    margin-left: 20px;
    font-weight: 500;
    transition: color var(--transition-speed);
}

.navbar .user-info a:hover {
    color: #ff3838;
    text-decoration: underline;
}

.container {
    padding: 40px;
    max-width: 1200px;
    margin: 0 auto;
    color: var(--text-light);
}
.container h1 {
    margin-top: 0;
    font-size: 38px;
    font-weight: 700;
    color: var(--text-header);
    margin-bottom: 20px;
}
.container p {
    font-size: 18px;
    color: var(--text-secondary);
}

/* --- NEW: Loader Wrapper Styles --- */
#loader-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999; /* On top of everything */
    
    /* This is the *exact* background from your login page for consistency */
    background: radial-gradient(circle at top left, var(--blue-glow) 0%, transparent 40%),
                radial-gradient(circle at bottom right, var(--purple-glow) 0%, transparent 40%),
                #1a1a2e;
    
    /* --- ADDED LINES --- */
    background-size: 200% 200%;
    animation: gradientAnimation 15s ease infinite alternate;
    overflow: hidden; /* Ensures grid lines don't cause scrollbars */
    /* --- END ADDED LINES --- */
    
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column; /* To stack spinner and text */
    
    /* Fade-out transition */
    transition: opacity 0.5s ease-out;
}

/* --- NEW: Animated grid lines for loader --- */
#loader-wrapper::before, #loader-wrapper::after {
    content: '';
    position: absolute;
    width: 100vw;
    height: 100vh;
    top: 0;
    left: 0;
    background-image: 
        linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 50px 50px;
    opacity: 0.3;
    animation: gridMovement 60s linear infinite;
    z-index: 1; /* Below spinner (z-index 10) */
}

#loader-wrapper::after {
    background-size: 70px 70px; /* Different size for depth */
    animation-direction: reverse;
    opacity: 0.2;
}

#loader-wrapper.loaded {
    /* Hide it when the 'loaded' class is added */
    opacity: 0;
    pointer-events: none; /* Make it unclickable */
}


/* Loading Text (Optional) */

/* --- NEW: Loader Logo Animation --- */
.loader-logo {
    width: 200px; /* You can change this size */
    height: auto;
    position: relative;
    z-index: 10;
    /* This applies the new pulse animation */
    animation: pulse 1.5s ease-in-out infinite;
}

/* Loading Text */
.loader-text {
    color: var(--text-secondary);
    margin-top: 10px; /* Increased space for the logo */
    font-size: 18px;
    font-weight: 500;
    position: relative;
    z-index: 10;
}

/* The "breathing" pulse animation */
@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.05); /* Gently scales up */
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 0.8;
    }
}

/*
 *
 * --- SIDEBAR STYLES ---
 *
 */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--sidebar-width-open);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    backdrop-filter: blur(12px); /* Slightly stronger blur */
    z-index: 1000; 
    transform: translateX(-100%); 
    transition: var(--sidebar-transition);
    display: flex;
    flex-direction: column;
    overflow-y: auto; 
    overflow-x: hidden; /* Prevent horizontal scroll */
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.2); /* Add subtle shadow */
}

.sidebar.open {
    transform: translateX(0); 
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 25px; /* Increased padding */
    border-bottom: 1px solid var(--sidebar-border);
    min-height: 65px; /* Match potential increased navbar height */
    box-sizing: border-box;
    flex-shrink: 0; /* Prevent header from shrinking */
}

.sidebar-title {
    font-size: 1.3em; /* Larger title */
    font-weight: 600;
    color: var(--text-header);
    letter-spacing: 0.5px;
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex; 
    align-items: center;
    justify-content: center;
}

.sidebar-toggle-btn svg {
    width: 26px; /* Slightly larger icon */
    height: 26px;
    stroke: var(--sidebar-link-color);
    transition: stroke 0.2s ease, transform 0.3s ease; /* Add rotate transition */
}

.sidebar-toggle-btn:hover svg {
    stroke: var(--sidebar-link-hover-color);
    transform: rotate(90deg); /* Rotate close icon on hover */
}
/* Style for the hamburger button in navbar */
.navbar .open-btn svg {
     stroke: var(--text-secondary); /* Match navbar text color */
}
.navbar .open-btn:hover svg {
     stroke: var(--primary-blue); /* Blue hover */
}


.sidebar-nav {
    flex-grow: 1; 
    padding-top: 20px; /* More space at the top */
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li {
    position: relative; /* Needed for the active border */
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    padding: 15px 25px; /* Increased padding */
    margin: 5px 10px; /* Add horizontal margin for rounded effect */
    color: var(--sidebar-link-color);
    text-decoration: none;
    font-size: 16px; /* Slightly larger font */
    font-weight: 500;
    border-radius: 8px; /* Rounded corners for hover effect */
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap; 
    overflow: hidden; 
    position: relative; /* For pseudo-element border */
}

.sidebar-nav li a::before { /* Left border for active state */
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    height: 0%; /* Hidden by default */
    width: 4px; /* Border thickness */
    background-color: var(--sidebar-link-active-border);
    border-radius: 0 4px 4px 0;
    transform: translateY(-50%);
    transition: height 0.3s ease;
}

.sidebar-nav li a:hover {
    background-color: var(--sidebar-link-hover-bg);
    color: var(--sidebar-link-hover-color);
    box-shadow: 0 0 15px rgba(0, 123, 255, 0.2); /* Subtle glow on hover */
}
.sidebar-nav li a:hover svg {
    stroke: var(--sidebar-link-hover-color); /* Brighten icon on hover */
}

/* Example Active State - Add class="active" to the relevant <li> or <a> */
.sidebar-nav li.active a,
.sidebar-nav li a.active { /* Add .active class to the link for the current page */
    background-color: var(--sidebar-link-active-bg);
    color: var(--sidebar-link-hover-color);
    font-weight: 600; /* Bolder text for active link */
}
.sidebar-nav li.active a::before,
.sidebar-nav li a.active::before {
    height: 70%; /* Show the colored left border */
}
.sidebar-nav li.active a svg,
.sidebar-nav li a.active svg {
    stroke: var(--sidebar-link-active-border); /* Color the icon blue */
}


.sidebar-nav li a svg {
    width: 20px;
    height: 20px;
    margin-right: 18px; /* More space after icon */
    flex-shrink: 0; 
    stroke: var(--sidebar-link-color); /* Ensure default icon color */
    transition: stroke 0.2s ease;
}

/* --- Main Content Push --- */
.main-content {
    transition: margin-left 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    margin-left: var(--sidebar-width-closed); 
    width: 100%; 
    box-sizing: border-box;
}

.main-content.sidebar-open {
    margin-left: var(--sidebar-width-open);
    width: calc(100% - var(--sidebar-width-open)); 
}

/* Adjust navbar button position & alignment */
.navbar {
    display: flex; /* Ensure flex is explicitly set */
    align-items: center; /* Vertically align items */
}
.navbar .open-btn {
    order: -1; 
    margin-right: 20px; /* More space after hamburger */
    flex-shrink: 0; /* Prevent button from shrinking */
}
.navbar .logo {
    /* Logo takes space but doesn't force others out */
     flex-grow: 0; 
     margin-right: auto; /* Pushes user info to the right */
     text-align: left; /* Keep logo aligned left */
}
.navbar .user-info {
    margin-left: 0; /* Reset any auto margin */
    flex-shrink: 0; /* Prevent user info from shrinking */
}


/* Optional: Responsive adjustments for sidebar */
@media (max-width: 992px) { /* Adjust breakpoint if needed */
    /* Make sidebar overlay content instead of pushing it */
    .main-content.sidebar-open {
        margin-left: 0; 
        width: 100%; 
    }
    .sidebar {
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.4); /* Stronger shadow when overlaying */
    }
    
    /* Optional: Add an overlay to dim content when sidebar is open */
    body::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999; /* Below sidebar, above content */
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.4s ease;
    }
    body.sidebar-open-overlay::after {
        opacity: 1;
        pointer-events: all;
    }
}
