/* ==========================================
   EKENDRA - AUTH PAGE CSS (UPGRADED)
   Modern, Animated, Dark Mode Ready
   ========================================== */

/* ===== ROOT VARIABLES ===== */
:root {
    /* Colors */
    --auth-primary: #4F46E5;
    --auth-primary-dark: #4338CA;
    --auth-primary-light: #818CF8;
    --auth-primary-glow: rgba(79, 70, 229, 0.15);
    
    --auth-success: #10B981;
    --auth-danger: #EF4444;
    --auth-warning: #F59E0B;
    
    /* Backgrounds */
    --auth-bg: #F8FAFC;
    --auth-bg-card: #FFFFFF;
    --auth-bg-hover: #F1F5F9;
    --auth-bg-input: #F8FAFC;
    
    /* Text */
    --auth-text-primary: #0F172A;
    --auth-text-secondary: #475569;
    --auth-text-muted: #94A3B8;
    
    /* Borders */
    --auth-border: #E2E8F0;
    --auth-border-focus: #4F46E5;
    
    /* Effects */
    --auth-shadow: 0 20px 60px rgba(0, 0, 0, 0.08);
    --auth-shadow-hover: 0 25px 80px rgba(79, 70, 229, 0.12);
    --auth-radius: 20px;
    --auth-radius-sm: 10px;
    --auth-radius-lg: 28px;
    
    /* Transitions */
    --auth-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== DARK THEME ===== */
[data-theme="dark"] {
    --auth-bg: #0F172A;
    --auth-bg-card: #1E293B;
    --auth-bg-hover: #334155;
    --auth-bg-input: #1E293B;
    
    --auth-text-primary: #F1F5F9;
    --auth-text-secondary: #94A3B8;
    --auth-text-muted: #64748B;
    
    --auth-border: #334155;
    --auth-border-focus: #818CF8;
    
    --auth-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    --auth-shadow-hover: 0 25px 80px rgba(79, 70, 229, 0.2);
}

/* ===== BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.auth-body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--auth-bg);
    padding: 24px;
    transition: var(--auth-transition);
    position: relative;
    overflow: hidden;
}

/* ===== ANIMATED BACKGROUND ===== */
.auth-body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        radial-gradient(circle at 30% 50%, var(--auth-primary-glow) 0%, transparent 50%),
        radial-gradient(circle at 70% 80%, rgba(124, 58, 237, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 50% 20%, rgba(79, 70, 229, 0.05) 0%, transparent 40%);
    z-index: 0;
    animation: authBgFloat 20s ease-in-out infinite;
}

[data-theme="dark"] .auth-body::before {
    background: 
        radial-gradient(circle at 30% 50%, rgba(79, 70, 229, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 70% 80%, rgba(124, 58, 237, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 50% 20%, rgba(79, 70, 229, 0.03) 0%, transparent 40%);
}

@keyframes authBgFloat {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(5deg) scale(1.05); }
}

/* ===== FLOATING PARTICLES ===== */
.auth-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--auth-primary);
    border-radius: 50%;
    opacity: 0.1;
    animation: particleFloat linear infinite;
}

.particle:nth-child(1) { left: 10%; animation-duration: 12s; animation-delay: 0s; width: 8px; height: 8px; }
.particle:nth-child(2) { left: 20%; animation-duration: 15s; animation-delay: 2s; width: 4px; height: 4px; }
.particle:nth-child(3) { left: 35%; animation-duration: 18s; animation-delay: 4s; width: 10px; height: 10px; }
.particle:nth-child(4) { left: 50%; animation-duration: 14s; animation-delay: 1s; width: 6px; height: 6px; }
.particle:nth-child(5) { left: 65%; animation-duration: 16s; animation-delay: 3s; width: 5px; height: 5px; }
.particle:nth-child(6) { left: 75%; animation-duration: 20s; animation-delay: 5s; width: 7px; height: 7px; }
.particle:nth-child(7) { left: 85%; animation-duration: 13s; animation-delay: 2s; width: 4px; height: 4px; }
.particle:nth-child(8) { left: 95%; animation-duration: 17s; animation-delay: 4s; width: 9px; height: 9px; }

