/* ============================================
   Dashboard Extra Styles
   Mobile menu, additional sections, modals
   ============================================ */

/* Chart Timeframe Buttons */
.chart-tf-btn {
    padding: 4px 12px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.chart-tf-btn:hover {
    border-color: rgba(0,240,255,0.3);
    color: #94a3b8;
    background: rgba(0,240,255,0.05);
}
.chart-tf-btn.active {
    border-color: #00f0ff;
    color: #00f0ff;
    background: rgba(0,240,255,0.12);
    box-shadow: 0 0 8px rgba(0,240,255,0.15);
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    padding: 12px 20px;
    min-height: 56px;
    box-sizing: border-box;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    justify-content: space-between;
    align-items: center;
}

.mobile-menu-btn {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    z-index: 1002;
    position: relative;
}

.mobile-menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    touch-action: pan-y;
}

.mobile-menu-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Section Panels */
.section-panel {
    animation: fadeIn 0.3s ease;
}

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

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

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

/* Trades Table */
.trades-table-container {
    overflow-x: auto;
    margin: 0 -24px;
    padding: 0 24px;
}

.trades-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
}

.trades-table th,
.trades-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.trades-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    background: var(--bg-elevated);
}

.trades-table td {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.trades-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.trades-table .profit-positive {
    color: var(--accent-green);
    font-weight: 600;
}

.trades-table .profit-negative {
    color: var(--accent-red);
    font-weight: 600;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 16px !important;
}

/* Referral Section */
.referral-info {
    text-align: center;
}

.referral-info > p {
    margin-bottom: 24px;
    font-size: 1.1rem;
}

.referral-link-box {
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 32px;
}

.referral-link-box label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.referral-link-input {
    display: flex;
    gap: 12px;
}

.referral-link-input input {
    flex: 1;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--accent-cyan);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    min-width: 0; /* Позволяет input сжиматься */
    overflow-x: auto; /* Позволяет прокручивать длинную ссылку */
    white-space: nowrap; /* Не переносит ссылку на новую строку */
}

.referral-stats {
    display: flex;
    justify-content: center;
    gap: 48px;
}

.ref-stat {
    text-align: center;
}

.ref-stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

.ref-stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.modal-overlay.hidden {
    display: none;
    pointer-events: none;
}

/* Ensure modal content is clickable */
.modal-content {
    pointer-events: auto !important;
    position: relative;
    z-index: 2001;
    touch-action: manipulation;
}

.modal-content .btn,
.modal-content button,
.modal-content a.btn {
    pointer-events: auto !important;
    touch-action: manipulation;
    position: relative;
    z-index: 2002;
    -webkit-tap-highlight-color: rgba(0, 240, 255, 0.3);
}

.modal-content {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    animation: modalIn 0.3s ease;
}

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

.modal-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.modal-content h3 {
    margin-bottom: 12px;
}

