/* ==========================================================================
   Design System & Variable Declarations
   ========================================================================== */
:root {
    /* Color Palette - Dark Theme (Default) */
    --bg-main: #080711;
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-glow: rgba(99, 102, 241, 0.15);
    
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary-grad: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --primary-glow: rgba(99, 102, 241, 0.5);
    
    --input-bg: rgba(255, 255, 255, 0.02);
    --input-border: rgba(255, 255, 255, 0.1);
    --input-focus-border: #6366f1;
    --input-focus-glow: rgba(99, 102, 241, 0.2);
    --input-text: #ffffff;
    --input-placeholder: #475569;
    --input-icon-color: #64748b;
    
    --btn-text: #ffffff;
    --link-color: #818cf8;
    --link-hover: #a855f7;
    
    --toast-bg: rgba(15, 23, 42, 0.9);
    --toast-border: rgba(255, 255, 255, 0.1);
    --toast-text: #f8fafc;
    
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    
    /* Layout & Animation constants */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    --border-radius-lg: 24px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
}

/* Light Theme overrides */
.light-theme {
    --bg-main: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.75);
    --card-border: rgba(0, 0, 0, 0.06);
    --card-glow: rgba(99, 102, 241, 0.05);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --primary-grad: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
    --primary-glow: rgba(79, 70, 229, 0.3);
    
    --input-bg: rgba(255, 255, 255, 0.9);
    --input-border: rgba(0, 0, 0, 0.1);
    --input-focus-border: #4f46e5;
    --input-focus-glow: rgba(79, 70, 229, 0.15);
    --input-text: #0f172a;
    --input-placeholder: #94a3b8;
    --input-icon-color: #64748b;
    
    --btn-text: #ffffff;
    --link-color: #4f46e5;
    --link-hover: #9333ea;
    
    --toast-bg: rgba(255, 255, 255, 0.95);
    --toast-border: rgba(0, 0, 0, 0.05);
    --toast-text: #0f172a;
}

/* ==========================================================================
   Reset & Core Styling
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: background-color var(--transition-slow);
}

/* ==========================================================================
   Background Ambient Animations
   ========================================================================== */
.bg-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.15;
    z-index: 0;
    pointer-events: none;
    transition: opacity var(--transition-slow);
}

.light-theme .bg-glow {
    opacity: 0.08;
}

.bg-glow-1 {
    background: #6366f1;
    top: -10%;
    left: -10%;
    animation: float-slow 20s infinite alternate;
}

.bg-glow-2 {
    background: #a855f7;
    bottom: -15%;
    right: -5%;
    animation: float-slow 25s infinite alternate-reverse;
}

.bg-glow-3 {
    background: #06b6d4;
    top: 40%;
    left: 60%;
    width: 400px;
    height: 400px;
    animation: float-medium 18s infinite alternate;
}

@keyframes float-slow {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(80px, 50px) scale(1.2); }
}

@keyframes float-medium {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-60px, 80px) scale(0.9); }
}

/* Tech-Grid Background Overlay */
.bg-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 1;
}

.light-theme .bg-grid {
    background-image: 
        linear-gradient(rgba(0, 0, 0, 0.012) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.012) 1px, transparent 1px);
}

/* ==========================================================================
   Layout Containers
   ========================================================================== */
.app-container {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 24px;
}

/* Header Area */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 24px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-md);
    background: var(--primary-grad);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 8px 16px var(--primary-glow);
}

.logo-icon i {
    width: 20px;
    height: 20px;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(to right, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Icon Buttons (Theme toggler) */
.icon-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    width: 42px;
    height: 42px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    backdrop-filter: blur(8px);
}

.icon-btn:hover {
    color: var(--text-primary);
    border-color: var(--input-focus-border);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--card-glow);
}

.icon-btn i {
    width: 18px;
    height: 18px;
}

.sun-icon {
    display: none;
}

.light-theme .sun-icon {
    display: block;
}

.light-theme .moon-icon {
    display: none;
}

/* ==========================================================================
   Login Wrapper & Card (Glassmorphism)
   ========================================================================== */
.login-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
}

.login-card {
    position: relative;
    width: 100%;
    max-width: 460px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-lg);
    padding: 48px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.25), 
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
    animation: card-appear 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.light-theme .login-card {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.05),
                inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.login-card:hover {
    box-shadow: 0 35px 70px rgba(0, 0, 0, 0.3),
                0 0 40px var(--card-glow);
}

.light-theme .login-card:hover {
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.08),
                0 0 20px var(--card-glow);
}

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

.card-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: var(--border-radius-lg);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(168, 85, 247, 0.05) 50%, transparent 100%);
    pointer-events: none;
    z-index: -1;
}

.card-header {
    text-align: center;
    margin-bottom: 36px;
}