@keyframes particleFloat {
    0% { transform: translateY(100vh) scale(0); opacity: 0; }
    10% { opacity: 0.1; }
    90% { opacity: 0.1; }
    100% { transform: translateY(-100vh) scale(1); opacity: 0; }
}

/* ===== AUTH CONTAINER ===== */
.auth-container {
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
    animation: authSlideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes authSlideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== AUTH BOX ===== */
.auth-box {
    background: var(--auth-bg-card);
    padding: 44px 40px 36px;
    border-radius: var(--auth-radius);
    box-shadow: var(--auth-shadow);
    border: 1px solid var(--auth-border);
    transition: var(--auth-transition);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.auth-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--auth-primary), #7C3AED, var(--auth-primary));
    background-size: 200% 100%;
    animation: authShimmer 3s ease-in-out infinite;
}

@keyframes authShimmer {
    0%, 100% { background-position: 0% 0%; }
    50% { background-position: 100% 0%; }
}

.auth-box:hover {
    box-shadow: var(--auth-shadow-hover);
    transform: translateY(-4px);
}

/* ===== BRAND ===== */
.auth-brand {
    text-align: center;
    margin-bottom: 32px;
}

.logo-link {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    font-size: 28px;
    font-weight: 800;
    color: var(--auth-text-primary);
    transition: var(--auth-transition);
}

.logo-link .logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--auth-primary), #7C3AED);
    border-radius: var(--auth-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 900;
    color: white;
    box-shadow: 0 4px 16px var(--auth-primary-glow);
    transition: var(--auth-transition);
}

.logo-link:hover .logo-icon {
    transform: rotate(-5deg) scale(1.05);
}

.logo-link span {
    background: linear-gradient(135deg, var(--auth-primary), #7C3AED);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-link .logo-text-light {
    -webkit-text-fill-color: var(--auth-text-primary);
}

.auth-brand .subtitle {
    color: var(--auth-text-muted);
    font-size: 15px;
    margin-top: 6px;
    font-weight: 400;
}

/* ===== AUTH TITLE ===== */
.auth-title {
    text-align: center;
    margin-bottom: 28px;
}

.auth-title h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--auth-text-primary);
    margin-bottom: 4px;
}

.auth-title p {
    color: var(--auth-text-muted);
    font-size: 14px;
}

/* ===== ALERT ===== */
.alert {
    padding: 14px 18px;
    border-radius: var(--auth-radius-sm);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    animation: alertSlide 0.4s ease forwards;
}

@keyframes alertSlide {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.alert i {
    font-size: 18px;
    flex-shrink: 0;
}

.alert-error {
    background: rgba(239, 68, 68, 0.08);
    color: var(--auth-danger);
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.alert-success {
    background: rgba(16, 185, 129, 0.08);
    color: var(--auth-success);
    border: 1px solid rgba(16, 185, 129, 0.15);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.08);
    color: var(--auth-warning);
    border: 1px solid rgba(245, 158, 11, 0.15);
}

.alert .alert-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 18px;
    opacity: 0.6;
    transition: var(--auth-transition);
    padding: 0 4px;
}

.alert .alert-close:hover {
    opacity: 1;
}

/* ===== FORM ===== */
.auth-form .form-group {
    margin-bottom: 20px;
}

.auth-form .form-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: var(--auth-text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}

.auth-form .form-group label i {
    color: var(--auth-primary);
    margin-right: 8px;
    width: 16px;
}

.auth-form .form-group .label-hint {
    float: right;
    font-weight: 400;
    font-size: 12px;
    color: var(--auth-text-muted);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
    font-size: 15px;
    transition: var(--auth-transition);
    font-family: 'Inter', sans-serif;
    background: var(--auth-bg-input);
    color: var(--auth-text-primary);
    box-sizing: border-box;
}

