@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --bg-light: #F8FAFC;
    --card-bg: #FFFFFF;
    --text-main: #0F172A;
    --text-muted: #64748B;
    --border: #E2E8F0;
    --border-focus: #4F46E5;
    --danger: #EF4444;
    --danger-bg: #FEF2F2;
    --success: #10B981;
    --success-bg: #ECFDF5;
    --font-main: 'Plus Jakarta Sans', sans-serif;
}

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

body.auth-page {
    font-family: var(--font-main);
    background-color: var(--bg-light);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-font-smoothing: antialiased;
}

/* Wrapper */
.auth-wrapper {
    display: flex;
    width: 100%;
    max-width: 1100px;
    min-height: 700px;
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    margin: 20px;
    animation: authFadeIn 0.5s ease-out forwards;
}

.auth-wrapper.single-column {
    max-width: 550px;
    min-height: auto;
}

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

/* Left Branding Panel */
.auth-branding {
    flex: 1;
    background: linear-gradient(135deg, var(--primary) 0%, #312E81 100%);
    padding: 60px;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.branding-content {
    position: relative;
    z-index: 2;
}

.brand-logo {
    width: 350px;
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto 40px auto;
    filter: brightness(0) invert(1);
}

.auth-branding h2 {
    font-size: 42px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 20px;
    letter-spacing: -1px;
}

.auth-branding p {
    font-size: 16px;
    line-height: 1.6;
    opacity: 0.9;
    max-width: 85%;
}

.brand-shape {
    position: absolute;
    bottom: -150px;
    right: -150px;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 60%);
    border-radius: 50%;
    animation: floatShape 20s infinite ease-in-out alternate;
}

.shape-register {
    bottom: auto;
    top: -150px;
    right: -100px;
}

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

/* Right Form Panel */
.auth-form-container {
    flex: 1.2;
    padding: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-form-inner {
    max-width: 420px;
    width: 100%;
    margin: 0 auto;
}

.auth-form-container.wide .auth-form-inner {
    max-width: 550px;
}

.auth-header {
    margin-bottom: 32px;
}

.auth-header.text-center {
    text-align: center;
}

.auth-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.auth-header p {
    font-size: 15px;
    color: var(--text-muted);
}

.mobile-logo-container {
    display: none;
    text-align: center;
    margin-bottom: 32px;
}

.mobile-logo {
    width: 250px;
    max-width: 100%;
    height: auto;
}

/* OAuth Buttons */
.oauth-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.oauth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: white;
    color: var(--text-main);
    font-weight: 600;
    font-size: 15px;
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
}

.oauth-btn img {
    width: 20px;
    height: 20px;
}

.oauth-btn:hover {
    background: #F8FAFC;
    border-color: #CBD5E1;
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 24px 0;
}

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

.divider span {
    padding: 0 16px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
}

/* Form Styles */
.auth-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
}

.form-group {
    margin-bottom: 20px;
}

.full-width {
    grid-column: span 2;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
}

.form-input, .form-select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-family: var(--font-main);
    font-size: 15px;
    color: var(--text-main);
    background: #FFFFFF;
    transition: all 0.2s ease;
    outline: none;
}

.form-input::placeholder {
    color: #94A3B8;
}

.form-input:focus, .form-select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.password-wrapper, .input-with-icon {
    position: relative;
}

.password-wrapper .form-input {
    padding-right: 44px;
}

.input-with-icon i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #94A3B8;
    pointer-events: none;
}

.input-with-icon .has-icon {
    padding-left: 44px;
}

.password-toggle {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #94A3B8;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
}

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

.select-wrapper {
    position: relative;
}

.form-select {
    appearance: none;
    padding-right: 40px;
    cursor: pointer;
}

.select-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #94A3B8;
    pointer-events: none;
    font-size: 14px;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
}

.remember-me input {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}

.forgot-link {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}

.forgot-link:hover {
    text-decoration: underline;
}

/* Submit Button */
.submit-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-family: var(--font-main);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2), 0 2px 4px -1px rgba(79, 70, 229, 0.1);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.submit-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.25), 0 4px 6px -2px rgba(79, 70, 229, 0.15);
}

.auth-footer {
    text-align: center;
    margin-top: 32px;
    font-size: 14px;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Loading States */
.btn-loader {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    position: absolute;
}

.oauth-btn .btn-loader {
    border-top-color: var(--primary);
    border-color: rgba(79, 70, 229, 0.2);
    border-top-color: var(--primary);
}

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

.loading span, .loading img {
    visibility: hidden;
    opacity: 0;
}

.loading .btn-loader {
    display: block;
}

.loading {
    pointer-events: none;
    opacity: 0.8;
}

/* Dynamic Setup Fields */
.dynamic-group {
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.dynamic-group.visible {
    opacity: 1;
    transform: translateY(0);
}

.field-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.setup-container .auth-form-inner {
    max-width: 480px;
}

/* Messages */
.error-message, .success-message, .warning-message {
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    animation: slideDown 0.3s ease-out;
}

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

.error-message {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid #FECACA;
}

.success-message {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid #A7F3D0;
}

/* Toast override for auth pages */
.toast-container {
    top: 24px;
    right: 24px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .auth-wrapper {
        max-width: 900px;
    }
    .auth-branding {
        padding: 40px;
    }
    .auth-form-container {
        padding: 40px;
    }
}

@media (max-width: 768px) {
    body.auth-page {
        padding: 0;
        background: var(--card-bg);
    }
    .auth-wrapper {
        border-radius: 0;
        box-shadow: none;
        margin: 0;
        min-height: 100vh;
    }
    .auth-branding {
        display: none;
    }
    .mobile-logo-container {
        display: block;
    }
    .auth-form-container {
        padding: 40px 24px;
    }
    .auth-grid {
        grid-template-columns: 1fr;
    }
    .full-width {
        grid-column: span 1;
    }
}

@media (max-width: 390px) {
    .auth-form-container {
        padding: 30px 20px;
    }
    .auth-header h1 {
        font-size: 24px;
    }
    .form-input, .form-select, .submit-btn, .oauth-btn {
        padding: 14px;
    }
}
