/* ===== DotPlus ERP - Auth Pages ===== */
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    --primary-50: #eef2ff;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body, input, button, select, textarea {
    font-family: 'Jost', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* =============================================
   SHARED - Floating Label Input (md-field-lg)
   ============================================= */
.md-field-lg {
    position: relative;
    margin-bottom: 1.75rem;
}

.md-field-lg .input-wrap {
    position: relative;
}

.md-field-lg input {
    width: 100%;
    height: 56px;
    padding: 0 1.125rem;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-dark);
    background: var(--primary-50);
    border: 2px solid transparent;
    border-radius: 14px;
    outline: none;
    letter-spacing: 0.02em;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.md-field-lg input:focus,
.md-field-lg input:not(:placeholder-shown) {
    padding-left: 3rem;
}

.md-field-lg input:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.md-field-lg input::placeholder { color: transparent; }

/* Label */
.md-field-lg label {
    position: absolute;
    left: 1.125rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.925rem;
    color: var(--text-muted);
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    padding: 0;
    z-index: 1;
}

.md-field-lg input:focus + label,
.md-field-lg input:not(:placeholder-shown) + label {
    top: 0;
    left: 0.875rem;
    transform: translateY(-50%);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary);
    background: #fff;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
}

/* Icon (after label in DOM) */
.md-field-lg .md-field-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    z-index: 2;
}

.md-field-lg .md-field-icon svg { width: 20px; height: 20px; }

.md-field-lg input:focus ~ .md-field-icon,
.md-field-lg input:not(:placeholder-shown) ~ .md-field-icon {
    opacity: 1;
}

.md-field-lg input:focus ~ .md-field-icon {
    color: var(--primary);
}

/* Password toggle */
.md-field-lg .password-toggle {
    position: absolute;
    right: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    z-index: 3;
}

.md-field-lg .password-toggle:hover { color: var(--primary); }

/* Error state */
.md-field-lg.has-error input {
    background: var(--danger-bg);
    border-color: var(--danger);
}

.md-field-lg.has-error input:focus {
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.08);
}

.md-field-lg.has-error input:focus + label,
.md-field-lg.has-error input:not(:placeholder-shown) + label {
    color: var(--danger);
}

.md-field-lg.has-error .md-field-icon { color: var(--danger); }

.md-field-lg .field-error {
    display: block;
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 0.5rem;
    padding-left: 0.25rem;
    animation: errorSlide 0.3s ease;
}

/* =============================================
   SHARED - Button
   ============================================= */
.auth-btn {
    width: 100%;
    height: 52px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.auth-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
    opacity: 0;
    transition: opacity 0.25s;
}

.auth-btn:hover::before { opacity: 1; }
.auth-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(79, 70, 229, 0.35); }
.auth-btn:active { transform: translateY(0); }
.auth-btn:disabled { opacity: 0.7; cursor: not-allowed; transform: none; box-shadow: none; }
.auth-btn .btn-arrow { transition: transform 0.2s; }
.auth-btn:hover .btn-arrow { transform: translateX(3px); }
.auth-btn.loading .btn-arrow { display: none; }

