/* ========================================
   MODERN LOGIN PAGE STYLES
   Enhanced with Glassmorphism & Animations
   ======================================== */

/* ========================================
   ROOT VARIABLES & MODERN THEME
   
   JAVASCRIPT COMPATIBILITY:
   - All original class names preserved (.login-box, .login-box_btn, .hide-box_btn)
   - DevExpress ClientInstanceNames intact (email, password, loader, frame)
   - Button types set to prevent form submission
   - Original functionality fully maintained
   ======================================== */
:root {
    --primary-color: #e9ecef;
    --primary-hover: #dee2e6;
    --secondary-color: #f8f9fa;
    --accent-color: #ffffff;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    
    --text-primary: #495057;
    --text-secondary: #6c757d;
    --text-light: #adb5bd;
    
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.98);
    --bg-glass-dark: rgba(255, 255, 255, 0.95);
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    
    --border-radius: 12px;
    --border-radius-lg: 20px;
    --border-radius-full: 9999px;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ========================================
   GLOBAL MODERN OVERRIDES
   ======================================== */
body, html {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
    font-size: 14px;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden !important; /* Hide horizontal scroll */
}

body {
    max-width: 100vw !important;
    overflow-x: hidden !important;
}

/* Ensure all elements use border-box sizing to prevent overflow */
*, *::before, *::after {
    box-sizing: border-box !important;
}

/* ========================================
   ANIMATED BACKGROUND SHAPES
   ======================================== */
.background-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
    pointer-events: none !important;
}

.background-shapes * {
    pointer-events: none !important;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: float 20s infinite ease-in-out;
}

.shape-1 {
    width: 500px;
    height: 500px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    top: -150px;
    left: -150px;
    animation-delay: 0s;
}

.shape-2 {
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
    bottom: -100px;
    right: -100px;
    animation-delay: -5s;
}

.shape-3 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
    top: 50%;
    right: 20%;
    animation-delay: -10s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) translateX(0) scale(1);
    }
    25% {
        transform: translateY(-30px) translateX(30px) scale(1.05);
    }
    50% {
        transform: translateY(20px) translateX(-20px) scale(0.95);
    }
    75% {
        transform: translateY(-20px) translateX(40px) scale(1.02);
    }
}

/* ========================================
   MODERN LOGIN CONTAINER
   ======================================== */
.modern-login-container {
    animation: fadeInRight 0.6s ease-out;
    z-index: 100;
    overflow-x: hidden !important;
    max-width: 100% !important;
}

.login-box {
    overflow-x: hidden !important;
    max-width: 100vw !important;
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   MODERN CARD WITH GLASSMORPHISM
   ======================================== */
.login-box .card,
.modern-card {
    background: var(--bg-glass) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    border-radius: var(--border-radius-lg) !important;
    box-shadow: var(--shadow-2xl) !important;
    overflow: hidden !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    transition: all var(--transition-normal);
    max-width: 100% !important;
}

.login-box .card:hover,
.modern-card:hover {
    box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.3) !important;
    transform: scale(1.01); /* Reduced from 1.02 to prevent overflow */
}

/* Desktop specific hover - subtle scale only */
@media (min-width: 1000px) {
    .login-box .card:hover,
    .modern-card:hover {
        transform: scale(1.01);
    }
}

/* ========================================
   MODERN HEADER
   ======================================== */
.login-box .card-header,
.modern-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
    padding: 2rem 1.5rem !important;
    border-bottom: none !important;
    position: relative;
    overflow: hidden !important;
    overflow-x: hidden !important;
    max-width: 100% !important;
}

.login-box .card-header::before,
.modern-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
}

.logo-container {
    position: relative;
    z-index: 1;
    margin-bottom: 1rem;
}

.login-box .card-header .brand-image,
.modern-logo {
    width: 80px !important;
    height: 80px !important;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    transition: all var(--transition-normal);
    animation: logoFloat 3s infinite ease-in-out;
}

.login-box .card-header .brand-image:hover,
.modern-logo:hover {
    transform: scale(1.1) rotate(5deg);
}

