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

html {
    /* Убираем все отступы для полного покрытия экрана */
    margin: 0;
    padding: 0;
    height: 100%;
    overflow-x: hidden;
}

:root {
    --primary: #5d87ff;
    --primary-dark: #2563eb;
    --primary-light: #93c5fd;
    --accent: #f97316;
    --accent-dark: #ea580c;
    
    --white: #ffffff;
    --black: #000000;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    --success: #059669;
    --error: #dc2626;
    --warning: #d97706;
    
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Safe area variables for PWA full-screen support */
    --safe-area-inset-top: env(safe-area-inset-top, 0);
    --safe-area-inset-right: env(safe-area-inset-right, 0);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0);
    --safe-area-inset-left: env(safe-area-inset-left, 0);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);
    /* Стандартная высота экрана для контента */
    height: 100vh;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed; /* Используем fixed для полной фиксации */
    width: 100%;
    /* Полностью убираем скролл */
    overflow: hidden;
    /* Предотвращаем bounce-эффект на iOS */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Полное покрытие экрана включая системные области */
    margin: 0;
    padding: 0;
    /* Extend body into safe areas */
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
}

body::before {
    content: '';
    position: fixed;
    /* Умеренное расширение фона для покрытия при автозаполнении */
    top: calc(-10vh - env(safe-area-inset-top, 0));
    left: calc(-1 * env(safe-area-inset-left, 0));
    right: calc(-1 * env(safe-area-inset-right, 0));
    bottom: calc(-10vh - env(safe-area-inset-bottom, 0));
    background-image: 
        url('../images/main-bg.png'),
        radial-gradient(circle at 25% 25%, rgba(93, 135, 255, 0.04) 0%, transparent 25%),
        radial-gradient(circle at 75% 75%, rgba(93, 135, 255, 0.03) 0%, transparent 25%);
    background-position: center center, 25% 25%, 75% 75%;
    background-repeat: no-repeat, no-repeat, no-repeat;
    background-size: cover, 100% 100%, 100% 100%;
    opacity: 0.3;
    pointer-events: none;
    /* Полное покрытие включая системные области + защита от автозаполнения */
    z-index: -1;
}

