/* ====================================
   MI Premium Login Page Design
   Fixed Color Scheme & Time-based Theming
   ==================================== */

/* CSS Variables for dynamic theming */
:root {
    /* Brand Colors */
    --brand-grey: hsl(0, 1%, 16%);
    --brand-green: hsl(69.58deg, 52.42%, 55.49%);
    --brand-orange: #ff6b35;
    --pure-white: #ffffff;
    --pure-black: #000000;

    /* Dynamic theme variables (updated by JavaScript) */
    --bg-primary: var(--pure-white);
    --bg-secondary: #f8fafc;
    --bg-accent: var(--brand-green);
    --text-primary: var(--pure-black);
    --text-secondary: rgba(0, 0, 0, 0.7);
    --form-bg: var(--pure-white);
    --form-text: var(--pure-black);
    --border-color: rgba(0, 0, 0, 0.1);
    --card-bg: rgba(255, 255, 255, 0.8);
    --shadow-color: rgba(0, 0, 0, 0.1);

    /* Effects */
    --shadow-light: 0 2px 10px var(--shadow-color);
    --shadow-medium: 0 4px 20px var(--shadow-color);
    --shadow-heavy: 0 8px 30px var(--shadow-color);
    --border-radius: 12px;
    --border-radius-lg: 20px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Light Theme (Default) */
.theme-light,
body:not([data-theme]) {
    --bg-primary: var(--pure-white);
    --bg-secondary: #f8fafc;
    --bg-accent: var(--brand-green);
    --text-primary: var(--pure-black);
    --text-secondary: rgba(0, 0, 0, 0.7);
    --form-bg: var(--pure-white);
    --form-text: var(--pure-black);
    --border-color: rgba(0, 0, 0, 0.1);
    --card-bg: rgba(255, 255, 255, 0.9);
    --shadow-color: rgba(0, 0, 0, 0.1);
    --logo-filter: none;
    --provider-bg: rgba(0, 0, 0, 0.05);
}

/* Dark Theme */
.theme-dark,
body[data-theme="dark"] {
    --bg-primary: var(--brand-grey);
    --bg-secondary: hsl(0, 1%, 20%);
    --bg-accent: var(--brand-green);
    --text-primary: var(--pure-white);
    --text-secondary: rgba(255, 255, 255, 0.8);
    --form-bg: var(--pure-white);
    --form-text: var(--pure-black);
    --border-color: rgba(255, 255, 255, 0.2);
    --card-bg: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.3);
    --logo-filter: brightness(0) invert(1);
    --provider-bg: rgba(255, 255, 255, 0.1);
}

/* Reset and base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body.premium-login {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition-smooth);
}

/* Main container */
.premium-login-wrapper {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    position: relative;
    overflow: hidden;
}

/* Left Panel - Feature Showcase */
.feature-panel {
    position: relative;
    z-index: 2;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    background: var(--bg-primary);
    transition: var(--transition-smooth);
    min-height: 100vh;
    overflow-y: auto;
}

/* Brand Section */
.brand-section {
    margin-bottom: 3rem;
    text-align: left;
}

.logo-container {
    margin-bottom: 2rem;
}

.logo-container img {
    height: 80px;
    width: auto;
    transition: var(--transition-smooth);
    filter: var(--logo-filter);
    background: transparent;
    padding: 8px;
    border-radius: 12px;
}

.brand-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.brand-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 300;
    margin-bottom: 0.5rem;
    min-height: 1.6em;
    width: 100%;
    max-width: 450px;
}

.brand-description {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 400px;
}

/* Mobile Money Providers */
.providers-section {
    margin: 2rem 0;
}

.providers-title {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    font-weight: 500;
}

.providers-list {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.provider-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border-radius: 12px;
    transition: var(--transition-smooth);
    cursor: pointer;
    border: 2px solid transparent;
    min-width: 100px;
}

