/* ===== СТИЛИ АВТОРИЗАЦИИ PHARMANEXT ===== */

/* Авторизация в шапке */
.auth-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.auth-buttons {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.auth-btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-family);
}

.login-btn {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.login-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* Меню пользователя */
.user-menu {
    position: relative;
    display: none;
}

.user-menu.active {
    display: block;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.user-info:hover {
    background: rgba(8, 169, 170, 0.1);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--dark-color);
}

.user-bonus {
    font-size: 0.8rem;
    color: #666;
}

.user-dropdown-arrow {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.user-info:hover .user-dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-medium);
    min-width: 200px;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
    display: none;
    z-index: 1001;
    border: 1px solid var(--border-color);
}

/* Мобильные устройства - выпадающее меню на всю ширину */
@media (max-width: 768px) {
    .user-dropdown {
        right: auto;
        left: 0;
        min-width: 100%;
        width: 100vw;
        max-width: 100vw;
        margin-left: -10px;
        margin-right: -10px;
        border-radius: 0;
        box-shadow: 0 4px 20px rgba(0,0,0,0.15);
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        animation: slideUp 0.3s ease;
    }
    
    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
    
    .auth-section {
        position: relative;
        width: 100%;
        z-index: 1000;
    }
    
    .user-menu {
        width: 100%;
    }
    
    .auth-btn {
        width: 100%;
        justify-content: center;
        padding: 10px 16px;
        font-size: 0.95rem;
        min-height: 44px; /* Минимальный размер для touch */
    }
    
    .user-info {
        width: 100%;
        justify-content: space-between;
        min-height: 44px; /* Минимальный размер для touch */
    }
    
    /* Улучшаем видимость модального окна на мобильных */
    .modal {
        padding: 0;
        align-items: flex-end;
    }
    
    .modal-content {
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 90vh;
        margin: 0;
    }
}

.user-dropdown.show {
    display: block;
    animation: dropdownSlideIn 0.2s ease;
}

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

.user-dropdown a {
    display: block;
    padding: 10px 20px;
    color: var(--dark-color);
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
    font-size: 0.9rem;
}

.user-dropdown a:hover {
    background: rgba(8, 169, 170, 0.1);
    color: var(--primary-color);
}

/* Модальные окна авторизации */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 0;
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalSlideIn 0.3s ease;
}

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

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

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 5px;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.close-btn:hover {
    background: var(--light-color);
    color: var(--dark-color);
}

/* Табы авторизации */
.auth-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
}

.auth-tab {
    flex: 1;
    padding: 1rem;
    background: transparent;
    border: none;
    color: #666;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: var(--transition);
    font-size: 1rem;
    font-family: var(--font-family);
}

.auth-tab:hover {
    background: rgba(8, 169, 170, 0.1);
}

.auth-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: rgba(8, 169, 170, 0.05);
}

/* Контейнер форм */
.auth-form-container {
    padding: 2rem;
}

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

/* Группы полей */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark-color);
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    font-family: var(--font-family);
    background: white;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(8, 169, 170, 0.1);
}

.form-group input.error {
    border-color: var(--error-color);
}

.form-group input:invalid {
    border-color: var(--error-color);
}

.form-group input:valid {
    border-color: var(--success-color);
}

/* Чекбоксы */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin: 0;
    transform: scale(1.2);
}

.checkbox-group label {
    margin: 0;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Сообщения об ошибках и успехе */
.form-error {
    color: var(--error-color);
    font-size: 0.9rem;
    margin: 0.5rem 0;
    padding: 0.5rem;
    background: rgba(231, 76, 60, 0.1);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--error-color);
}

.form-success {
    color: var(--success-color);
    font-size: 0.9rem;
    margin: 0.5rem 0;
    padding: 0.5rem;
    background: rgba(39, 174, 96, 0.1);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--success-color);
}

/* Кнопки отправки */
.submit-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 1rem;
    font-family: var(--font-family);
}

.submit-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

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

.submit-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Разделитель */
.auth-divider {
    text-align: center;
    margin: 1.5rem 0;
    position: relative;
    color: #666;
    font-size: 0.9rem;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-color);
}