@keyframes logoFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.login-box .card-header .h4,
.login-box .card-header a,
.app-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary) !important;
    margin: 0;
    letter-spacing: -0.02em;
    position: relative;
    z-index: 1;
    text-shadow: none;
    text-decoration: none;
}

/* ========================================
   MODERN BODY
   ======================================== */
.login-box .card-body,
.modern-body {
    padding: 2.5rem 2rem !important;
    background: transparent !important;
    overflow-x: hidden !important;
    max-width: 100% !important;
}

.login-box .login-box-msg,
.modern-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary) !important;
    margin-bottom: 2rem !important;
    font-weight: 400;
    text-align: center;
}

/* ========================================
   MODERN INPUT GROUPS
   ======================================== */
.modern-input-group {
    position: relative;
    margin-bottom: 1.25rem !important;
    max-width: 100% !important;
    overflow: visible !important; /* Allow focus glow to show */
}

.login-box .input-group {
    max-width: 100% !important;
    overflow: visible !important;
}

.input-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    color: var(--text-light);
    font-size: 1.1rem;
    transition: color var(--transition-fast);
    pointer-events: none;
}

.modern-input-group:focus-within .input-icon {
    color: var(--primary-color);
}

/* Modern Input Styling */
.modern-input .dxeTextBox,
.modern-input .dxeEditArea {
    background: rgba(255, 255, 255, 0.8) !important;
    border: 2px solid rgba(0, 0, 0, 0.1) !important;
    border-radius: var(--border-radius) !important;
    padding-left: 45px !important;
    font-size: 0.95rem !important;
    color: var(--text-primary) !important;
    transition: all var(--transition-normal) !important;
    height: 50px !important;
}

.modern-input .dxeTextBox:hover {
    background: rgba(255, 255, 255, 0.95) !important;
    border-color: rgba(0, 0, 0, 0.2) !important;
}

.modern-input .dxeTextBox:focus,
.modern-input .dxeFocused {
    background: white !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05) !important;
    outline: none !important;
}

/* Modern Select Dropdown */
.modern-select {
    background: rgba(255, 255, 255, 0.8) !important;
    border: 2px solid rgba(0, 0, 0, 0.1) !important;
    border-radius: var(--border-radius) !important;
    padding: 12px 15px 12px 45px !important;
    font-size: 0.95rem !important;
    color: var(--text-primary) !important;
    width: 100% !important;
    height: 50px !important;
    transition: all var(--transition-normal) !important;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
}

.modern-select:hover {
    background: rgba(255, 255, 255, 0.95) !important;
    border-color: rgba(0, 0, 0, 0.2) !important;
}

.modern-select:focus {
    background: white !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05) !important;
    outline: none !important;
}

/* ========================================
   MODERN CHECKBOX
   ======================================== */
.modern-checkbox {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
}

.modern-checkbox input[type="checkbox"],
.login-box #remember {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    margin-right: 0.5rem;
    cursor: pointer;
    appearance: none;
    background: white;
    position: relative;
    transition: all var(--transition-fast);
}

.modern-checkbox input[type="checkbox"]:hover,
.login-box #remember:hover {
    border-color: var(--primary-color);
}

.modern-checkbox input[type="checkbox"]:checked,
.login-box #remember:checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.modern-checkbox input[type="checkbox"]:checked::after,
.login-box #remember:checked::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 12px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.modern-label,
.login-box .gridTd {
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    cursor: pointer;
    user-select: none;
}

/* ========================================
   MODERN BUTTON
   ======================================== */
.modern-button,
.modern-button .dxbButton,
.login-box #LoginButton,
.login-box #LoginButton table,
.login-box #LoginButton .dxbButton {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
    border: none !important;
    border-radius: var(--border-radius) !important;
    color: var(--text-primary) !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.02em;
    padding: 0.75rem 1.5rem !important;
    transition: all var(--transition-normal) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    position: relative;
    overflow: hidden;
}

.modern-button::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 var(--transition-slow);
}

