@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Futuristic Neon Color Palette */
    --primary-color: #00f5ff;
    /* Cyan Neon */
    --primary-hover: #00d4e0;
    --secondary-color: #ff006e;
    /* Neon Pink */
    --accent-color: #8b5cf6;
    /* Electric Purple */
    --bg-color: #0a0a1a;
    /* Deep Space */
    --card-bg: rgba(10, 20, 40, 0.7);
    --sidebar-bg: rgba(5, 10, 25, 0.95);
    --text-color: #e0f7ff;
    --text-muted: #7dd3fc;
    --border-color: rgba(0, 245, 255, 0.15);
    --input-bg: rgba(15, 25, 45, 0.9);
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    --sidebar-width: 280px;

    /* Neon Glow Effects */
    --neon-cyan: 0 0 20px rgba(0, 245, 255, 0.5);
    --neon-pink: 0 0 20px rgba(255, 0, 110, 0.5);
    --neon-purple: 0 0 20px rgba(139, 92, 246, 0.5);
    --neon-green: 0 0 20px rgba(57, 255, 20, 0.5);

    color-scheme: dark;
}

/* MENU TOGGLE - ALWAYS VISIBLE */
.mobile-menu-toggle {
    display: flex;
    /* Always flex */
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 2000;
    /* Higher than sidebar z-index */
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    transition: all 0.2s;
}

.mobile-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

/* Remove media query wrapper for toggle if previously wrapped, but here we redefine basics */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    background-image:
        radial-gradient(ellipse at 20% 80%, rgba(0, 245, 255, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(255, 0, 110, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(139, 92, 246, 0.1) 0%, transparent 60%),
        radial-gradient(ellipse at 100% 100%, rgba(0, 245, 255, 0.08) 0%, transparent 40%);
    background-size: 200% 200%, 200% 200%, 150% 150%, 200% 200%;
    animation: nebula-flow 20s ease-in-out infinite;
    min-height: 100vh;
    color: var(--text-color);
    color-scheme: dark;
    position: relative;
}

/* Nebula Flow Animation */
@keyframes nebula-flow {

    0%,
    100% {
        background-position: 0% 0%, 100% 100%, 50% 50%, 100% 0%;
    }

    25% {
        background-position: 50% 100%, 0% 50%, 100% 0%, 50% 100%;
    }

    50% {
        background-position: 100% 100%, 0% 0%, 50% 100%, 0% 50%;
    }

    75% {
        background-position: 50% 0%, 100% 50%, 0% 50%, 100% 100%;
    }
}

/* Cyber Grid Overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        linear-gradient(rgba(0, 245, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 245, 255, 0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
    animation: grid-pulse 8s ease-in-out infinite;
}

@keyframes grid-pulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 0.8;
    }
}

/* Scanline Effect */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.03) 2px,
            rgba(0, 0, 0, 0.03) 4px);
    pointer-events: none;
    z-index: 9999;
}

/* Auth Pages (Login/Register) */
.login-container {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 3rem 2.5rem;
    box-shadow: var(--shadow);
}