.provider-item.provider-active {
    background: var(--card-bg);
    border-color: var(--bg-accent);
    box-shadow: var(--shadow-light);
}

.provider-item.provider-active:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
    border-color: var(--brand-orange);
}

.provider-item.provider-coming-soon {
    background: var(--provider-bg);
    border-color: var(--border-color);
    opacity: 0.7;
}

.provider-logo {
    height: 40px;
    width: auto;
    transition: var(--transition-smooth);
    border-radius: 6px;
    background: transparent;
}

.provider-logo img {
    height: 100%;
    width: auto;
    object-fit: contain;
}


/* M2U Logo */
.m2u-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 40px;
    background: #7d7d7d7d;
    border-radius: 8px;
    overflow: hidden;
}

.m2u-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.m2u-text {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--pure-white);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.provider-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.2;
}

/* Features Section */
.features-section {
    margin-top: 2rem;
}

.features-title {
    font-size: 1.125rem;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.features-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr 1fr;
}

.feature-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    transition: var(--transition-smooth);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-light);
}

.feature-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
    background: var(--bg-accent);
    color: var(--pure-white);
}

.feature-icon {
    width: 20px;
    height: 20px;
    color: var(--bg-accent);
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.feature-card:hover .feature-icon {
    color: var(--pure-white);
}

.feature-title {
    font-size: 0.875rem;
    color: inherit;
    font-weight: 500;
    line-height: 1.4;
}

/* Right Panel - Login Form */
.login-panel {
    position: relative;
    z-index: 2;
    background: #f3f3f3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--form-text);
    transition: var(--transition-smooth);
    min-height: 100vh;
    overflow-y: auto;
}

/* Dark theme login panel */
body[data-theme="dark"] .login-panel {
    background: hsl(0, 1%, 20%);
}

/* Dark theme form background */
body[data-theme="dark"] .login-form-container {
    padding: 2rem;
}

.login-container {
    background: var(--pure-white);
    color: var(--pure-black);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-heavy);
    width: 100%;
    max-width: 400px;
    position: sticky;
    top: 33%;
    transform: translateY(-50%);
}

/* Language Switcher & Theme Toggle */
.top-controls {
    position: absolute;
    top: 2rem;
    right: 2rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.language-switcher {
    display: flex;
    gap: 0.5rem;
}

/* Theme Toggle Button */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition-smooth);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-light);
    position: relative;
    overflow: hidden;
}

.theme-toggle:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-medium);
    border-color: var(--bg-accent);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-icon {
    font-size: 1.2rem;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Theme icon animations */
.theme-toggle[data-theme="light"] .theme-icon::before {
    content: "☀️";
}

.theme-toggle[data-theme="dark"] .theme-icon::before {
    content: "🌙";
}

.theme-toggle .theme-icon::before {
    display: inline-block;
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.theme-toggle:hover .theme-icon::before {
    transform: rotate(180deg);
}

.lang-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--bg-accent);
    border-radius: 8px;
    color: var(--bg-accent);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.lang-button:hover,
.lang-button.active {
    background: var(--bg-accent);
    color: var(--pure-white);
    text-decoration: none;
}

.lang-flag {
    width: 20px;
    height: auto;
    border-radius: 2px;
}

/* Login Form */
.login-form-container {
    text-align: center;
    padding: 2rem;
}

.login-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--bg-accent);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.login-subtitle {
    font-size: 1rem;
    color: var(--form-text);
    opacity: 0.7;
    margin-bottom: 2.5rem;
}

.login-form {
    text-align: left;
}

/* Form Groups */
.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.form-group-floating {
    position: relative;
}

.form-control-floating {
    width: 100%;
    padding: 1rem 1rem 0.5rem;
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius);
    font-size: 1rem;
    background: var(--form-bg);
    transition: var(--transition-smooth);
    outline: none;
    color: var(--form-text);
}

