/* Стили для авторизации */
.auth-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.auth-modal-content {
    background: white;
    margin: 10% auto;
    padding: 20px;
    width: 90%;
    max-width: 400px;
    border-radius: 5px;
    position: relative;
}

.auth-close {
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 24px;
    cursor: pointer;
}

.auth-error-message {
    color: #d9534f;
    padding: 10px;
    margin-top: 10px;
    background: #fdf7f7;
    border-radius: 4px;
    display: none;
}

.auth-spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid rgba(0,0,0,.1);
    border-radius: 50%;
    border-top-color: #fff;
    animation: auth-spin 1s linear infinite;
}

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

/* Стили для модального окна смены пароля */
#change-password-modal .auth-modal-content,
#setup-2fa-modal .auth-modal-content {
    max-width: 450px;
}

/* Стили для кнопок 2FA */
#toggle-2fa-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
}

#toggle-2fa-btn:hover {
    background: #45a049;
}

#confirm-2fa-btn {
    background: #2196F3;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
}

#confirm-2fa-btn:hover {
    background: #0b7dda;
}

#2fa-setup-code {
    padding: 8px;
    width: 150px;
    margin-right: 10px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Стили для статуса 2FA */
#2fa-status-text {
    font-weight: bold;
    margin-bottom: 15px;
}

/* Стили для кнопки отправки кода в Telegram */
#send-telegram-code-btn {
    background: #ff9800;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    margin-top: 5px;
    cursor: pointer;
}

#send-telegram-code-btn:hover {
    background: #e68a00;
}

/* Стили для контейнера 2FA в форме авторизации */
#2fa-container {
    margin-top: 15px;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 4px;
    background-color: #f9f9f9;
}

/* Стили для панели пользователя */
.user-panel {
    position: relative;
    display: inline-block;
}

.user-menu {
    position: relative;
}

.user-info {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.user-info:hover {
    background-color: #f5f5f5;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #2196F3;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 10px;
    font-family: Arial, sans-serif;
}

.user-name {
    font-weight: 500;
    margin-right: 8px;
    color: #333;
}

.user-role {
    font-size: 0.9em;
    color: #666;
}

.user-menu-arrow {
    font-size: 0.8em;
    color: #666;
    transition: transform 0.2s;
}

.user-menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    width: 280px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    margin-top: 5px;
    overflow: hidden;
}

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

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

.user-menu-header {
    padding: 16px;
    border-bottom: 1px solid #eee;
    background-color: #f9f9f9;
}

.user-details {
    display: flex;
    align-items: center;
}

.user-avatar-large {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #2196F3;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2em;
    margin-right: 12px;
    font-family: Arial, sans-serif;
}

.user-info-detailed {
    flex: 1;
}

.user-name-detailed {
    font-weight: 600;
    margin-bottom: 4px;
    color: #333;
}

.user-role-detailed {
    font-size: 0.9em;
    color: #666;
}

.user-menu-items {
    padding: 8px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
    color: #333;
    text-decoration: none;
}

.menu-item:hover {
    background-color: #f5f5f5;
}

.menu-icon {
    margin-right: 12px;
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.menu-divider {
    margin: 8px 0;
    border: none;
    border-top: 1px solid #eee;
}

.logout-btn {
    color: #d9534f;
}

.logout-btn:hover {
    background-color: #fdf7f7;
    color: #c9302c;
}

/* Стили для форм авторизации */
#auth-form label {
    display: block;
    margin-bottom: 15px;
}

#auth-form input[type="tel"],
#auth-form input[type="password"],
#auth-form input[type="text"] {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

#auth-form button[type="submit"] {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
}

#auth-form button[type="submit"]:hover {
    background: #45a049;
}

/* Стили для мобильной авторизации */
.mobile-auth-item {
    display: none;
    border-bottom: 1px solid var(--border-color);
}

.mobile-auth-header {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
}

.mobile-auth-header .user-avatar {
    width: 24px;
    height: 24px;
    font-size: 0.8em;
    margin-right: 10px;
    font-family: Arial, sans-serif;
}

.mobile-auth-header .user-name {
    flex: 1;
    font-weight: 500;
    color: var(--header-text);
}

.mobile-auth-arrow {
    font-size: 0.8em;
    color: var(--header-text);
    transition: transform 0.3s ease;
}

.mobile-auth-content {
    display: none;
    padding: 10px 0;
    background: rgba(0, 0, 0, 0.1);
}

.mobile-auth-content.open {
    display: block;
}

.user-menu-items-mobile {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 0 20px;
}

.user-menu-items-mobile .menu-item {
    padding: 12px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--header-text);
}

.user-menu-items-mobile .menu-item:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Стиль для простой кнопки входа в мобильной версии */
.mobile-login-btn {
    display: none;
    padding: 15px 20px;
    background: var(--accent-color);
    color: #333;
    border: none;
    width: 100%;
    text-align: left;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

.mobile-login-btn:hover {
    background: var(--accent-hover);
}

/* Скрываем десктопную авторизацию на мобильных */
@media (max-width: 992px) {
    .desktop-auth {
        display: none;
    }
    
    .mobile-auth-item {
        display: block;
    }
    
    .mobile-login-btn {
        display: block;
    }
    
    /* Скрываем сложное меню авторизации для неавторизованных пользователей */
    .mobile-auth-item:not(.logged-in) .mobile-auth-header,
    .mobile-auth-item:not(.logged-in) .mobile-auth-content {
        display: none;
    }
}

/* Показываем десктопную авторизацию на больших экранах */
@media (min-width: 993px) {
    .mobile-auth-item {
        display: none;
    }
    
    .mobile-login-btn {
        display: none;
    }
    
    .desktop-auth {
        display: block;
    }
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .auth-modal-content {
        margin: 5% auto;
        padding: 15px;
        width: 95%;
    }
    
    .user-menu-dropdown {
        width: 250px;
        right: -10px;
    }
    
    #2fa-setup-code {
        width: 100%;
        margin-right: 0;
    }
    
    .user-info {
        padding: 6px 10px;
    }
    
    .user-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.9em;
    }
    
    .user-name {
        font-size: 0.9em;
    }
    
    .user-role {
        font-size: 0.8em;
    }
}

/* Стили для модального окна выбора роли */
#role-modal .auth-modal-content {
    max-width: 500px;
}

.role-selection-instruction {
    margin-bottom: 15px;
    font-weight: bold;
    text-align: center;
}

.role-item {
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.role-item:hover {
    background-color: #f5f5f5;
}

.role-item input[type="radio"] {
    margin-right: 10px;
}

.role-modal-actions {
    margin-top: 20px;
    text-align: center;
}

#confirm-role-change-btn {
    display: none;
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

#confirm-role-change-btn:hover {
    background-color: #45a049;
}