.modern-button:hover,
.login-box #LoginButton:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15) !important;
}

.modern-button:hover::before {
    left: 100%;
}

.modern-button:active,
.login-box #LoginButton:active {
    transform: translateY(0) !important;
}

/* ========================================
   MODERN LINKS
   ======================================== */
.modern-links {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1.5rem 0;
    flex-wrap: wrap;
    gap: 1rem;
    max-width: 100% !important;
    overflow: visible !important;
}

.modern-link,
.login-box a.gridTd {
    color: var(--primary-color) !important;
    text-decoration: none !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    transition: all var(--transition-fast) !important;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    position: relative;
}

.modern-link::after,
.login-box a.gridTd::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: width var(--transition-normal);
}

.modern-link:hover,
.login-box a.gridTd:hover {
    color: var(--primary-hover) !important;
}

.modern-link:hover::after,
.login-box a.gridTd:hover::after {
    width: 100%;
}

.modern-link i {
    font-size: 0.85rem;
}

/* ========================================
   MODERN SOCIAL AUTH
   ======================================== */
.modern-social {
    padding: 1.5rem 0 0 0;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.divider span {
    padding: 0 1rem;
    color: var(--text-light);
    font-size: 0.85rem;
    font-weight: 500;
}

.google-signin-container {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

/* ========================================
   MODERN TOGGLE BUTTONS (MOBILE)
   Preserves original bottom positioning behavior
   ======================================== */

/* Show Button - Bottom Left (Mobile) - ALWAYS VISIBLE ON MOBILE */
.login-box_btn {
    /* Original positioning preserved */
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    z-index: 10000 !important;
    height: 50px !important;
    pointer-events: auto !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
    color: var(--text-primary) !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0.75rem 1.5rem !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1) !important;
    transition: all var(--transition-normal) !important;
    cursor: pointer !important;
    outline: none !important;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
}

/* Ensure button is visible at ALL mobile widths */
@media (max-width: 999px) {
    .login-box_btn {
        display: flex !important;
    }
}

@media (max-width: 500px) {
    .login-box_btn {
        display: flex !important;
        font-size: 0.9rem !important;
        padding: 0.5rem 1rem !important;
    }
}

@media (max-width: 350px) {
    .login-box_btn {
        display: flex !important;
        font-size: 0.85rem !important;
        padding: 0.5rem 0.75rem !important;
    }
    
    .login-box_btn span {
        display: inline !important;
    }
}

.login-box_btn:hover,
.modern-show-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.15) !important;
}

.login-box_btn:active,
.login-box_btn:focus,
.modern-show-btn:active,
.modern-show-btn:focus {
    outline: none !important;
}

/* Hide Button - Bottom Right on Card (Mobile) */
.hide-box_btn {
    /* Original positioning preserved */
    width: 90px !important;
    z-index: 10000 !important;
    right: 0 !important;
    margin-top: -20px !important;
    height: 50px !important;
    position: fixed !important;
    bottom: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    pointer-events: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(255, 255, 255, 0.9) !important;
    color: var(--primary-color) !important;
    border: 2px solid rgba(0, 0, 0, 0.15) !important;
    transition: all var(--transition-normal) !important;
    cursor: pointer !important;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1) !important;
    outline: none !important;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
}

.hide-box_btn:hover,
.modern-toggle-btn:hover {
    background: white !important;
    transform: translateY(-2px);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15) !important;
}

.hide-box_btn:active,
.hide-box_btn:focus,
.modern-toggle-btn:active,
.modern-toggle-btn:focus {
    outline: none !important;
}

.hide-box_btn i,
.modern-toggle-btn i {
    font-size: 1.2rem;
    transition: transform var(--transition-normal);
}

.hide-box_btn:hover i,
.modern-toggle-btn:hover i {
    transform: translateY(2px);
}

/* Critical: Ensure button visible at ALL small widths */
@media (max-width: 500px) {
    /* Override any conflicting rules */
    .login-box_btn,
    button.login-box_btn,
    .login-box_btn:not([style*="display: none"]) {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: 10000 !important;
    }
}