.modal-content p {
    margin-bottom: 24px;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Dashboard main section */
.dashboard-main-section {
    display: block;
}

/* Fix for section panels */
.section-panel {
    width: 100%;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }

    .mobile-header {
        display: flex;
        height: auto;
        min-height: 56px;
    }

    .mobile-menu-overlay {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 999;
        top: 0;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        grid-column: 1;
        margin-left: 0 !important;
        margin-top: 0 !important;
        padding-top: 80px !important;
        padding-left: 16px;
        padding-right: 16px;
        width: 100%;
        box-sizing: border-box;
        position: relative;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        margin-top: 0 !important;
        margin-bottom: 24px;
        padding-top: 0;
        position: relative;
        z-index: 1;
    }
    
    /* Убеждаемся, что первый элемент не заезжает за хедер */
    .main-content > *:first-child {
        margin-top: 0;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .control-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .chart-container {
        height: 240px;
    }

    .logs-container {
        height: 180px;
    }

    .referral-stats {
        flex-direction: column;
        gap: 24px;
    }

    .referral-link-input {
        flex-direction: column;
    }

    .trades-table-container {
        margin: 0 -16px;
        padding: 0 16px;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 80px 16px 20px;
    }

    .dashboard-header h2 {
        font-size: 1.5rem;
    }

    .status-badge {
        font-size: 0.875rem;
        padding: 6px 12px;
    }

    .card {
        padding: 20px;
    }

    .stat-card {
        padding: 20px;
    }

    .stat-card .value {
        font-size: 1.75rem;
    }

    .chart-container {
        height: 200px;
    }

    .logs-container {
        height: 150px;
        font-size: 0.8rem;
    }

    .input-group input,
    .input-group select {
        padding: 12px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
    }

    .btn {
        padding: 14px 24px;
        font-size: 0.9rem;
        min-height: 48px;
        min-width: 48px;
    }

    .section-header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .section-header-row h3 {
        font-size: 1.25rem;
    }

    .trades-table {
        font-size: 0.85rem;
    }

    .trades-table th,
    .trades-table td {
        padding: 10px 12px;
    }

    .referral-link-input input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 16px;
        min-height: 44px;
    }

    .ref-stat-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 60px 12px 16px;
    }

    .card {
        padding: 16px;
    }

    .btn {
        padding: 16px 24px;
        font-size: 0.95rem;
        min-height: 52px;
        min-width: 52px;
        width: 100%;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card .value {
        font-size: 1.5rem;
    }

    .dashboard-header h2 {
        font-size: 1.25rem;
    }

    .chart-container {
        height: 180px;
    }

    .logs-container {
        height: 120px;
        padding: 12px;
    }

    .section-header-row h3 {
        font-size: 1.1rem;
    }

    .modal-content {
        padding: 24px 20px;
        margin: 16px;
    }

    .modal-icon {
        font-size: 3rem;
    }

    .trades-table {
        min-width: 400px;
    }

    .trades-table th,
    .trades-table td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .wallet-info {
        padding: 12px;
    }

    .wallet-info .address {
        font-size: 0.75rem;
    }

    .sidebar {
        width: 100%;
        max-width: 280px;
        padding: 20px 16px;
    }

    .sidebar-nav a {
        padding: 10px 14px;
        font-size: 0.9rem;
    }

    .sidebar-logo {
        margin-bottom: 24px;
        font-size: 1.25rem;
    }

    .wallet-info {
        padding: 12px;
        margin-bottom: 24px;
    }

    .btn-sm {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .ref-stat-value {
        font-size: 1.25rem;
    }

    .ref-stat-label {
        font-size: 0.8rem;
    }
}

/* Fix overflow issues */
.dashboard-layout {
    overflow-x: hidden;
}

.main-content {
    overflow-x: hidden;
    width: 100%;
    position: relative;
    z-index: 1;
}

/* Ensure buttons are clickable on mobile */
.btn,
button,
input[type="button"],
input[type="submit"],
a.btn {
    -webkit-tap-highlight-color: rgba(0, 240, 255, 0.3);
    touch-action: manipulation;
    cursor: pointer;
    pointer-events: auto !important;
    position: relative;
    z-index: 100;
    -webkit-user-select: none;
    user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    /* Prevent double-tap zoom on mobile */
    touch-action: manipulation;
}

/* Prevent double-tap zoom on buttons */
.btn:active,
button:active {
    transform: scale(0.98);
}

/* Fix for inputs and selects on mobile */
.input-group input,
.input-group select {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    font-size: 16px; /* Prevents zoom on iOS */
}

/* Ensure cards don't block clicks */
.card {
    position: relative;
    z-index: 1;
}

/* Fix for sidebar links */
.sidebar-nav a {
    -webkit-tap-highlight-color: rgba(0, 240, 255, 0.2);
    touch-action: manipulation;
    min-height: 44px;
    display: flex;
    align-items: center;
    pointer-events: auto !important;
    position: relative;
    z-index: 10;
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* Fix for iOS Safari viewport */
@supports (-webkit-touch-callout: none) {
    body.modal-open {
        position: fixed;
        left: 0;
        right: 0;
    }
}

/* Ensure cards don't overflow */
.card {
    box-sizing: border-box;
    overflow: visible;
}

/* Fix table scrolling on mobile */
.trades-table-container {
    -webkit-overflow-scrolling: touch;
}

/* Desktop specific fixes */
@media (min-width: 1025px) {
    .main-content {
        padding: 32px 40px;
    }
    
    .control-grid > div {
        min-width: 0;
        overflow: visible;
        width: 100%;
    }
    
    .chart-card,
    .logs-card,
    .bot-card,
    .withdraw-card,
    .sub-card {
        overflow: visible;
    }
}

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

.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 15, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-end;
}

.toast {
    padding: 16px 24px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    animation: toastIn 0.3s ease;
    min-width: 200px;
    max-width: 500px;
    width: fit-content;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.toast.success {
    border-color: var(--accent-green);
}

.toast.error {
    border-color: var(--accent-red);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@media (max-width: 480px) {
    .toast-container {
        left: 16px;
        right: 16px;
        top: 16px;
        align-items: stretch;
    }

    .toast {
        max-width: none;
        width: 100%;
        white-space: normal;
    }
}

/* ============================================
   Детальная статистика рефералов
   ============================================ */

.referral-stats-detailed {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 20px;
    margin-top: 24px;
    padding: 24px;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.referral-stats-detailed .ref-stat {
    text-align: center;
    padding: 12px;
}

.referral-stats-detailed .ref-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-cyan);
    margin-bottom: 4px;
}

.referral-stats-detailed .ref-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Статусы комиссий */
.commission-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.commission-status.pending {
    background: rgba(250, 204, 21, 0.15);
    color: #facc15;
    border: 1px solid rgba(250, 204, 21, 0.3);
}

.commission-status.awarded {
    background: rgba(0, 240, 160, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(0, 240, 160, 0.3);
}

/* Адрес кошелька в таблице */
.wallet-address {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent-cyan);
    background: rgba(0, 240, 255, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .referral-stats-detailed {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        padding: 16px;
    }

    .referral-stats-detailed .ref-stat-value {
        font-size: 1.25rem;
    }

    .referral-stats-detailed .ref-stat-label {
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .referral-stats-detailed {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        padding: 12px;
    }

    .referral-stats-detailed .ref-stat {
        padding: 8px;
    }

    .referral-stats-detailed .ref-stat-value {
        font-size: 1.1rem;
    }

    .wallet-address {
        font-size: 0.75rem;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ============================================
   Support Section (Dashboard)
   ============================================ */

.support-card-dashboard {
    max-width: 600px;
    margin: 0 auto;
}

.support-content {
    text-align: center;
    padding: 20px 0;
}

.support-icon-large {
    font-size: 4rem;
    margin-bottom: 20px;
}

.support-content h2 {
    font-size: 1.75rem;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.support-content > p {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 32px;
    max-width: 450px;
    margin-left: auto;
    margin-right: auto;
}

.support-telegram-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 18px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, #0088cc, #00aced);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 136, 204, 0.3);
}

.support-telegram-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(0, 136, 204, 0.5);
}

.support-telegram-btn .tg-icon {
    font-size: 1.3rem;
}

.support-info {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.support-info-item {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.support-info-item .info-icon {
    font-size: 1.2rem;
}

@media (max-width: 768px) {
    .support-icon-large {
        font-size: 3rem;
    }

    .support-content h2 {
        font-size: 1.5rem;
    }

    .support-telegram-btn {
        padding: 16px 32px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .support-card-dashboard {
        padding: 20px 16px;
    }

    .support-icon-large {
        font-size: 2.5rem;
    }

    .support-content h2 {
        font-size: 1.25rem;
    }

    .support-content > p {
        font-size: 0.9rem;
    }

    .support-telegram-btn {
        width: 100%;
        padding: 16px 24px;
    }

    .support-info-item {
        font-size: 0.85rem;
    }
}

/* ============================================
   VIP Badge Styles
   ============================================ */

.wallet-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.vip-badge-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* VIP неактивен (серый) */
.vip-badge-link.inactive {
    background: rgba(100, 116, 139, 0.2);
    border: 1px solid rgba(100, 116, 139, 0.3);
    color: #64748b;
}

.vip-badge-link.inactive:hover {
    background: rgba(100, 116, 139, 0.3);
    border-color: rgba(100, 116, 139, 0.5);
}

.vip-badge-link.inactive .vip-icon {
    filter: grayscale(100%);
    opacity: 0.5;
}

/* VIP активен (золотой) */
.vip-badge-link.active {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 170, 0, 0.15));
    border: 1px solid rgba(255, 215, 0, 0.5);
    color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
    animation: vipGlow 2s ease-in-out infinite alternate;
}

.vip-badge-link.active:hover {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(255, 170, 0, 0.25));
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.4);
    transform: scale(1.05);
}

.vip-badge-link.active .vip-icon {
    animation: crownBounce 1s ease-in-out infinite;
}

@keyframes vipGlow {
    from {
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
    }
    to {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
    }
}

@keyframes crownBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-2px);
    }
}

.vip-icon {
    font-size: 0.9rem;
}

.vip-text {
    font-size: 0.65rem;
}

@media (max-width: 480px) {
    .wallet-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .vip-badge-link {
        padding: 3px 8px;
    }

    .vip-icon {
        font-size: 0.8rem;
    }

    .vip-text {
        font-size: 0.6rem;
    }
}