.form-control-floating:focus {
    border-color: var(--bg-accent);
    box-shadow: 0 0 0 3px rgba(156, 185, 106, 0.1);
}

.form-control-floating:focus + .form-label-floating,
.form-control-floating:not(:placeholder-shown) + .form-label-floating {
    transform: translateY(-0.5rem) scale(0.85);
    color: var(--bg-accent);
}

.form-label-floating {
    position: absolute;
    top: 1rem;
    left: 1rem;
    font-size: 1rem;
    color: var(--form-text);
    opacity: 0.6;
    pointer-events: none;
    transition: var(--transition-smooth);
    transform-origin: left;
}

/* Error handling */
.form-error {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, #fee, #fdd);
    border: 1px solid #f5c6cb;
    border-radius: var(--border-radius);
    color: #721c24;
    font-size: 0.875rem;
    border-left: 4px solid #dc3545;
}

/* Captcha */
.captcha-container {
    margin-bottom: 1.5rem;
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 2px solid #e9ecef;
    transition: var(--transition-smooth);
}

.captcha-container:focus-within {
    border-color: var(--bg-accent);
    box-shadow: 0 0 0 3px rgba(156, 185, 106, 0.1);
}

/* Remember Me */
.remember-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 1rem;
}

.custom-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--form-text);
    opacity: 0.8;
}

.custom-checkbox input {
    width: 18px;
    height: 18px;
    accent-color: var(--bg-accent);
}