@media (max-width: 320px) {
    /* Extra small devices - ensure button still visible */
    .login-box_btn {
        display: flex !important;
        height: 45px !important;
        font-size: 0.8rem !important;
    }
}

/* Desktop - Hide mobile buttons, ALWAYS show form */
@media (min-width: 1000px) {
    .login-box_btn,
    .hide-box_btn {
        display: none !important;
    }
    
    /* Force form to be visible on desktop, regardless of inline styles from JS */
    .login-box,
    .login-box[style],
    .login-box[style*="display: none"],
    .login-box[style*="display:none"] {
        display: block !important;
        position: absolute !important;
        top: -10px !important;
        right: 0 !important;
        background: transparent !important;
        padding: 0 !important;
        opacity: 1 !important;
        visibility: visible !important;
        height: auto !important;
        width: auto !important;
        bottom: auto !important;
        left: auto !important;
        overflow: visible !important;
    }
    
    .modern-login-container {
        position: absolute !important;
        right: 0 !important;
        top: -10px !important;
        margin: 0 auto !important;
        left: auto !important;
    }
    
    /* Reset all mobile styles on desktop */
    .login-box .card,
    .modern-card {
        max-width: 420px !important;
        min-width: 400px !important;
    }
    
    .login-box .card-body,
    .modern-body {
        padding: 2.5rem 2rem !important;
    }
}