/* ... (Keep existing form styles) ... */

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-header h2 {
    color: var(--text-color);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.form-group label {
    display: block;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    color: var(--text-color);
    transition: all 0.3s ease;
    outline: none;
}

/* Fix Select Options Visibility */
select.form-control {
    background-color: #1e293b !important;
    color: #ffffff !important;
    color-scheme: dark !important;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3Cpath%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 1rem center !important;
    background-size: 1.25rem !important;
    padding-right: 2.5rem !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

/* Remove explicit option styling to let browser handle contrast via color-scheme: dark */
select.form-control option {
    background-color: #ffffff !important;
    /* Accept the white background on Windows */
    color: #0f172a !important;
    /* Dark text for visibility */
}

/* Ensure the select dropdown popup uses dark colors */
select.form-control:focus {
    background-color: #1e293b !important;
    border-color: var(--primary-color) !important;
}

/* Fix Date Input Visibility */
input[type="date"].form-control {
    color-scheme: dark;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0, 245, 255, 0.15), var(--neon-cyan);
    background: rgba(15, 25, 45, 0.95);
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: #0a0a1a;
    border: none;
    border-radius: 12px;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 1rem;
    box-shadow: 0 0 30px rgba(0, 245, 255, 0.3), 0 4px 15px rgba(0, 0, 0, 0.3);
    text-align: center;
    display: block;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    text-shadow: 0 0 10px rgba(0, 245, 255, 0.5);
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 0 50px rgba(0, 245, 255, 0.5), 0 10px 30px rgba(0, 0, 0, 0.4);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
}

.auth-link {
    display: block;
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.auth-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.alert {
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.footer-text {
    text-align: center;
    margin-top: 2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.decoration {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    z-index: 0;
}

.decoration-1 {
    top: -100px;
    left: -100px;
    width: 300px;
    height: 300px;
    background: var(--primary-color);
}

.decoration-2 {
    bottom: -100px;
    right: -100px;
    width: 300px;
    height: 300px;
    background: #a855f7;
}

/* Dashboard Layout */
.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport height for mobile */
    overflow: hidden;
}

@media (max-width: 768px) {
    .app-container {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        overflow: visible;
    }
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid rgba(0, 245, 255, 0.2);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    backdrop-filter: blur(20px);
    z-index: 1500;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 5px 0 30px rgba(0, 245, 255, 0.1), 0 0 50px rgba(0, 0, 0, 0.5);
}

.sidebar.mobile-open {
    transform: translateX(0);
    /* Show when active */
}

/* Scrollbar tweaks */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.sidebar:hover::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

/* Backdrop Logic - Global */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    z-index: 1400;
    /* Behind sidebar */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.show {
    display: block;
    opacity: 1;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    /* Stack logo and text vertically */
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.logo-icon {
    width: 80px;
    /* Increased from 40px */
    height: 80px;
    /* Increased from 40px */
    background: white;
    /* White background for the logo */
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    transition: transform 0.3s ease;
    overflow: hidden;
    /* Added to crop zoomed image */
}

.logo-icon:hover {
    transform: scale(1.05);
}

.app-name {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

.nav-menu {
    flex: 1;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-bottom: 1rem;
}

.nav-item {
    width: 100%;
}

.nav-section {
    padding: 0.4rem 0.75rem;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
    font-size: 0.65rem;
    font-weight: 700;
    color: #e2e8f0;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3) 0%, rgba(168, 85, 247, 0.2) 100%);
    border-left: 3px solid var(--primary-color);
    border-radius: 0 6px 6px 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0.6rem;
    /* Compact padding */
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.9rem;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.nav-link i {
    font-size: 1.1rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
    /* Extra padding */
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    background: var(--sidebar-bg);
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-weight: 700;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
    background: rgba(15, 23, 42, 0.5);
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .main-content {
        overflow: visible;
        flex: none;
    }
}

.content-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-color);
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1.5rem;
    backdrop-filter: blur(15px);
    box-shadow:
        0 0 20px rgba(0, 245, 255, 0.05),
        inset 0 0 30px rgba(0, 245, 255, 0.02);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-color), var(--secondary-color), transparent);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.card:hover {
    border-color: rgba(0, 245, 255, 0.4);
    box-shadow:
        0 0 40px rgba(0, 245, 255, 0.15),
        0 20px 40px rgba(0, 0, 0, 0.3);
    transform: translateY(-5px);
}

.card:hover::before {
    opacity: 1;
}

/* Media Queries */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        position: relative;
    }

    /* Sidebar is now global - Removing specific mobile definitions that are now redundant or default */
    /* .sidebar logic moved to global scope */

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-header {
        border-bottom: 1px solid var(--border-color);
        margin-bottom: 1rem;
        padding-bottom: 1rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }

    .nav-menu {
        display: flex;
    }

    .user-profile {
        margin-top: auto;
        display: flex;
    }

    /* Backdrop logic moved to global scope */

    /* Split Container (PO Confirm, Receive Goods) */
    .split-container {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    .left-panel {
        width: 100%;
        max-height: none;
        overflow: visible;
        margin-bottom: 1rem;
    }

    .right-panel {
        width: 100%;
        min-height: 500px;
    }

    /* Main Content padding adjustments */
    .main-content {
        padding: 1rem;
        padding-top: 4.5rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .header-controls {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .header-controls select,
    .header-controls input {
        width: 100% !important;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Hide logout wrapper if exists */
    .logout-btn-wrapper {
        display: none;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--sidebar-bg);
    margin: 10% auto;
    padding: 2rem;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 600px;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    color: var(--text-color);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-color);
}

.modal-body {
    margin-bottom: 2rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Role Selector Styles - Pro Design */
.role-selector-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 8px;
}

.role-option {
    cursor: pointer;
    position: relative;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Hide default radio completely */
.role-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Pro Card Base Style */
.role-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: rgba(30, 41, 59, 0.4);
    /* Dark glass */
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    transition: all 0.2s ease-out;
    position: relative;
    overflow: hidden;
    height: 100%;
}

/* Hover - Lighten slightly */
.role-card:hover {
    background: rgba(30, 41, 59, 0.6);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* Icon Container */
.role-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

/* Text Info */
.role-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.role-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-color);
    letter-spacing: 0.2px;
}

.role-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* ----------------------------------------------------
   Selection Logic (Accent Borders + Glow) 
   ---------------------------------------------------- */

/* Global Selected State */
.role-option input:checked+.role-card {
    background: rgba(30, 41, 59, 0.8);
    border-width: 1px;
    box-shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.5);
    transform: translateY(-2px);
}

/* --- Admin (Red) --- */
.role-admin .role-icon {
    color: #f87171;
    background: rgba(248, 113, 113, 0.1);
}

.role-option input:checked+.role-admin {
    border-color: #ef4444;
    box-shadow: inset 0 0 0 1px #ef4444, 0 4px 20px -5px rgba(239, 68, 68, 0.3);
}

.role-option input:checked+.role-admin .role-icon {
    background: #ef4444;
    color: white;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

.role-option input:checked+.role-admin .role-name {
    color: #f87171;
}


/* --- Drystore (Blue) --- */
.role-drystore .role-icon {
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.1);
}

.role-option input:checked+.role-drystore {
    border-color: #3b82f6;
    box-shadow: inset 0 0 0 1px #3b82f6, 0 4px 20px -5px rgba(59, 130, 246, 0.3);
}

.role-option input:checked+.role-drystore .role-icon {
    background: #3b82f6;
    color: white;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.role-option input:checked+.role-drystore .role-name {
    color: #60a5fa;
}


/* --- Purchase (Purple) --- */
.role-purchase .role-icon {
    color: #c084fc;
    background: rgba(192, 132, 252, 0.1);
}

.role-option input:checked+.role-purchase {
    border-color: #a855f7;
    box-shadow: inset 0 0 0 1px #a855f7, 0 4px 20px -5px rgba(168, 85, 247, 0.3);
}

.role-option input:checked+.role-purchase .role-icon {
    background: #a855f7;
    color: white;
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.4);
}

.role-option input:checked+.role-purchase .role-name {
    color: #c084fc;
}


/* --- User (Green) --- */
.role-user .role-icon {
    color: #34d399;
    background: rgba(52, 211, 153, 0.1);
}

.role-option input:checked+.role-user {
    border-color: #10b981;
    box-shadow: inset 0 0 0 1px #10b981, 0 4px 20px -5px rgba(16, 185, 129, 0.3);
}

.role-option input:checked+.role-user .role-icon {
    background: #10b981;
    color: white;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}

.role-option input:checked+.role-user .role-name {
    color: #34d399;
}

/* Optional: Checkmark Badge logic removed for cleaner "Icon Glow" look */
.role-card::before {
    display: none;
}