:root {
    --primary-color: #1976d2;
    --primary-dark: #1565c0;
    --primary-light: #42a5f5;
    --surface: #ffffff;
    --background: #f8f9fa;
    --on-surface: #1f1f1f;
    --on-surface-variant: #5f5f5f;
    --outline: #e0e0e0;
    --error: #d32f2f;
    --success: #2e7d32;
    --shadow-1: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    --shadow-2: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
    --border-radius: 16px;
    --border-radius-small: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Vazirmatn', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--background);
    color: var(--on-surface);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0 20px;
    max-width: 400px;
    margin: 0 auto;
}

/* صفحات */
.page {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    padding: 40px 0;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.page.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

/* هدر */
.header {
    text-align: center;
    margin-bottom: 60px;
    position: relative;
}

.app-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 16px;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--on-surface);
}

.page-subtitle {
    font-size: 14px;
    color: var(--on-surface-variant);
    margin-bottom: 8px;
}

.phone-display {
    font-size: 14px;
    color: var(--primary-color);
    font-weight: 500;
}

.back-btn {
    position: absolute;
    right: 0;
    top: 0;
    background: none;
    border: none;
    color: var(--on-surface);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.back-btn:hover {
    background: var(--outline);
}

/* فرم‌ها */
.form-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.form {
    width: 100%;
}

.input-container {
    margin-bottom: 24px;
}

.input-wrapper {
    position: relative;
    margin-bottom: 16px;
}

.modern-input,
.modern-select {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--outline);
    border-radius: var(--border-radius-small);
    font-size: 16px;
    background: var(--surface);
    transition: all 0.3s ease;
    outline: none;
}

.modern-input:focus,
.modern-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.input-label {
    position: absolute;
    top: -8px;
    right: 12px;
    background: var(--surface);
    padding: 0 8px;
    font-size: 12px;
    color: var(--on-surface-variant);
    transition: all 0.3s ease;
}

/* OTP */
.otp-container {
    margin-bottom: 32px;
}

.otp-inputs {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 24px;
    direction: ltr;
}

.otp-digit {
    width: 64px;
    height: 64px;
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    border: 2px solid var(--outline);
    border-radius: var(--border-radius-small);
    background: var(--surface);
    transition: all 0.3s ease;
    outline: none;
    direction: ltr;
    text-align: center;
}

.otp-digit:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.otp-digit.filled {
    border-color: var(--primary-color);
    background: rgba(25, 118, 210, 0.05);
}

/* تایمر */
.timer-container {
    text-align: center;
    margin-bottom: 32px;
}

.timer {
    font-size: 14px;
    color: var(--on-surface-variant);
}

.link-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
}

.link-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* دکمه‌ها */
.modern-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--border-radius-small);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.modern-btn.primary {
    background: var(--primary-color);
    color: white;
}

.modern-btn.primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-1);
}

.modern-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-loader {
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* لینک‌های فوتر */
.footer-links {
    text-align: center;
    margin-top: auto;
    padding-top: 32px;
}

.footer-link {
    color: var(--on-surface-variant);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.footer-link:hover {
    color: var(--primary-color);
}

/* پیام‌ها */
.message-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--on-surface);
    color: white;
    padding: 12px 20px;
    border-radius: var(--border-radius-small);
    font-size: 14px;
    z-index: 1000;
    box-shadow: var(--shadow-2);
    max-width: 90%;
    text-align: center;
}

.message-toast.success {
    background: var(--success);
}

.message-toast.error {
    background: var(--error);
}

.hidden {
    display: none !important;
}

/* انیمیشن‌ها */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page.active {
    animation: slideIn 0.4s ease-out;
}

/* رسپانسیو برای موبایل */
@media (max-height: 700px) {
    .page {
        padding: 20px 0;
    }
    
    .header {
        margin-bottom: 40px;
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 0 16px;
    }
    
    .otp-digit {
        width: 56px;
        height: 56px;
        font-size: 20px;
    }
}

/* جلوگیری از باز شدن کیبورد روی محتوا */
@media (max-height: 600px) {
    .form-container {
        justify-content: flex-start;
        padding-top: 20px;
    }
}