.card-title {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    background: linear-gradient(to right, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.card-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   Form Fields & Elements
   ========================================================================== */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.input-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.password-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.forgot-link {
    font-size: 0.8rem;
    color: var(--link-color);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.forgot-link:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 16px;
    color: var(--input-icon-color);
    pointer-events: none;
    transition: color var(--transition-fast);
    width: 18px;
    height: 18px;
}

.input-wrapper input {
    width: 100%;
    padding: 14px 16px 14px 48px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--border-radius-md);
    color: var(--input-text);
    font-size: 0.95rem;
    outline: none;
    transition: all var(--transition-fast);
}

/* Password eye button spacing */
.input-wrapper input[type="password"],
.input-wrapper input[type="text"] {
    padding-right: 48px;
}

.input-wrapper input::placeholder {
    color: var(--input-placeholder);
}

.input-wrapper input:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.light-theme .input-wrapper input:hover {
    border-color: rgba(0, 0, 0, 0.2);
}

.input-wrapper input:focus {
    border-color: var(--input-focus-border);
    background: rgba(255, 255, 255, 0.04);
    box-shadow: 0 0 0 4px var(--input-focus-glow);
}

.light-theme .input-wrapper input:focus {
    background: #ffffff;
}

.input-wrapper input:focus + .input-icon {
    color: var(--input-focus-border);
}

/* Password Toggle Visibility Button */
.password-toggle-btn {
    position: absolute;
    right: 16px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: color var(--transition-fast);
}

.password-toggle-btn:hover {
    color: var(--text-primary);
}

.password-toggle-btn i {
    width: 18px;
    height: 18px;
}

.hidden {
    display: none !important;
}

/* Error validation styling */
.error-msg {
    font-size: 0.8rem;
    color: var(--error);
    min-height: 16px;
    transition: opacity var(--transition-fast);
    opacity: 0;
}

.error-msg.visible {
    opacity: 1;
}

.input-group.invalid input {
    border-color: var(--error) !important;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15) !important;
}

/* Checkbox Style */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: -6px;
}

.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    cursor: pointer;
    user-select: none;
    gap: 10px;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: relative;
    height: 18px;
    width: 18px;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.checkbox-container:hover input ~ .checkmark {
    border-color: rgba(255, 255, 255, 0.25);
}

.light-theme .checkbox-container:hover input ~ .checkmark {
    border-color: rgba(0, 0, 0, 0.25);
}

.checkbox-container input:checked ~ .checkmark {
    background: var(--primary-grad);
    border-color: transparent;
    box-shadow: 0 2px 6px var(--primary-glow);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 6px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ==========================================================================
   Submit Button & Loading Animations
   ========================================================================== */
.submit-btn {
    position: relative;
    width: 100%;
    padding: 15px;
    background: var(--primary-grad);
    border: none;
    border-radius: var(--border-radius-md);
    color: var(--btn-text);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
    transition: all var(--transition-normal);
    box-shadow: 0 10px 20px var(--primary-glow);
    display: flex;
    justify-content: center;
    align-items: center;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px var(--primary-glow);
    filter: brightness(1.1);
}

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

/* Button Loading State */
.btn-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--primary-grad);
    left: 0;
    top: 0;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s ease infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Auditor compliance alert box */
.auditor-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 28px;
    padding: 12px 16px;
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-radius: var(--border-radius-md);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.auditor-notice i {
    width: 16px;
    height: 16px;
    color: var(--link-color);
    flex-shrink: 0;
}

/* ==========================================================================
   Regulatory Compliant Footer
   ========================================================================== */
.main-footer {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    border-top: 1px solid var(--card-border);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.copyright {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.beian-links {
    display: flex;
    align-items: center;
    gap: 16px;
}

.icp-link {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-fast);
    padding: 6px 12px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
}

.icp-link:hover {
    color: var(--text-primary);
    border-color: var(--input-focus-border);
    box-shadow: 0 4px 12px var(--card-glow);
}

.icp-link i {
    width: 14px;
    height: 14px;
}

/* ==========================================================================
   Toast Notification System
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 9999;
}

.toast {
    min-width: 300px;
    max-width: 400px;
    background: var(--toast-bg);
    border: 1px solid var(--toast-border);
    border-radius: var(--border-radius-md);
    padding: 16px;
    color: var(--toast-text);
    backdrop-filter: blur(12px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: toast-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    transition: all 0.3s ease;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.toast.removing {
    opacity: 0;
    transform: scale(0.9) translateY(-10px);
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--error); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--link-color); }

.toast-body {
    flex-grow: 1;
}

.toast-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.toast-message {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}

.toast-close:hover {
    color: var(--text-primary);
}

.toast-close i {
    width: 16px;
    height: 16px;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 600px) {
    body {
        padding: 0;
    }
    .app-container {
        padding: 16px;
    }
    .login-card {
        padding: 32px 24px;
        margin: 0 8px;
    }
    .footer-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}