.login-container {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 24px;
    /* Ensure content respects safe areas */
    padding-top: max(24px, env(safe-area-inset-top, 0));
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0));
    padding-left: max(24px, env(safe-area-inset-left, 0));
    padding-right: max(24px, env(safe-area-inset-right, 0));
    position: relative;
    z-index: 1;
    animation: containerSlideIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes containerSlideIn {
    0% {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-card {
    background: #ffffff !important; /* Fixed background - not affected by theme */
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: cardFloat 6s ease-in-out infinite;
}

@keyframes cardFloat {
    0%, 100% {
        transform: translateY(0) rotateX(0deg);
        box-shadow: var(--shadow-xl);
    }
    50% {
        transform: translateY(-5px) rotateX(1deg);
        box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    }
}

.login-header {
    background: #ffffff !important; /* Fixed background */
    padding: 32px 32px 24px 32px;
    position: relative;
}

.brand {
    text-align: center;
    animation: brandFadeIn 1s ease-out 0.3s both;
}

@keyframes brandFadeIn {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.brand-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 4px;
    margin-top: 0;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    transition: all 0.3s ease;
    animation: titleGlow 4s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% {
        text-shadow: 0 0 5px rgba(93, 135, 255, 0.1);
        transform: scale(1);
    }
    50% {
        text-shadow: 0 0 15px rgba(93, 135, 255, 0.3);
        transform: scale(1.02);
    }
}

.brand-subtitle {
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    animation: subtitleSlide 1s ease-out 0.5s both;
}

@keyframes subtitleSlide {
    0% {
        opacity: 0;
        transform: translateX(-30px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.login-body {
    padding: 32px;
    animation: bodyFadeIn 1s ease-out 0.7s both;
}

@keyframes bodyFadeIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-group {
    margin-bottom: 20px;
    position: relative;
    opacity: 0;
    animation: formSlideIn 0.6s ease-out forwards;
}

.form-group:nth-child(3) {
    animation-delay: 0.9s;
}

.form-group:nth-child(4) {
    animation-delay: 1.1s;
}

.form-group:nth-child(5) {
    animation-delay: 1.3s;
}

@keyframes formSlideIn {
    0% {
        opacity: 0;
        transform: translateX(-30px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    transition: all 0.3s ease;
}

.form-control {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 16px; /* 16px+ предотвращает зум на iOS */
    font-weight: 500;
    color: var(--gray-900);
    background: #ffffff !important; /* Fixed background */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-appearance: none;
    appearance: none;
    transform: translateY(0);
}

.form-control::placeholder {
    color: var(--gray-400);
    font-weight: 400;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(93, 135, 255, 0.1);
    transform: translateY(-2px);
}

.form-control:focus::placeholder {
    transform: translateY(-2px);
    opacity: 0.7;
}

.form-control:hover:not(:focus) {
    border-color: var(--gray-400);
    transform: translateY(-1px);
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 16px;
    pointer-events: none;
    transition: all 0.3s ease;
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% {
        opacity: 0.7;
        transform: translateY(-50%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translateY(-50%) scale(1.1);
    }
}

.input-wrapper:focus-within .input-icon {
    color: var(--primary);
    transform: translateY(-50%) scale(1.1);
}

.form-control.has-icon {
    padding-left: 40px;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: var(--radius-sm);
}

.password-toggle:hover {
    color: var(--gray-600);
    background: var(--gray-100);
    transform: translateY(-50%) scale(1.1);
}

.password-toggle:active {
    transform: translateY(-50%) scale(0.95);
}

.btn-primary {
    width: 100%;
    height: 44px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 700;
    color: var(--white);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 8px;
    position: relative;
    overflow: hidden;
    opacity: 0;
    animation: buttonSlideUp 0.6s ease-out 1.5s forwards;
}

@keyframes buttonSlideUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s ease;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(93, 135, 255, 0.3);
}

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

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--white);
    animation: spin 1s linear infinite;
}

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

.error-message {
    background: #ffffff !important; /* Fixed background */
    border: 2px solid var(--error);
    color: var(--error);
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 20px;
    display: none;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    transform: translateY(-10px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.error-message.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
    animation: shake 0.5s ease-in-out;
}

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

.success-message {
    background: #ffffff !important; /* Fixed background */
    border: 2px solid var(--success);
    color: var(--success);
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 20px;
    display: none;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    transform: translateY(-10px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.success-message.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
    animation: successPulse 0.6s ease-out;
}

@keyframes successPulse {
    0% {
        transform: scale(0.95);
        opacity: 0;
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.form-control.is-valid {
    border-color: var(--success);
}

.form-control.is-invalid {
    border-color: var(--error);
}

/* PWA Installation Guide Styles */
.pwa-install-guide {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
    animation: pwaSlideIn 0.6s ease-out 2s both;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.pwa-install-guide.collapsed .pwa-content {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
}

@keyframes pwaSlideIn {
    0% {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.pwa-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pwa-header:hover {
    background: rgba(255, 255, 255, 0.15);
}

.pwa-header i:first-child {
    margin-right: 6px;
    margin-left: 6px;
    font-size: 14px;
}

.pwa-toggle {
    background: none;
    border: none;
    color: var(--white);
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.8;
    transform: rotate(0deg);
}

.pwa-toggle.collapsed {
    transform: rotate(180deg);
}

.pwa-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
    transform: scale(1.1);
}

.pwa-toggle.collapsed:hover {
    transform: rotate(180deg) scale(1.1);
}

.pwa-content {
    padding: 16px;
    color: var(--white);
    max-height: 200px;
    opacity: 1;
    transition: all 0.8s ease;
    overflow: hidden;
}

.pwa-subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin-bottom: 12px;
    text-align: center;
    font-weight: 500;
}

.pwa-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pwa-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.step-number {
    width: 18px;
    height: 18px;
    background: var(--white);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}

.step-content {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
}

.step-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
}

.step-icon i {
    font-size: 12px;
}

/* Mobile Styles */
@media (max-width: 480px) {
    .login-container {
        padding: 16px;
        /* Ensure content respects safe areas on mobile */
        padding-top: max(16px, env(safe-area-inset-top, 0));
        padding-bottom: max(16px, env(safe-area-inset-bottom, 0));
        padding-left: max(16px, env(safe-area-inset-left, 0));
        padding-right: max(16px, env(safe-area-inset-right, 0));
    }
    
    .login-header {
        padding: 24px 24px 20px 24px;
    }
    
    .login-body {
        padding: 24px;
    }
    
    .brand-title {
        font-size: 24px;
    }
    
    .login-card {
        border-radius: var(--radius);
    }
}

/* Landscape Mobile */
@media (max-height: 600px) and (orientation: landscape) {
    .login-container {
        padding: 12px;
        /* Ensure content respects safe areas in landscape */
        padding-top: max(12px, env(safe-area-inset-top, 0));
        padding-bottom: max(12px, env(safe-area-inset-bottom, 0));
        padding-left: max(12px, env(safe-area-inset-left, 0));
        padding-right: max(12px, env(safe-area-inset-right, 0));
    }
    
    .login-header {
        padding: 20px 24px 16px 24px;
    }
    
    .login-body {
        padding: 20px 24px;
    }
    
    .form-group {
        margin-bottom: 16px;
    }
}

/* PWA guide responsive adjustments */
@media (min-width: 768px) {
    .pwa-install-guide {
        font-size: 14px;
    }
    
    .pwa-content {
        padding: 20px;
    }
    
    .step-content {
        font-size: 13px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .login-card {
        border-width: 0.5px;
    }
}

/* Reduce Motion */
@media (prefers-reduced-motion: reduce) {
    *, ::before, ::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
} 