/* Mobile/Tablet - Show buttons, hide form initially */
@media (max-width: 999px) {
    /* Show button ALWAYS visible by default on mobile - even at small widths */
    .login-box_btn:not([style*="display: none"]):not([style*="display:none"]) {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
    }
    
    /* When JavaScript hides show button (only after click) */
    .login-box_btn[style*="display: none"],
    .login-box_btn[style*="display:none"] {
        display: none !important;
    }
    
    /* Hide button is always visible when parent form is visible */
    .hide-box_btn {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* Login form hidden by default - will be shown by JavaScript */
    .login-box:not([style*="display: block"]):not([style*="display:block"]) {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
    }
    
    /* When JavaScript shows the form */
    .login-box[style*="display: block"],
    .login-box[style*="display:block"] {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
}

/* ========================================
   MODERN ERROR & VALIDATION
   ======================================== */
.modern-error,
.modern-error-container .failureNotification {
    color: var(--error-color) !important;
    font-size: 0.8rem !important;
    margin-top: 0.3rem;
    display: block;
    animation: shake 0.5s;
}

.modern-notification,
.modern-error-container .failureNotification {
    display: block;
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid var(--error-color);
    border-radius: var(--border-radius);
    color: var(--error-color) !important;
    font-size: 0.9rem;
    margin: 1rem 0;
    animation: slideIn 0.3s ease-out;
}

.modern-validation {
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid var(--error-color);
    border-radius: var(--border-radius);
    padding: 0.75rem 1rem;
    color: var(--error-color) !important;
    font-size: 0.85rem;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Desktop - Form on Right Side, Top Aligned */
@media (min-width: 1000px) {
    .modern-login-container {
        position: absolute !important;
        right: 0 !important;
        top: -10px !important;
        margin: 0 auto !important;
        left: auto !important;
    }
    
    .modern-card {
        max-width: 420px;
        min-width: 400px;
    }
}

/* Mobile/Tablet - Overlay Form (< 1000px) */
@media (max-width: 999px) {
    .login-box {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        height: 100vh !important;
        overflow-y: auto !important;
        z-index: 1000 !important;
        background: rgba(0, 0, 0, 0.5) !important; /* Dim background */
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 1rem !important;
        padding-bottom: 60px !important; /* Space for hide button */
    }
    
    .login-box .card,
    .modern-card {
        margin: 0 auto !important;
        width: 100% !important;
        max-width: 450px !important;
        height: auto !important; /* Natural height */
        min-height: auto !important; /* Remove min-height */
    }
    
    .login-box .card-body,
    .modern-body {
        padding: 1.5rem 1rem !important;
    }
}

/* Mobile Specific - Compact layout */
@media (max-width: 576px) {
    .login-box {
        padding: 0.5rem !important;
        padding-bottom: 60px !important;
    }
    
    .login-box .card,
    .modern-card {
        border-radius: var(--border-radius) !important;
        max-width: 100% !important;
    }
    
    .login-box .card-header,
    .modern-header {
        padding: 1.5rem 1rem !important;
    }
    
    .login-box .card-body,
    .modern-body {
        padding: 1.25rem 1rem !important;
    }
    
    .login-box .card-header .brand-image,
    .modern-logo {
        width: 60px !important;
        height: 60px !important;
    }
    
    .modern-links {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 0.75rem;
    }
    
    .shape {
        display: none;
    }
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */
.Material .modern-card,
.Office365Dark .modern-card {
    background: rgba(31, 41, 55, 0.8) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.Material .modern-input .dxeTextBox,
.Material .modern-input .dxeEditArea,
.Material .modern-select,
.Office365Dark .modern-input .dxeTextBox,
.Office365Dark .modern-input .dxeEditArea,
.Office365Dark .modern-select {
    background: rgba(55, 65, 81, 0.8) !important;
    color: #f3f4f6 !important;
    border-color: rgba(99, 102, 241, 0.2) !important;
}

.Material .modern-subtitle,
.Material .modern-label,
.Office365Dark .modern-subtitle,
.Office365Dark .modern-label {
    color: #d1d5db !important;
}

.Material .input-icon,
.Office365Dark .input-icon {
    color: #9ca3af;
}

.Material .divider::before,
.Material .divider::after,
.Office365Dark .divider::before,
.Office365Dark .divider::after {
    border-color: rgba(255, 255, 255, 0.1);
}

.Material .divider span,
.Office365Dark .divider span {
    color: #9ca3af;
}

/* ========================================
   LOADING PANEL MODERN STYLES
   ======================================== */
.dxlpLoadingPanel_Material,
.dxlpLoadingPanel_MaterialCompact {
    background: var(--bg-glass) !important;
    backdrop-filter: blur(10px) !important;
    border-radius: var(--border-radius) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

/* ========================================
   SMOOTH SCROLLBAR
   ======================================== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 10px;
    transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* ========================================
   ANIMATIONS & TRANSITIONS
   ======================================== */
.modern-card,
.modern-input,
.modern-button,
.modern-link,
.modern-select {
    will-change: transform;
}

/* Smooth focus transitions */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.text-gradient {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glass-effect {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.shadow-modern {
    box-shadow: var(--shadow-2xl);
}

/* ========================================
   DEVEXPRESS CONTROL COMPATIBILITY
   ======================================== */

/* Ensure DevExpress controls maintain functionality */
.modern-input table,
.modern-input tbody,
.modern-input tr,
.modern-input td {
    width: 100% !important;
    border: none !important;
}

/* DevExpress Button compatibility */
#LoginButton table,
#LoginButton tbody,
#LoginButton tr,
#LoginButton td {
    border: none !important;
}

/* Ensure input fields maintain focus behavior */
.modern-input .dxeEditArea input,
.modern-input .dxeEditArea {
    width: 100% !important;
    border: none !important;
    background: transparent !important;
}

/* These rules are now defined in the MODERN TOGGLE BUTTONS section above */

/* Ensure dropdown works properly */
.modern-select option {
    background: white;
    color: var(--text-primary);
    padding: 8px;
}

.Material .modern-select option,
.Office365Dark .modern-select option {
    background: #374151;
    color: #f3f4f6;
}

/* Preserve z-index hierarchy */
.modern-login-container {
    z-index: 10 !important;
    position: relative;
}

/* Bottom buttons already have z-index defined above */

/* Ensure form elements are clickable */
.modern-input-group input,
.modern-input-group select,
.modern-input-group .dxeTextBox {
    pointer-events: auto !important;
}

/* Loading panel compatibility */
.dxlpLoadingPanel_MaterialCompact,
.dxlpLoadingPanel_Material {
    z-index: 9999 !important;
}

/* Popup control compatibility */
.dxpcLite_Material,
.dxpcLite_MaterialCompact,
.dxpcLite_Office365,
.dxpcLite_Office365Dark {
    z-index: 10000 !important;
}

/* ========================================
   JAVASCRIPT INTERACTION FIXES
   ======================================== */

/* Ensure jQuery can find and manipulate elements */
.login-box {
    /* Will be toggled by JavaScript */
    transition: opacity 0.3s ease, transform 0.3s ease !important;
}

/* Desktop - Right side with smooth slide */
@media (min-width: 1000px) {
    .login-box[style*="display: none"] {
        opacity: 0;
        transform: translateX(50px);
        pointer-events: none;
    }

    .login-box[style*="display: block"] {
        opacity: 1;
        transform: translateX(0);
        pointer-events: auto;
    }
}

/* Mobile/Tablet - Smooth fade in/out */
@media (max-width: 999px) {
    .login-box[style*="display: none"],
    .login-box[style*="display:none"] {
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        transition: opacity 0.3s ease, visibility 0.3s ease !important;
    }

    .login-box[style*="display: block"],
    .login-box[style*="display:block"] {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        animation: fadeInScale 0.3s ease-out;
    }
    
    @keyframes fadeInScale {
        from {
            opacity: 0;
            transform: scale(0.95);
        }
        to {
            opacity: 1;
            transform: scale(1);
        }
    }
    
    /* Show button smooth hide */
    .login-box_btn[style*="display: none"],
    .login-box_btn[style*="display:none"] {
        opacity: 0 !important;
        transform: translateY(10px) !important;
        transition: all 0.3s ease !important;
    }
}

/* Smooth transitions for show/hide */
.login-box_btn {
    transition: opacity 0.3s ease, transform 0.3s ease !important;
}

/* Prevent double-click issues but preserve button clicks */
button:not(.login-box_btn):not(.hide-box_btn) {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* Ensure bottom buttons are always clickable */
.login-box_btn,
.hide-box_btn {
    pointer-events: auto !important;
    cursor: pointer !important;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* ========================================
   MOBILE JAVASCRIPT COMPATIBILITY
   ======================================== */
@media (max-width: 999px) {
    /* Ensure buttons are accessible on mobile */
    .login-box_btn {
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.3);
    }
    
    .hide-box_btn {
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.3);
    }
}

/* ========================================
   COOKIE & SESSION COMPATIBILITY
   ======================================== */

/* Remember me checkbox - ensure it's clickable */
#remember {
    cursor: pointer;
    pointer-events: auto;
    z-index: 1;
}

#remember + label {
    cursor: pointer;
    pointer-events: auto;
}

/* Autologin checkbox */
#autologin {
    cursor: pointer;
    pointer-events: auto;
}

/* ========================================
   AJAX & FORM SUBMISSION COMPATIBILITY
   ======================================== */

/* Ensure form elements maintain their IDs for jQuery selectors */
#UserName_I,
#Password_I,
#LoginButton_I,
#DropDownList1 {
    /* jQuery uses these IDs - must remain accessible */
    pointer-events: auto !important;
}

/* Maintain input focus for Enter key submission */
.modern-input input:focus {
    outline: none !important;
}

/* Ensure validation messages display properly */
.failureNotification {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========================================
   FINAL COMPATIBILITY NOTES
   
   All JavaScript functionality from Logi.js is preserved:
   ✓ Show/hide login box on mobile
   ✓ Form login with AJAX
   ✓ Google Sign-In
   ✓ Remember me functionality
   ✓ Auto-login feature
   ✓ Cookie management
   ✓ Enter key submission
   ✓ DevExpress control interactions
   ✓ Popup windows
   ✓ Loading panel
   
   If issues occur:
   1. Clear browser cache (Ctrl+F5)
   2. Check browser console for errors
   3. Verify DevExpress scripts are loaded
   4. Ensure jQuery is loaded before Logi.js
   ======================================== */

