@font-face {
    font-family: Kalameh;
    font-weight: 400;
    src: url("../fonts/kalameh/Kalameh-Regular.ttf") format("truetype");
}

@font-face {
    font-family: Kalameh;
    font-weight: 600;
    src: url("../fonts/kalameh/Kalameh-Bold.ttf") format("truetype");
}

@font-face {
    font-family: Kalameh;
    font-weight: 900;
    src: url("../fonts/kalameh/Kalameh-Black.ttf") format("truetype");
}

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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --success: #10b981;
    --danger: #ef4444;
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --bg-white: #ffffff;
    --bg-gray: #f9fafb;
    --border: #e5e7eb;
    --shadow: rgba(0, 0, 0, .1);
    --shadow-lg: rgba(0, 0, 0, .15);
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --badge-email-bg: #dbeafe;
    --badge-email-color: #1e40af;
    --badge-mobile-bg: #d1fae5;
    --badge-mobile-color: #065f46;
    --error-bg: #fee2e2;
    --error-color: #991b1b;
    --success-bg: #d1fae5;
    --toggle-bg: rgba(255, 255, 255, .15);
    --toggle-color: #fff;
}

html[data-theme="dark"] {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --primary-light: #a5b4fc;
    --success: #34d399;
    --danger: #f87171;
    --text-dark: #f3f4f6;
    --text-light: #9ca3af;
    --bg-white: #1e293b;
    --bg-gray: #0f172a;
    --border: #334155;
    --shadow: rgba(0, 0, 0, .3);
    --shadow-lg: rgba(0, 0, 0, .5);
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --badge-email-bg: #1e3a5f;
    --badge-email-color: #93c5fd;
    --badge-mobile-bg: #064e3b;
    --badge-mobile-color: #6ee7b7;
    --error-bg: #450a0a;
    --error-color: #fca5a5;
    --success-bg: #064e3b;
    --toggle-bg: rgba(255, 255, 255, .1);
    --toggle-color: #f3f4f6;
}

html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

body {
    font-family: Kalameh, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    direction: rtl;
    position: relative;
    transition: background .4s ease;
}

body::before {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: rgba(255, 255, 255, .1);
    border-radius: 50%;
    top: -200px;
    right: -200px;
    animation: float 20s infinite ease-in-out;
}

body::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, .08);
    border-radius: 50%;
    bottom: 0px;
    left: -150px;
    animation: float 15s infinite ease-in-out reverse;
}

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

.theme-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 10;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    background: var(--toggle-bg);
    color: var(--toggle-color);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    transition: transform .3s ease, background .3s ease;
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(15deg);
}

.container {
    max-width: 440px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.login-card {
    background: var(--bg-white);
    border-radius: 24px;
    box-shadow: 0 20px 60px var(--shadow-lg);
    overflow: hidden;
    animation: slideUp .5s ease-out;
    transition: background .4s ease;
}

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

.card-header {
    padding: 40px 40px 0;
    text-align: center;
}

.logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: #fff;
    font-weight: 700;
}
.logo img{
    width: 3.5rem;
}
.card-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 8px;
    transition: color .4s ease;
}

.card-subtitle {
    font-size: 15px;
    color: var(--text-light);
    font-weight: 400;
    transition: color .4s ease;
}

.card-body {
    padding: 32px 40px 40px;
}

.form-step {
    display: none;
    animation: fadeIn .3s ease;
}

.form-step.active {
    display: block;
}

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

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

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 8px;
    transition: color .4s ease;
}

.input-wrapper {
    position: relative;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 15px;
    font-family: inherit;
    border: 2px solid var(--border);
    border-radius: 12px;
    outline: none;
    transition: all .3s ease;
    background: var(--bg-white);
    color: var(--text-dark);
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .1);
}

.form-input::placeholder {
    color: var(--text-light);
}

.input-type-badge {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 500;
    opacity: 0;
    transition: opacity .3s ease;
    pointer-events: none;
}