.form-control:focus {
    border-color: var(--auth-border-focus);
    outline: none;
    box-shadow: 0 0 0 4px var(--auth-primary-glow);
    background: var(--auth-bg-card);
}

.form-control::placeholder {
    color: var(--auth-text-muted);
}

.form-control:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.form-control.error {
    border-color: var(--auth-danger);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

.form-control.success {
    border-color: var(--auth-success);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

/* ===== PASSWORD WRAPPER ===== */
.password-wrapper {
    position: relative;
}

.password-wrapper .form-control {
    padding-right: 48px;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--auth-text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 6px;
    transition: var(--auth-transition);
    border-radius: 6px;
}

.toggle-password:hover {
    color: var(--auth-primary);
    background: var(--auth-bg-hover);
}

/* ===== PASSWORD STRENGTH ===== */
.password-strength {
    margin-top: 8px;
    display: none;
}

.password-strength.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.password-strength .strength-bar {
    width: 100%;
    height: 4px;
    background: var(--auth-border);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 4px;
}

.password-strength .strength-fill {
    height: 100%;
    width: 0%;
    border-radius: 4px;
    transition: width 0.4s ease, background 0.4s ease;
}

.password-strength .strength-label {
    font-size: 12px;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
}

/* ===== FORM OPTIONS ===== */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--auth-text-secondary);
    cursor: pointer;
    user-select: none;
    transition: var(--auth-transition);
}

.checkbox-label:hover {
    color: var(--auth-text-primary);
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--auth-border);
    border-radius: 6px;
    position: relative;
    transition: var(--auth-transition);
    flex-shrink: 0;
    background: var(--auth-bg-input);
}

.checkbox-label input:checked + .checkmark {
    background: var(--auth-primary);
    border-color: var(--auth-primary);
    animation: checkboxPop 0.3s ease;
}

@keyframes checkboxPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.checkbox-label input:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 13px;
    font-weight: 700;
}

.forgot-link {
    color: var(--auth-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--auth-transition);
}

.forgot-link:hover {
    color: var(--auth-primary-dark);
    text-decoration: underline;
}

/* ===== BUTTON ===== */
.btn-login {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--auth-radius-sm);
    background: linear-gradient(135deg, var(--auth-primary), #7C3AED);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: var(--auth-transition);
    font-family: 'Inter', sans-serif;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px var(--auth-primary-glow);
}

.btn-login::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transition: left 0.6s ease;
}

.btn-login:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 35px var(--auth-primary-glow);
}

.btn-login:hover::before {
    left: 100%;
}

.btn-login:active {
    transform: translateY(0px);
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
}

.btn-login .spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-login.loading .spinner {
    display: inline-block;
}

