/**
 * Стили Личного Кабинета Игрока
 * Адаптивный дизайн для мобильных и десктоп
 */

/* ============================================
   СБРОС И БАЗОВЫЕ НАСТРОЙКИ
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: #e4e4e7;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #1a1a2e 100%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   КОНТЕЙНЕР
   ============================================ */
.container {
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
    padding: 0 16px;
}

@media (min-width: 768px) {
    .container {
        max-width: 600px;
        padding: 0 24px;
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 800px;
        padding: 0 32px;
    }
}

/* ============================================
   ХЕДЕР
   ============================================ */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    padding: 12px 0;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    font-size: 24px;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    color: #a78bfa;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    font-size: 16px;
}

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

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: #e4e4e7;
}

.user-balance {
    font-size: 12px;
    color: #a78bfa;
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

.header-login {
    padding: 8px 16px;
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
}

.header-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(167, 139, 250, 0.4);
}

/* ============================================
   ФЛЕШ-СООБЩЕНИЯ
   ============================================ */
.flash-message {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideDown 0.3s ease;
    max-width: 90%;
    width: 400px;
}

.flash-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.flash-error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.flash-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.flash-close:hover {
    opacity: 1;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translate(-50%, -20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* ============================================
   ОСНОВНОЙ КОНТЕНТ
   ============================================ */
.app-main {
    padding: 24px 0;
    min-height: calc(100vh - 140px);
}

/* ============================================
   КАРТОЧКИ
   ============================================ */
.dashboard-card, .auth-card, .purchase-card, .history-card, .settings-card {
    background: rgba(30, 30, 46, 0.8);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid rgba(139, 92, 246, 0.15);
    backdrop-filter: blur(10px);
}

.auth-card {
    max-width: 400px;
    margin: 0 auto;
}

.dashboard-card {
    width: 100%;
}

/* ============================================
   БАЛАНС И КЛЮЧ
   ============================================ */
.balance-header {
    text-align: center;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.15);
}

.balance-header h2 {
    font-size: 16px;
    color: #a78bfa;
    margin-bottom: 12px;
}

.balance-amount {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.coins-icon {
    font-size: 32px;
}

.coins-value {
    font-size: 36px;
    font-weight: 700;
    color: #a78bfa;
}

.key-section {
    margin-top: 20px;
}

.key-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.key-header h3 {
    font-size: 14px;
    color: #e4e4e7;
}

.key-value-container {
    background: rgba(167, 139, 250, 0.1);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 8px;
}

.key-value {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    color: #a78bfa;
    word-break: break-all;
}

.key-hint {
    font-size: 12px;
    color: #71717a;
    text-align: center;
}

/* ============================================
   УСЛУГИ
   ============================================ */
.services-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.services-header h2 {
    font-size: 18px;
    color: #e4e4e7;
}

.services-nav {
    display: flex;
    gap: 8px;
}

.nav-btn {
    padding: 8px 16px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 20px;
    color: #a78bfa;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nav-btn:hover, .nav-btn.active {
    background: rgba(139, 92, 246, 0.2);
    border-color: #a78bfa;
}

.services-slider {
    margin-bottom: 16px;
}

.slider-wrapper {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding-bottom: 16px;
    -webkit-overflow-scrolling: touch;
}

.slider-wrapper::-webkit-scrollbar {
    height: 6px;
}

.slider-wrapper::-webkit-scrollbar-track {
    background: rgba(139, 92, 246, 0.1);
    border-radius: 3px;
}

.slider-wrapper::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 3px;
}

.service-card {
    min-width: calc(50% - 8px);
    background: rgba(139, 92, 246, 0.05);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid rgba(139, 92, 246, 0.1);
    transition: all 0.3s ease;
}

.service-card:hover {
    border-color: rgba(139, 92, 246, 0.4);
    transform: translateY(-4px);
}

.service-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    margin-bottom: 12px;
}