.input-type-badge.show {
    opacity: 1;
}

.input-type-badge.email {
    background: var(--badge-email-bg);
    color: var(--badge-email-color);
}

.input-type-badge.mobile {
    background: var(--badge-mobile-bg);
    color: var(--badge-mobile-color);
}

.password-toggle {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    display: flex;
    align-items: center;
    transition: color .2s;
}

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

.btn {
    width: 100%;
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all .3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, .3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, .4);
}

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

.btn-secondary {
    background: var(--bg-gray);
    color: var(--text-dark);
    margin-top: 12px;
}

.btn-secondary:hover {
    opacity: .85;
}

.btn-link {
    background: transparent;
    color: var(--primary);
    margin-top: 12px;
    font-weight: 500;
}

.btn-link:hover {
    background: rgba(99, 102, 241, .08);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 24px 0;
    color: var(--text-light);
    font-size: 13px;
}

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

.divider span {
    padding: 0 12px;
}

.password-step {
    max-height: 0;
    overflow: hidden;
    transition: max-height .4s ease, margin .4s ease;
}

.password-step.show {
    max-height: 400px;
    margin-top: 20px;
}

.helper-text {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 8px;
    text-align: center;
}

.success-message {
    text-align: center;
    padding: 20px;
}

.success-icon {
    width: 64px;
    height: 64px;
    background: var(--success-bg);
    color: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 32px;
}

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

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

.error-message {
    background: var(--error-bg);
    color: var(--error-color);
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 16px;
    display: none;
}

.error-message.show {
    display: block;
    animation: shake .4s ease;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-8px);
    }
    75% {
        transform: translateX(8px);
    }
}

/* موبایل */
@media (max-width: 480px) {
    body {
        padding: 0;
        align-items: center;
    }

    .container {
        max-width: 100%;
        padding: 0 12px;
    }

    .login-card {
        border-radius: 18px;
        max-height: 90vh;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .card-header {
        padding: 24px 16px 0;
    }

    .card-body {
        padding: 20px 16px 24px;
    }

    .logo {
        width: 60px;
        height: 60px;
        font-size: 26px;
        margin-bottom: 16px;
        border-radius: 15px;
    }
    .logo img{
        width: 2.5rem;
    }
    .card-title {
        font-size: 22px;
        margin-bottom: 6px;
    }

    .card-subtitle {
        font-size: 13px;
    }

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

    .form-label {
        font-size: 13px;
        margin-bottom: 6px;
    }

    .form-input {
        padding: 12px 14px;
        font-size: 16px;
        border-radius: 10px;
    }

    .btn {
        padding: 12px;
        font-size: 14px;
        border-radius: 10px;
    }

    .theme-toggle {
        top: 12px;
        left: 12px;
        width: 40px;
        height: 40px;
        font-size: 18px;
        border-radius: 12px;
    }

    .divider {
        margin: 18px 0;
        font-size: 12px;
    }
}

/* موبایل خیلی کوچک */
@media (max-width: 360px) {
    .container {
        padding: 0 8px;
    }

    .card-header {
        padding: 20px 12px 0;
    }

    .card-body {
        padding: 18px 12px 20px;
    }

    .card-title {
        font-size: 20px;
    }

    .logo {
        width: 54px;
        height: 54px;
        font-size: 24px;
    }
    .logo img{
        width: 2.5rem;
    }
}

/* landscape */
@media (max-height: 600px) and (orientation: landscape) {
    body {
        padding: 8px 0;
        align-items: flex-start;
    }

    .login-card {
        max-height: 95vh;
    }

    .card-header {
        padding: 16px 20px 0;
    }

    .logo {
        width: 48px;
        height: 48px;
        font-size: 22px;
        margin-bottom: 10px;
    }
    .logo img{
        width: 2.5rem;
    }
    .card-title {
        font-size: 20px;
        margin-bottom: 4px;
    }

    .card-body {
        padding: 16px 20px 20px;
    }

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