.btn-login.loading .btn-text {
    display: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== DEMO SECTION ===== */
.demo-section {
    margin-top: 28px;
    padding: 18px 20px;
    background: var(--auth-bg-hover);
    border-radius: var(--auth-radius-sm);
    border: 1px solid var(--auth-border);
    transition: var(--auth-transition);
}

.demo-section:hover {
    border-color: var(--auth-primary);
}

.demo-section > p {
    font-size: 13px;
    color: var(--auth-text-muted);
    margin-bottom: 10px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.demo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.demo-item {
    background: var(--auth-bg-card);
    padding: 10px 14px;
    border-radius: var(--auth-radius-sm);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    border: 1px solid var(--auth-border);
    transition: var(--auth-transition);
}

.demo-item:hover {
    border-color: var(--auth-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.demo-item .role-tag {
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.demo-item .role-tag.admin {
    background: rgba(79, 70, 229, 0.12);
    color: var(--auth-primary);
}

.demo-item .role-tag.retailer {
    background: rgba(16, 185, 129, 0.12);
    color: var(--auth-success);
}

.demo-item .role-tag.distributor {
    background: rgba(245, 158, 11, 0.12);
    color: var(--auth-warning);
}

.demo-item .role-tag.master {
    background: rgba(124, 58, 237, 0.12);
    color: #7C3AED;
}

.demo-item code {
    background: var(--auth-bg-hover);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    color: var(--auth-text-secondary);
}

.demo-item .sep {
    color: var(--auth-text-muted);
    font-size: 12px;
}

.demo-item .demo-click {
    margin-left: auto;
    font-size: 12px;
    color: var(--auth-primary);
    opacity: 0;
    transition: var(--auth-transition);
}

.demo-item:hover .demo-click {
    opacity: 1;
}

/* ===== FOOTER ===== */
.auth-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--auth-border);
    font-size: 13px;
    color: var(--auth-text-muted);
}

.auth-footer a {
    color: var(--auth-primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--auth-transition);
}

.auth-footer a:hover {
    text-decoration: underline;
    color: var(--auth-primary-dark);
}

.auth-footer .footer-links {
    display: flex;
    gap: 16px;
}

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 520px) {
    .auth-box {
        padding: 32px 20px 28px;
        border-radius: var(--auth-radius-sm);
    }
    
    .auth-box::before {
        height: 2px;
    }
    
    .auth-brand .logo-link {
        font-size: 24px;
    }
    
    .auth-brand .logo-link .logo-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .auth-title h2 {
        font-size: 20px;
    }
    
    .demo-grid {
        grid-template-columns: 1fr;
    }
    
    .form-options {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .auth-footer {
        flex-direction: column;
        align-items: center;
        gap: 8px;
        text-align: center;
    }
    
    .auth-footer .footer-links {
        gap: 12px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .demo-item .demo-click {
        opacity: 1;
    }
}

@media (max-width: 380px) {
    .auth-box {
        padding: 24px 16px 20px;
    }
    
    .auth-body {
        padding: 12px;
    }
    
    .btn-login {
        font-size: 14px;
        padding: 12px;
    }
}

/* ==========================================
   ANIMATIONS
   ========================================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

.slide-down {
    animation: slideDown 0.4s ease forwards;
}

/* ==========================================
   INPUT GROUP WITH ICON
   ========================================== */

.input-group {
    position: relative;
}

.input-group .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--auth-text-muted);
    font-size: 16px;
    transition: var(--auth-transition);
}

.input-group .form-control {
    padding-left: 44px;
}

.input-group .form-control:focus + .input-icon,
.input-group .form-control:focus ~ .input-icon {
    color: var(--auth-primary);
}

/* ==========================================
   DIVIDER
   ========================================== */

.auth-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 24px 0;
    color: var(--auth-text-muted);
    font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--auth-border);
}

/* ==========================================
   SOCIAL BUTTONS
   ========================================== */

.social-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-social {
    padding: 10px;
    border: 2px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
    background: var(--auth-bg-card);
    color: var(--auth-text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--auth-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: 'Inter', sans-serif;
}

.btn-social:hover {
    border-color: var(--auth-primary);
    color: var(--auth-primary);
    background: var(--auth-bg-hover);
}

.btn-social i {
    font-size: 18px;
}

/* ==========================================
   BACK TO HOME
   ========================================== */

.back-home {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--auth-text-muted);
    text-decoration: none;
    font-size: 13px;
    transition: var(--auth-transition);
    margin-bottom: 20px;
}

.back-home:hover {
    color: var(--auth-primary);
}

/* ==========================================
   TWO-FACTOR AUTH SPECIFIC
   ========================================== */

.otp-inputs {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin: 20px 0;
}

.otp-input {
    width: 52px;
    height: 60px;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    border: 2px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
    background: var(--auth-bg-input);
    color: var(--auth-text-primary);
    transition: var(--auth-transition);
}

.otp-input:focus {
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 4px var(--auth-primary-glow);
    outline: none;
}

.otp-input:not(:placeholder-shown) {
    border-color: var(--auth-success);
}

/* ==========================================
   TERMS CHECKBOX
   ========================================== */

.terms-text {
    font-size: 13px;
    color: var(--auth-text-muted);
    text-align: center;
    margin-top: 16px;
}

.terms-text a {
    color: var(--auth-primary);
    text-decoration: none;
    font-weight: 500;
}

.terms-text a:hover {
    text-decoration: underline;
}