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

:root {
    --primary-color: #4A90E2;
    --primary-hover: #1E88E5;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --border-color: #e2e8f0;
    --bg-gradient-start: #ffffff;
    --bg-gradient-end: #f5f7fa;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
}

/* Background Animation */
.auth-container {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
    display: none; /* Hide background animation */
}

.shape {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    animation: float 20s infinite ease-in-out;
    display: none; /* Hide shapes */
}

.shape-1 {
    width: 300px;
    height: 300px;
    top: -100px;
    left: -100px;
    animation-delay: 0s;
}

.shape-2 {
    width: 400px;
    height: 400px;
    bottom: -150px;
    right: -150px;
    animation-delay: 5s;
}

.shape-3 {
    width: 200px;
    height: 200px;
    top: 50%;
    right: 10%;
    animation-delay: 10s;
}

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

/* Auth Box */
.auth-box {
    position: relative;
    z-index: 1;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 480px;
    width: 100%;
    overflow: hidden;
    animation: slideUp 0.5s ease;
}

.auth-box.hidden {
    display: none;
}

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

/* Auth Header */
.auth-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    padding: 2rem;
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.logo:hover {
    opacity: 0.8;
}

.logo-img-auth {
    height: 48px;
    width: auto;
    filter: brightness(0) invert(1); /* Белый логотип как в dashboard */
    transition: opacity 0.3s ease;
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
}

.subtitle {
    font-size: 0.95rem;
    opacity: 0.9;
}

/* Auth Form */
.auth-form {
    padding: 2rem;
}

.auth-form h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    color: #4A90E2;
}

.form-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-group label i {
    color: var(--primary-color);
}

.form-control {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
    color: var(--text-primary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(66, 165, 245, 0.1);
}

.form-control::placeholder {
    color: #cbd5e0;
}

/* Password Input */
.password-input {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.3s ease;
}

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

/* Password Strength */
.password-strength {
    margin-top: 0.5rem;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.password-strength::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.password-strength.weak::before {
    width: 33%;
    background: var(--danger-color);
}

.password-strength.medium::before {
    width: 66%;
    background: var(--warning-color);
}

.password-strength.strong::before {
    width: 100%;
    background: var(--success-color);
}

/* Form Options */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.checkbox-label a {
    color: var(--primary-color);
    text-decoration: none;
}

.checkbox-label a:hover {
    text-decoration: underline;
}

.forgot-password {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.3s ease;
}

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

/* Buttons */
.btn {
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(66, 165, 245, 0.3);
}

.btn-block {
    width: 100%;
}

/* Social Login */
.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0;
    color: var(--text-secondary);
}

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

.divider span {
    padding: 0 1rem;
    font-size: 0.9rem;
}

.social-login {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.btn-social {
    padding: 0.875rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: white;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-google {
    color: #db4437;
}

.btn-google:hover {
    background: #db4437;
    color: white;
    border-color: #db4437;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(219, 68, 55, 0.3);
}

.btn-facebook {
    color: var(--primary-color);
}

.btn-facebook:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(66, 165, 245, 0.3);
}

/* Switch Form */
.switch-form {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.switch-form a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.switch-form a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Success Message */
.success-message {
    background: rgba(40, 167, 69, 0.1);
    border: 2px solid var(--success-color);
    color: var(--success-color);
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideDown 0.5s ease;
}

.success-message i {
    font-size: 1.5rem;
}

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

/* Error Message */
.error-message {
    background: rgba(220, 53, 69, 0.1);
    border: 2px solid var(--danger-color);
    color: var(--danger-color);
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: shake 0.5s ease;
}

.error-message i {
    font-size: 1.5rem;
}

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

/* Responsive */
@media (max-width: 768px) {
    body {
        background: white;
    }

    .bg-animation {
        display: none;
    }

    .auth-container {
        padding: 1rem;
        min-height: 100vh;
        background: white;
    }

    .auth-box {
        max-width: 100%;
        box-shadow: none;
        border-radius: 0;
    }

    .auth-header {
        padding: 1.5rem 1rem;
    }

    .logo-img-auth {
        height: 40px;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .auth-form {
        padding: 1.5rem 1rem;
    }

    .auth-form h2 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .form-group {
        margin-bottom: 1.25rem;
    }

    .form-control {
        padding: 0.75rem;
        font-size: 16px; /* Prevent zoom on iOS */
        color: var(--text-primary);
    }

    .btn {
        padding: 0.875rem 1.25rem;
    }

    .social-login {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .btn-social {
        padding: 0.75rem;
    }

    .form-options {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .checkbox-label {
        font-size: 0.875rem;
    }

    .switch-form {
        font-size: 0.875rem;
    }

    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        margin: 0 auto !important;
        border-radius: 12px !important;
        max-height: 95vh !important;
    }
    
    .modal-header {
        padding: 1rem !important;
    }
    
    .modal-body {
        padding: 1rem !important;
    }
    
    .modal-footer {
        padding: 1rem !important;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .auth-header {
        padding: 1.25rem 1rem;
    }

    .logo-img-auth {
        height: 36px;
    }

    .auth-form h2 {
        font-size: 1.25rem;
    }

    .form-group label {
        font-size: 0.9rem;
    }

    .form-control {
        padding: 0.625rem;
        color: var(--text-primary);
    }
}

/* Modal Styles for Telegram Verification */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    margin: 0 auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.3s ease;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.modal-footer .btn-primary {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, #42a5f5 0%, #1e88e5 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9375rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(66, 165, 245, 0.3);
    border: none;
    cursor: pointer;
}

.modal-footer .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(66, 165, 245, 0.4);
}

.modal-footer .btn-secondary {
    flex: 0 0 auto;
    padding: 0.875rem 1.5rem;
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-footer .btn-secondary:hover {
    background: var(--bg-color, #f5f7fa);
    border-color: var(--text-secondary);
}

body.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

body.modal-open .btn {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
}

/* Landscape mobile */
@media (max-width: 896px) and (orientation: landscape) {
    .auth-container {
        padding: 0.5rem;
    }

    .auth-box {
        max-height: 100vh;
        overflow-y: auto;
    }

    .auth-header {
        padding: 1rem;
    }

    .logo-img-auth {
        height: 32px;
    }

    .auth-form {
        padding: 1rem;
    }

    .form-group {
        margin-bottom: 1rem;
    }
}

/* Loading State */
.btn.loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    margin-left: 8px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* 2FA Styles */
.two-fa-group {
    animation: slideDown 0.3s ease-out;
    margin-top: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

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

.two-fa-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.two-fa-group label i {
    color: var(--primary-color);
}

.two-fa-group input {
    text-align: center;
    font-size: 1.5em;
    letter-spacing: 0.5em;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    padding: 0.75rem;
}

.two-fa-group .form-text {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Mobile adjustments for 2FA */
@media (max-width: 768px) {
    .two-fa-group input {
        font-size: 1.25em;
        letter-spacing: 0.3em;
    }
}


/* Telegram Verification Modal Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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