.auth-divider span {
    background: white;
    padding: 0 1rem;
    position: relative;
    z-index: 1;
}

/* Кнопка Telegram */
.telegram-btn {
    width: 100%;
    padding: 12px;
    background: #0088cc;
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-family);
}

.telegram-btn:hover {
    background: #0077b3;
    transform: translateY(-1px);
}

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

/* Ссылки переключения */
.switch-link {
    text-align: center;
    margin-top: 1rem;
}

.switch-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    font-size: 0.9rem;
}

.switch-link a:hover {
    text-decoration: underline;
}

/* Telegram авторизация */
.telegram-auth-modal .modal-content {
    max-width: 400px;
}

.telegram-widget-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3000;
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: var(--shadow-heavy);
    text-align: center;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

.telegram-qr-container {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--light-color);
    border-radius: 10px;
    border: 2px dashed var(--primary-color);
}

.telegram-qr-code {
    width: 120px;
    height: 120px;
    border-radius: 4px;
    border: 1px solid #ddd;
    margin: 0 auto 0.5rem;
    display: block;
}

.telegram-instructions {
    font-size: 0.75rem;
    color: #666;
    line-height: 1.3;
    margin-top: 0.5rem;
}

.telegram-id-input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.telegram-id-input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.telegram-method-btns {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.telegram-method-btn {
    flex: 1;
    padding: 8px 10px;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}

.telegram-method-btn.active {
    background: var(--success-color);
    color: white;
}

.telegram-method-btn:not(.active) {
    background: #ccc;
    color: white;
}

/* Валидация полей */
.form-group.has-error input {
    border-color: var(--error-color);
    background: rgba(231, 76, 60, 0.05);
}

.form-group.has-success input {
    border-color: var(--success-color);
    background: rgba(39, 174, 96, 0.05);
}

.field-validation {
    font-size: 0.8rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.field-validation.error {
    color: var(--error-color);
}

.field-validation.success {
    color: var(--success-color);
}

.field-validation.warning {
    color: var(--warning-color);
}

/* Индикаторы загрузки */
.auth-loading {
    position: relative;
    overflow: hidden;
}

.auth-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.8), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Адаптивность */
@media (max-width: 768px) {
    .auth-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .modal-header {
        padding: 1.5rem 1.5rem 1rem;
    }
    
    .auth-form-container {
        padding: 1.5rem;
    }
    
    .auth-tab {
        font-size: 0.9rem;
        padding: 0.8rem 0.5rem;
    }
    
    .user-dropdown {
        right: -10px;
        min-width: 180px;
    }
    
    .telegram-widget-container {
        width: 95%;
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .modal-title {
        font-size: 1.2rem;
    }
    
    .auth-tab {
        font-size: 0.8rem;
        padding: 0.7rem 0.3rem;
    }
    
    .form-group input {
        padding: 10px;
    }
    
    .submit-btn,
    .telegram-btn {
        padding: 10px;
        font-size: 0.9rem;
    }
}

/* ===== СТИЛИ ДЛЯ TELEGRAM QR АВТОРИЗАЦИИ ===== */

/* QR модальное окно */
.telegram-qr-modal .modal-content {
    max-width: 450px;
    padding: 0;
}

.telegram-qr-content {
    padding: 2rem;
    text-align: center;
}

/* Инструкции */
.qr-instruction {
    margin-bottom: 2rem;
}

.qr-instruction h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-weight: 600;
}

.qr-instruction p {
    color: #666;
    line-height: 1.6;
}

/* Контейнер QR-кода */
.qr-code-container {
    background: #f8f9fa;
    border: 2px dashed var(--primary-color);
    border-radius: 15px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    position: relative;
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.qr-code-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* QR-код изображение */
.qr-code-image {
    width: 200px;
    height: 200px;
    border-radius: 10px;
    box-shadow: var(--shadow-medium);
    background: white;
    padding: 10px;
    transition: opacity 0.3s ease;
}

/* Ссылка под QR-кодом */
.qr-code-link {
    margin-top: 0.5rem;
}

.qr-code-link small {
    color: #666;
    font-size: 0.8rem;
}

.qr-code-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.qr-code-link a:hover {
    text-decoration: underline;
}

/* Загрузка QR-кода */
.qr-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--primary-color);
}