.badge-subscription {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.badge-coins {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.service-icon {
    font-size: 32px;
    text-align: center;
    margin-bottom: 12px;
}

.service-card h3 {
    font-size: 14px;
    color: #e4e4e7;
    margin-bottom: 8px;
}

.service-description {
    font-size: 12px;
    color: #71717a;
    margin-bottom: 16px;
    line-height: 1.4;
}

.service-details {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-label {
    font-size: 11px;
    color: #71717a;
}

.detail-value {
    font-size: 14px;
    font-weight: 600;
}

.detail-value.price {
    color: #a78bfa;
}

.detail-value.coins {
    color: #f59e0b;
}

.service-buy-btn {
    width: 100%;
}

.slider-nav {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.slider-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    color: #a78bfa;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slider-btn:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: #a78bfa;
}

/* ============================================
   ДЕЙСТВИЯ
   ============================================ */
.actions-card h3 {
    font-size: 16px;
    color: #e4e4e7;
    margin-bottom: 16px;
}

.actions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 8px;
    background: rgba(139, 92, 246, 0.05);
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.action-item:active {
    transform: scale(0.95);
    background: rgba(139, 92, 246, 0.1);
}

.action-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.action-text {
    font-size: 11px;
    color: #a78bfa;
    text-align: center;
}

/* ============================================
   ФОРМЫ
   ============================================ */
.auth-form, .settings-form {
    width: 100%;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #e4e4e7;
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(30, 30, 46, 0.8);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 10px;
    color: #e4e4e7;
    font-size: 15px;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.form-group input.error {
    border-color: #ef4444;
}

.form-group input.success {
    border-color: #10b981;
}

.error-message {
    display: block;
    font-size: 12px;
    color: #ef4444;
    margin-top: 6px;
    min-height: 18px;
}

.hint {
    font-size: 12px;
    color: #71717a;
    margin-top: 6px;
}

.password-requirements {
    margin-top: 12px;
}

.requirement {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #71717a;
    margin-top: 4px;
    transition: color 0.3s ease;
}

.requirement.met {
    color: #10b981;
}

.requirement.met .icon {
    color: #10b981;
}

.checkbox-group {
    margin-bottom: 24px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(139, 92, 246, 0.4);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
    border-color: transparent;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    color: white;
    font-size: 14px;
}

.checkbox-text {
    font-size: 14px;
    color: #a78bfa;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
}

.auth-footer p {
    font-size: 14px;
    color: #71717a;
}

.auth-footer a {
    color: #a78bfa;
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* ============================================
   КНОПКИ
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    width: 100%;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.4);
}

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

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-lg {
    padding: 18px 24px;
    font-size: 16px;
}

.btn-secondary {
    background: rgba(139, 92, 246, 0.2);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

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

.btn-loader {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn.loading .btn-text {
    display: none;
}

.btn.loading .btn-loader {
    display: block;
}

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

/* ============================================
   МОДАЛЬНОЕ ОКНО
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: linear-gradient(135deg, #1e1e2e 0%, #2d2d44 100%);
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    width: 100%;
    position: relative;
    border: 1px solid rgba(139, 92, 246, 0.3);
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 24px;
    color: #71717a;
    cursor: pointer;
    transition: color 0.3s;
}

.modal-close:hover {
    color: #e4e4e7;
}

.modal-content h2 {
    font-size: 18px;
    color: #e4e4e7;
    margin-bottom: 20px;
    text-align: center;
}

/* ============================================
   ТАБЛИЦЫ
   ============================================ */
.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th,
.history-table td {
    padding: 12px 8px;
    text-align: left;
    font-size: 13px;
}

.history-table th {
    color: #a78bfa;
    font-weight: 600;
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}

.history-table td {
    color: #e4e4e7;
    border-bottom: 1px solid rgba(139, 92, 246, 0.1);
}

.history-table tr:last-child td {
    border-bottom: none;
}

.history-table .date {
    color: #71717a;
    font-size: 12px;
}

.history-table .service-name {
    font-weight: 500;
}

.history-table .service-desc {
    color: #71717a;
    font-size: 11px;
}

/* ============================================
   ПУСТОЕ СОСТОЯНИЕ
   ============================================ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    color: #e4e4e7;
    margin-bottom: 8px;
}

.empty-state p {
    color: #71717a;
    margin-bottom: 24px;
}

/* ============================================
   НАСТРОЙКИ
   ============================================ */
.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.settings-header h1 {
    font-size: 20px;
    color: #e4e4e7;
}

.back-link {
    color: #a78bfa;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.3s;
}

.back-link:hover {
    color: #8b5cf6;
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: rgba(139, 92, 246, 0.05);
    border-radius: 12px;
    margin-bottom: 20px;
}

.profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 600;
    color: white;
}

.profile-details {
    flex: 1;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(139, 92, 246, 0.1);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: #71717a;
    font-size: 14px;
}

.detail-value {
    color: #e4e4e7;
    font-weight: 500;
}

.detail-value.coins {
    color: #a78bfa;
}

.warning-card {
    border-color: rgba(239, 68, 68, 0.2);
}

.warning-card h2 {
    color: #ef4444;
}

.danger-zone {
    margin-top: 16px;
}

.danger-item {
    padding: 16px;
    background: rgba(239, 68, 68, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.1);
    margin-bottom: 16px;
}

.danger-item h3 {
    color: #ef4444;
    font-size: 14px;
    margin-bottom: 8px;
}

.danger-item p {
    color: #71717a;
    font-size: 13px;
    line-height: 1.5;
}

.app-info {
    margin-top: 16px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(139, 92, 246, 0.1);
}

.info-row:last-child {
    border-bottom: none;
}

.info-row .label {
    color: #71717a;
    font-size: 14px;
}

.info-row .value {
    color: #e4e4e7;
    font-size: 14px;
    font-family: monospace;
}

/* ============================================
   ФУТЕР
   ============================================ */
.app-footer {
    text-align: center;
    padding: 24px 16px;
    border-top: 1px solid rgba(139, 92, 246, 0.1);
}

.app-footer p {
    font-size: 13px;
    color: #71717a;
    margin-bottom: 8px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.footer-links a {
    color: #a78bfa;
    text-decoration: none;
    font-size: 13px;
    transition: color 0.3s;
}

.footer-links a:hover {
    color: #8b5cf6;
}

/* ============================================
   DEBUG ИНФО
   ============================================ */
.debug-info {
    margin-top: 24px;
    padding: 16px;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.debug-info p {
    font-size: 13px;
    color: #f59e0b;
    margin-bottom: 8px;
}

.debug-info a {
    color: #f59e0b;
    text-decoration: underline;
}

/* ============================================
   АДАПТИВНОСТЬ
   ============================================ */
@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }
    
    .dashboard-card, .auth-card, .purchase-card, .settings-card {
        padding: 20px 16px;
    }
    
    .coins-value {
        font-size: 28px;
    }
    
    .services-nav {
        flex-wrap: wrap;
    }
    
    .nav-btn {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .service-card {
        min-width: calc(100% - 16px);
    }
    
    .actions-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .slider-btn {
        width: 40px;
        height: 40px;
    }
}

@media (min-width: 768px) {
    .service-card {
        min-width: calc(50% - 8px);
    }
    
    .actions-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1024px) {
    .service-card {
        min-width: calc(33.333% - 11px);
    }
    
    .actions-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ============================================
   WEBVIEW СПЕЦИФИЧНЫЕ СТИЛИ
   ============================================ */
.webview .app-header {
    padding-top: 8px;
    padding-bottom: 8px;
}

.webview .back-button {
    display: block;
}

/* ============================================
   АНИМАЦИИ
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.dashboard-card, .auth-card {
    animation: fadeIn 0.3s ease;
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(139, 92, 246, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.5);
}