.auth-btn .spinner {
    display: none;
    width: 20px; height: 20px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.auth-btn.loading .spinner { display: inline-block; }
.auth-btn.loading .btn-text { opacity: 0.8; }

/* =============================================
   SHARED - Alert
   ============================================= */
.auth-alert {
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: 12px;
    padding: 0.875rem 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    animation: errorSlide 0.3s ease;
}

.auth-alert svg { flex-shrink: 0; width: 18px; height: 18px; color: var(--danger); margin-top: 1px; }
.auth-alert p { margin: 0; font-size: 0.85rem; color: #b91c1c; line-height: 1.5; }

.success-alert {
    background: #f0fdf4;
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-radius: 12px;
    padding: 1rem 1.125rem;
    margin-bottom: 1.5rem;
    display: flex; align-items: flex-start; gap: 0.625rem;
    animation: fadeSlideUp 0.3s ease;
}

.success-alert svg { flex-shrink: 0; width: 20px; height: 20px; color: #10b981; margin-top: 1px; }
.success-alert p { margin: 0; font-size: 0.875rem; color: #065f46; line-height: 1.5; }

/* =============================================
   SHARED - Step Indicator
   ============================================= */
.org-step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2.5rem;
}

.org-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.org-step-dot {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-muted);
    font-size: 0.75rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s;
}

.org-step.active .org-step-dot {
    background: var(--primary); color: #fff;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.org-step.completed .org-step-dot {
    background: #10b981; color: #fff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.org-step span { font-size: 0.8rem; font-weight: 600; color: var(--text-light); }
.org-step.active span { color: var(--text-dark); }
.org-step.completed span { color: #10b981; }

.org-step-line {
    width: 60px; height: 2px;
    background: var(--border);
    margin: 0 0.75rem;
}

.org-step-line.filled {
    background: linear-gradient(90deg, #10b981, var(--primary));
}

/* =============================================
   SHARED - Floating Shapes
   ============================================= */
.shape {
    position: absolute;
    border-radius: 50%;
}

.shape-1 {
    width: 400px; height: 400px;
    background: #818cf8; opacity: 0.07;
    top: -120px; right: -100px;
    animation: float1 18s ease-in-out infinite;
}

.shape-2 {
    width: 250px; height: 250px;
    background: #a5b4fc; opacity: 0.05;
    bottom: -60px; left: -40px;
    animation: float2 22s ease-in-out infinite;
}

.shape-3 {
    width: 160px; height: 160px;
    background: #c7d2fe; opacity: 0.04;
    top: 50%; left: 50%;
    animation: float3 15s ease-in-out infinite;
}

/* =============================================
   ORGANIZATION PAGE
   ============================================= */
.org-page {
    display: flex;
    min-height: 100vh;
}

.org-brand-panel {
    position: relative;
    width: 50%;
    min-height: 100vh;
    background: linear-gradient(145deg, #1e1b4b, #312e81, #4338ca);
    display: flex; align-items: center; justify-content: center;
    padding: 3rem;
    overflow: hidden;
}

.org-brand-content {
    position: relative; z-index: 2; max-width: 420px;
}

.org-brand-logo {
    width: 56px; height: 56px;
    border-radius: 14px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 1.75rem;
}

.org-brand-logo svg { width: 28px; height: 28px; color: #e0e7ff; }

.org-brand-content h2 {
    font-size: 2rem; font-weight: 800; color: #fff;
    letter-spacing: -0.03em; margin-bottom: 0.75rem;
}

.org-brand-tagline {
    font-size: 1rem; color: rgba(199,210,254,0.8);
    line-height: 1.7; margin-bottom: 2.5rem;
}

.org-features { display: flex; flex-direction: column; gap: 1.25rem; }

.org-feature {
    display: flex; align-items: flex-start; gap: 0.875rem;
    padding: 1rem 1.125rem;
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    transition: all 0.3s ease;
}

.org-feature:hover { background: rgba(255,255,255,0.12); transform: translateX(4px); }

.org-feature-icon {
    width: 38px; height: 38px; border-radius: 10px;
    background: rgba(255,255,255,0.12);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.org-feature-icon svg { width: 20px; height: 20px; color: #c7d2fe; }
.org-feature strong { display: block; font-size: 0.875rem; font-weight: 600; color: #fff; margin-bottom: 0.125rem; }
.org-feature span { font-size: 0.8rem; color: rgba(199,210,254,0.65); line-height: 1.4; }

.org-brand-shapes {
    position: absolute; inset: 0; overflow: hidden; z-index: 1;
}

/* Right form panel */
.org-form-panel {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 2rem;
    background: #fff;
    position: relative;
}

.org-form-wrapper {
    width: 100%; max-width: 400px;
    animation: fadeSlideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.org-form-header { margin-bottom: 2rem; }
.org-form-header h1 { font-size: 1.625rem; font-weight: 700; color: var(--text-dark); letter-spacing: -0.025em; margin-bottom: 0.5rem; }
.org-form-header p { font-size: 0.9rem; color: var(--text-muted); line-height: 1.6; }

.org-help {
    display: flex; align-items: center; justify-content: center;
    gap: 0.375rem; margin-top: 1.5rem;
    padding: 0.875rem; background: #f8fafc; border-radius: 10px;
}

.org-help svg { color: var(--text-light); flex-shrink: 0; }
.org-help span { font-size: 0.775rem; color: var(--text-muted); line-height: 1.5; }

.org-form-footer {
    position: absolute; bottom: 1.5rem; left: 0; right: 0; text-align: center;
}

.org-form-footer span { font-size: 0.75rem; color: var(--text-light); }

/* =============================================
   LOGIN PAGE
   ============================================= */
.login-page {
    display: flex;
    min-height: 100vh;
}

.login-brand-panel {
    position: relative;
    width: 50%;
    min-height: 100vh;
    background: linear-gradient(160deg, #0c0a1d, #1a1547, #2e1a6b);
    display: flex; flex-direction: column;
    align-items: flex-start; justify-content: flex-end;
    padding: 3rem;
    overflow: hidden;
}

/* Brand illustration */
.brand-illustration {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 2rem 10rem;
}

.brand-svg { width: 100%; max-width: 440px; height: auto; }

/* SVG element animations */
.anim-monitor { animation: fadeSlideUp 0.8s 0.2s cubic-bezier(0.16,1,0.3,1) both; }
.anim-bar-1 { animation: barGrow 0.5s 0.5s ease both; transform-origin: center bottom; }
.anim-bar-2 { animation: barGrow 0.5s 0.65s ease both; transform-origin: center bottom; }
.anim-bar-3 { animation: barGrow 0.5s 0.8s ease both; transform-origin: center bottom; }
.anim-bar-4 { animation: barGrow 0.5s 0.95s ease both; transform-origin: center bottom; }
.anim-bar-5 { animation: barGrow 0.5s 1.1s ease both; transform-origin: center bottom; }
@keyframes barGrow { from { transform: scaleY(0); opacity: 0; } to { transform: scaleY(1); opacity: 1; } }

.anim-pie { animation: pieReveal 1.5s 0.8s ease both; }
@keyframes pieReveal { from { stroke-dasharray: 0 160; } to { stroke-dasharray: 60 100; } }

.anim-card-1 { animation: cardPulse 3s 1s ease-in-out infinite; }
@keyframes cardPulse { 0%,100% { opacity: 0.7; } 50% { opacity: 1; } }

.anim-float-card-1 { animation: floatCard1 4s 0.4s ease-in-out infinite both; }
.anim-float-card-2 { animation: floatCard2 5s 0.8s ease-in-out infinite both; }
@keyframes floatCard1 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(5px,-12px); } }
@keyframes floatCard2 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-5px,-10px); } }

.anim-person { animation: fadeSlideUp 0.9s 0.3s cubic-bezier(0.16,1,0.3,1) both; }

.anim-dot-1 { animation: dotFloat 3s ease-in-out infinite; }
.anim-dot-2 { animation: dotFloat 4s 0.5s ease-in-out infinite; }
.anim-dot-3 { animation: dotFloat 3.5s 1s ease-in-out infinite; }
.anim-dot-4 { animation: dotFloat 5s 0.3s ease-in-out infinite; }
.anim-dot-5 { animation: dotFloat 4.5s 0.8s ease-in-out infinite; }
.anim-dot-6 { animation: dotFloat 3s 1.5s ease-in-out infinite; }
@keyframes dotFloat { 0%,100% { transform: translateY(0); opacity: 0.3; } 50% { transform: translateY(-8px); opacity: 0.7; } }

.anim-line { animation: lineSlide 2s ease-in-out infinite; }
@keyframes lineSlide { 0%,100% { opacity: 0.15; } 50% { opacity: 0.4; } }

/* Brand content (bottom of left panel) */
.login-brand-content {
    position: relative; z-index: 2; max-width: 420px;
    margin-top: auto;
    margin-bottom: 5rem;
    padding-left: 1rem;
    animation: slideFromLeft 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.brand-badge {
    display: inline-block;
    font-size: 0.625rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.12em;
    color: rgba(196,181,253,0.9);
    background: rgba(139,92,246,0.2);
    border: 1px solid rgba(139,92,246,0.15);
    padding: 0.35rem 0.875rem;
    border-radius: 100px;
    margin-bottom: 0.875rem;
}

.login-brand-content h2 {
    font-size: 1.75rem; font-weight: 800; color: #fff;
    letter-spacing: -0.03em; margin-bottom: 0.5rem;
}

.login-brand-content h2 span {
    color: #a78bfa; font-weight: 400;
}

.login-brand-tagline {
    font-size: 0.875rem; color: rgba(199,210,254,0.65);
    line-height: 1.6; margin-bottom: 1.5rem;
}

/* Feature checkmarks */
.brand-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.625rem;
}

.brand-feature-item {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.8rem; color: rgba(199,210,254,0.75);
}

.brand-feature-item svg { color: #10b981; flex-shrink: 0; }

.login-brand-shapes {
    position: absolute; inset: 0; overflow: hidden; z-index: 0;
}

/* Right form panel */
.login-form-panel {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 2rem;
    background: #fff;
    position: relative;
}

.login-form-wrapper {
    width: 100%; max-width: 420px;
    animation: fadeSlideUp 0.6s 0.15s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Top logo on form side */
.login-logo-header {
    text-align: center;
    margin-bottom: 1.75rem;
    animation: scaleFade 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-top-logo {
    max-width: 180px;
    max-height: 80px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.login-org-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
}

/* Org card */
.login-org-card {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--primary-50);
    border: 1px solid rgba(79, 70, 229, 0.1);
    border-radius: 12px;
    margin-bottom: 2rem;
    animation: scaleFade 0.5s 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.login-org-card-icon {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--primary-light);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; color: var(--primary);
}

.login-org-card-info { flex: 1; min-width: 0; }

.login-org-card-name {
    display: block; font-size: 0.875rem; font-weight: 600;
    color: var(--text-dark); line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.login-org-card-code {
    display: block; font-size: 0.725rem; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em;
}

.login-org-card-change {
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); transition: all 0.2s; flex-shrink: 0;
    text-decoration: none;
}

.login-org-card-change:hover { background: var(--primary-light); color: var(--primary); }

.login-form-header {
    margin-bottom: 2rem;
    animation: fadeIn 0.5s 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.login-form-header h1 { font-size: 1.625rem; font-weight: 700; color: var(--text-dark); letter-spacing: -0.025em; margin-bottom: 0.375rem; }
.login-form-header p { font-size: 0.9rem; color: var(--text-muted); line-height: 1.5; }

/* Forgot password */
.login-actions-row {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1.25rem;
    margin-top: -0.5rem;
}

.forgot-link {
    font-size: 0.825rem;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

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

/* Bottom links */
.login-bottom-links {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.switch-org-link {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.switch-org-link:hover {
    color: var(--primary);
}

.login-form-footer {
    position: absolute; bottom: 1.5rem; left: 0; right: 0; text-align: center;
}

.login-form-footer span { font-size: 0.75rem; color: var(--text-light); }

/* =============================================
   ANIMATIONS
   ============================================= */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideFromLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleFade {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

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

@keyframes logoPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
    50% { box-shadow: 0 0 0 10px rgba(139, 92, 246, 0.08); }
}

@keyframes float1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-30px, 40px) scale(1.05); }
}

@keyframes float2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(20px, -30px) scale(1.08); }
}

@keyframes float3 {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -55%) scale(1.1); }
}

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

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

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 900px) {
    .org-page,
    .login-page {
        flex-direction: column;
    }

    .org-brand-panel,
    .login-brand-panel {
        width: 100%; min-height: auto;
        padding: 2.5rem 2rem 2rem;
    }

    .org-brand-content h2,
    .login-brand-content h2 { font-size: 1.5rem; }

    .org-brand-tagline,
    .login-brand-tagline { margin-bottom: 1.5rem; font-size: 0.9rem; }

    .org-features { display: none; }

    .org-form-panel,
    .login-form-panel { padding: 2rem 1.5rem 4rem; }

    .org-form-footer,
    .login-form-footer { position: relative; bottom: auto; margin-top: 2rem; }
}

@media (max-width: 480px) {
    .org-brand-panel,
    .login-brand-panel { padding: 2rem 1.25rem 1.5rem; }

    .org-brand-content h2,
    .login-brand-content h2 { font-size: 1.3rem; }

    .org-form-panel,
    .login-form-panel { padding: 1.5rem 1.25rem 3rem; }

    .org-form-header h1,
    .login-form-header h1 { font-size: 1.375rem; }

    .org-step-indicator { margin-bottom: 2rem; }

    .login-stats { display: none; }
}