.qr-loading p {
    margin: 0;
    font-weight: 500;
}

/* Ошибка QR-кода */
.qr-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--error-color);
}

.qr-error p {
    margin: 0;
    color: #666;
}

/* Инструкции по использованию */
.qr-instructions {
    background: rgba(8, 169, 170, 0.05);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

.qr-instructions h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.qr-instructions ol {
    margin: 0;
    padding-left: 1.2rem;
    color: #555;
}

.qr-instructions li {
    margin-bottom: 0.3rem;
    line-height: 1.4;
}

/* Статус авторизации */
.auth-status {
    margin-bottom: 1.5rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.status-indicator.waiting {
    background: rgba(243, 156, 18, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(243, 156, 18, 0.3);
}

.status-indicator.scanned {
    background: rgba(8, 169, 170, 0.1);
    color: var(--primary-color);
    border: 1px solid rgba(8, 169, 170, 0.3);
}

.status-indicator.success {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(39, 174, 96, 0.3);
}

.status-indicator.registration {
    background: rgba(52, 152, 219, 0.1);
    color: #3498db;
    border: 1px solid rgba(52, 152, 219, 0.3);
}

.status-indicator.error {
    background: rgba(231, 76, 60, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(231, 76, 60, 0.3);
}

/* Иконки статуса */
.status-icon {
    font-size: 1.1rem;
    animation: pulse 2s infinite;
}

.status-indicator.success .status-icon,
.status-indicator.error .status-icon {
    animation: none;
}

/* Анимация пульса */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* Действия с QR-кодом */
.qr-actions {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.qr-actions.show {
    display: flex;
}

/* Адаптивность для мобильных */
@media (max-width: 480px) {
    .telegram-qr-content {
        padding: 1.5rem;
    }
    
    .qr-code-container {
        padding: 1.5rem;
        min-height: 250px;
    }
    
    .qr-code-image {
        width: 160px;
        height: 160px;
    }
    
    .qr-instructions {
        padding: 1rem;
    }
    
    .qr-instructions h4 {
        font-size: 0.9rem;
    }
    
    .qr-instructions li {
        font-size: 0.8rem;
    }
    
    .status-indicator {
        padding: 0.8rem;
        font-size: 0.8rem;
    }
}

/* Анимация появления QR-кода */
.qr-code-image {
    animation: qrAppear 0.5s ease;
}

@keyframes qrAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Спиннер загрузки для QR */
.qr-loading .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(8, 169, 170, 0.2);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Hover эффекты */
.qr-code-image:hover {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

/* Анимация успешной авторизации */
.status-indicator.success {
    animation: successPulse 0.6s ease;
}

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

/* Стили для темной темы (если потребуется) */
@media (prefers-color-scheme: dark) {
    .qr-code-container {
        background: #2c3e50;
        border-color: var(--primary-color);
    }
    
    .qr-instructions {
        background: rgba(8, 169, 170, 0.1);
    }
    
    .qr-code-image {
        background: white; /* QR всегда на белом фоне для читаемости */
    }
}

/**
 * ДОПОЛНИТЕЛЬНЫЕ CSS СТИЛИ
 * Добавьте в ваш CSS файл для лучшего отображения
 */
const additionalCSS = `
<style>
.qr-code-link small {
    display: block;
    margin-top: 0.5rem;
    color: #666;
}

.status-indicator.scanned {
    background-color: #e8f5e9;
    color: #2e7d32;
    border-left: 4px solid #4caf50;
    padding: 10px;
    border-radius: 4px;
}

.status-indicator.success {
    background-color: #e8f5e9;
    color: #1b5e20;
    border-left: 4px solid #4caf50;
    padding: 10px;
    border-radius: 4px;
    animation: success-pulse 2s ease-in-out;
}

@keyframes success-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.qr-code-image {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    border: 2px solid #f0f0f0;
}