.forgot-password {
    color: var(--bg-accent);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.forgot-password:hover {
    text-decoration: underline;
    opacity: 0.8;
}

/* Submit Button */
.btn-login {
    width: 100%;
    padding: 1rem 2rem;
    background: var(--bg-accent);
    border: none;
    border-radius: var(--border-radius);
    color: var(--pure-white);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
    filter: brightness(1.1);
}

.btn-login:active {
    transform: translateY(0);
}

/* Help Links */
.help-section {
    margin-top: 2rem;
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid #e9ecef;
}

.help-links {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.help-link {
    color: var(--form-text);
    opacity: 0.6;
    text-decoration: none;
    font-size: 0.875rem;
    transition: var(--transition-smooth);
    padding: 0.5rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.help-link:hover {
    color: var(--bg-accent);
    opacity: 1;
    text-decoration: none;
}

/* Security Indicators */
.security-section {
    margin-top: 2rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: var(--border-radius);
    text-align: center;
}

.security-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--bg-accent);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.security-badges {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.security-badge {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--form-text);
    opacity: 0.7;
    background: var(--form-bg);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    border: 1px solid #e9ecef;
}

.security-icon {
    width: 14px;
    height: 14px;
    color: hsl(69.58deg, 52.42%, 55.49%);
}

/* Time indicator */
.time-indicator {
    position: fixed;
    top: 1rem;
    left: 1rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    z-index: 1000;
    opacity: 0.5;
}

/* Copyright Footer */
.copyright-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.copyright-content {
    padding: 0.75rem 1rem;
    text-align: center;
}

.copyright-content p {
    margin: 0;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 400;
}

.copyright-content a {
    color: var(--brand-green);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.copyright-content a:hover {
    color: var(--pure-white);
    text-decoration: underline;
}

/* Dark theme adjustments */
body[data-theme="dark"] .copyright-footer {
    background: rgba(0, 0, 0, 0.9);
    border-top-color: rgba(255, 255, 255, 0.2);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .premium-login-wrapper {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
    }

    .login-panel {
        order: -1;
        min-height: 100vh;
        padding: 2rem;
    }

    .feature-panel {
        order: 1;
        padding: 2rem;
        border-right: none;
        border-top: 1px solid var(--border-color);
        min-height: auto;
    }

    .login-container {
        position: static;
        transform: none;
        max-width: 100%;
    }

    .brand-title {
        font-size: 2rem;
    }

    .features-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    .feature-panel {
        padding: 1.5rem;
    }

    .login-panel {
        padding: 1.5rem 1.5rem 1rem; /* Réduit encore le padding */
        display: block; /* Assure que c'est en block */
        min-height: auto; /* Pas de hauteur minimale */
        align-items: flex-start; /* Si flex est utilisé ailleurs */
        justify-content: flex-start;
    }

    .login-container {
        width: 100%;
        max-width: 400px;
        margin: 0 auto;
        position: static; /* Assure que le positionnement est statique */
        transform: none;
        top: auto;
    }

    .top-controls {
        position: static;
        justify-content: center;
        margin-bottom: 2rem;
    }

    .login-title {
        font-size: 1.75rem;
    }

    .brand-title {
        font-size: 1.75rem;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    .help-links {
        flex-direction: column;
        gap: 1rem;
    }

    .remember-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .providers-list {
        flex-wrap: wrap;
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .feature-panel,
    .login-panel {
        padding: 1rem;
        padding-bottom: 3rem; /* Add space for footer */
    }

    .login-container {
        max-width: none;
        margin: 0; /* Supprime les marges auto pour occuper toute la largeur */
    }

    .security-badges {
        flex-direction: column;
        gap: 0.5rem;
    }

    .copyright-content {
        padding: 0.5rem 1rem;
    }

    .copyright-content p {
        font-size: 0.6875rem;
    }
}

/* Loading Animation */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus improvements */
.btn-login:focus,
.form-control-floating:focus,
.lang-button:focus,
.help-link:focus,
.forgot-password:focus {
    outline: 2px solid var(--bg-accent);
    outline-offset: 2px;
}

/* Theme transition */
.theme-transitioning,
.theme-transitioning *,
.theme-transitioning *::before,
.theme-transitioning *::after {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* System theme preferences */
@media (prefers-color-scheme: dark) {
    body:not([data-theme]) {
        --bg-primary: var(--brand-grey);
        --bg-secondary: hsl(0, 1%, 20%);
        --text-primary: var(--pure-white);
        --text-secondary: rgba(255, 255, 255, 0.8);
        --form-bg: var(--pure-white);
        --form-text: var(--pure-black);
        --border-color: rgba(255, 255, 255, 0.2);
        --card-bg: rgba(255, 255, 255, 0.1);
        --shadow-color: rgba(0, 0, 0, 0.3);
        --logo-filter: brightness(0) invert(1);
        --provider-bg: rgba(255, 255, 255, 0.1);
    }
}

/* Dark theme form adjustments */
body[data-theme="dark"] .form-control-floating {
    background: var(--form-bg);
    color: var(--form-text);
    border: 2px solid hsl(0, 1%, 85%);
}

body[data-theme="dark"] .form-control-floating:focus {
    border-color: var(--bg-accent);
    box-shadow: 0 0 0 3px rgba(156, 185, 106, 0.2);
}

body[data-theme="dark"] .form-label-floating {
    color: var(--form-text);
    opacity: 0.7;
}

body[data-theme="dark"] .form-control-floating:focus + .form-label-floating,
body[data-theme="dark"] .form-control-floating:not(:placeholder-shown) + .form-label-floating {
    color: var(--bg-accent);
    opacity: 1;
}

/* Dark theme captcha */
body[data-theme="dark"] .captcha-container {
    border: 2px solid hsl(0, 1%, 85%);
}

body[data-theme="dark"] .captcha-container:focus-within {
    border-color: var(--bg-accent);
    box-shadow: 0 0 0 3px rgba(156, 185, 106, 0.2);
}

/* Better grid layout for features */
.features-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

@media (max-width: 768px) {
    .features-grid {
        grid-template-columns: 1fr;
    }

    .top-controls {
        position: static;
        justify-content: center;
        margin-bottom: 2rem;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .theme-transitioning,
    .theme-transitioning *,
    .theme-transitioning *::before,
    .theme-transitioning *::after {
        transition: none !important;
    }
}