/* Custom Design System - Telegram-inspired Premium Dark Theme */
:root {
    --bg-gradient: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --telegram-blue: #24a1de;
    --telegram-blue-hover: #1e8cb8;
    --telegram-blue-glow: rgba(36, 161, 222, 0.35);
    --input-bg: rgba(15, 23, 42, 0.6);
    --input-border: rgba(255, 255, 255, 0.1);
    --input-border-focus: #24a1de;
    --error-color: #f43f5e;
    --success-color: #10b981;
}

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

body {
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* Background glowing decoration */
.bg-glow-1, .bg-glow-2 {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    z-index: 1;
    pointer-events: none;
}
.bg-glow-1 {
    width: 400px;
    height: 400px;
    background: rgba(36, 161, 222, 0.15);
    top: 15%;
    left: 20%;
}
.bg-glow-2 {
    width: 350px;
    height: 350px;
    background: rgba(99, 102, 241, 0.12);
    bottom: 15%;
    right: 20%;
}

/* Glassmorphism Card Container */
.login-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 420px;
    padding: 30px;
    margin: 20px;
}

.login-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 40px 32px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
}

/* Logo & Header */
.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.telegram-logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #2aabee 0%, #229ed9 100%);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 20px;
    box-shadow: 0 8px 24px rgba(36, 161, 222, 0.4);
    transition: transform 0.3s ease;
}
.telegram-logo:hover {
    transform: scale(1.05);
}

.telegram-logo svg {
    width: 42px;
    height: 42px;
    fill: #ffffff;
    transform: translate(-2px, 1px);
}

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

.login-header p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Form steps control */
.form-step {
    display: none;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-step.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* Input Fields & Groups */
.input-group {
    position: relative;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
}

.input-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-control {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 15px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.25s, box-shadow 0.25s;
}

.input-control:focus {
    border-color: var(--input-border-focus);
    box-shadow: 0 0 0 3px var(--telegram-blue-glow);
}

/* Custom styling for intl-tel-input on dark theme */
.iti {
    width: 100%;
}
.iti__country-list {
    background-color: #1e293b !important;
    border: 1px solid var(--input-border) !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
    color: var(--text-primary) !important;
    max-width: 320px;
    margin-top: 5px;
    z-index: 1000 !important;
}
.iti__country {
    padding: 10px 14px !important;
    transition: background 0.2s;
}
.iti__country:hover, .iti__country.iti__highlight {
    background-color: rgba(36, 161, 222, 0.15) !important;
}
.iti__selected-flag {
    background-color: transparent !important;
    border-radius: 12px 0 0 12px !important;
    padding-left: 14px !important;
}
.iti__selected-flag:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
}
.iti__arrow {
    border-top-color: var(--text-secondary) !important;
}
.iti__arrow--up {
    border-bottom-color: var(--text-secondary) !important;
}
.iti__dial-code {
    color: var(--text-secondary) !important;
}
.iti--separate-dial-code .iti__selected-dial-code {
    color: var(--text-primary) !important;
    font-weight: 500;
    margin-left: 6px;
}
/* Style adjustments for the main phone number field input */
#phone_number {
    padding-left: 92px !important; /* Spacing for country flag & code */
}

/* Button & Actions */
.btn-submit {
    width: 100%;
    background: linear-gradient(135deg, #24a1de 0%, #1c85b7 100%);
    border: none;
    border-radius: 12px;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(36, 161, 222, 0.25);
    transition: all 0.25s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-submit:hover {
    background: linear-gradient(135deg, #2eb2f3 0%, #2096ce 100%);
    box-shadow: 0 6px 20px rgba(36, 161, 222, 0.4);
    transform: translateY(-1px);
}

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

/* Error/Alert box */
.alert-error {
    display: none;
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fda4af;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    margin-bottom: 20px;
    animation: shake 0.4s ease;
}

/* Loading Overlay */
#submit-loader {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(6px);
    z-index: 100;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    border-radius: 24px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(36, 161, 222, 0.1);
    border-top: 3px solid var(--telegram-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.loader-text {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Success state styles */
.success-checkmark {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(16, 185, 129, 0.15);
    border: 2px solid var(--success-color);
    border-radius: 50%;
    color: var(--success-color);
    animation: scaleUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.success-checkmark svg {
    width: 40px;
    height: 40px;
    fill: none;
    stroke: currentColor;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: drawCheck 0.6s 0.3s ease forwards;
}

/* Keyframes */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

@keyframes scaleUp {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes drawCheck {
    to { stroke-dashoffset: 0; }
}

/* Layout modifications for responsive details */
@media (max-width: 480px) {
    .login-card {
        padding: 30px 20px;
    }
}

/* === STEP 0: Device Language Selector === */
.lang-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 8px;
}

.lang-card {
    background: rgba(36, 161, 222, 0.07);
    border: 1px solid rgba(36, 161, 222, 0.2);
    border-radius: 14px;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 500;
    padding: 14px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    line-height: 1.5;
    letter-spacing: 0.01em;
}

.lang-card:hover {
    background: rgba(36, 161, 222, 0.18);
    border-color: var(--telegram-blue);
    box-shadow: 0 0 12px rgba(36, 161, 222, 0.25);
    transform: translateY(-2px);
}

.lang-card:active {
    transform: translateY(0);
    background: rgba(36, 161, 222, 0.3);
}

.lang-loading {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
    padding: 20px 0;
    grid-column: 1 / -1;
}
