/* PAGE */

.profile-wrapper {
    display: flex;
    justify-content: center;
    padding: 40px;
}

/* MAIN CARD */

.profile-card {
    width: 100%;
    max-width: 1500px;
    border: 1px solid #2a2a2a;
    background: #121212;
    border-radius: 12px;
    padding: 30px;
}

/* TITLE */

.profile-title {
    text-align: center;
    margin-bottom: 25px;
}

/* LAYOUT */

.profile-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 40px;
}

/* USER */

.profile-user {
    display: flex;
    flex-direction: column;
    margin-top: 15px;
    gap: 20px;
}

.profile-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.profile-field input {
    padding: 8px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    color: white;
}

.profile-field .toggle-prof-password {
    position: absolute;
    top: 55%;
    right: 12px;
    /* отступ от края input */
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: #ffffff;
    /* глазик белый */
    padding: 0;
}

.profile-field .toggle-prof-password svg {
    display: block;
    /* убираем лишние отступы */
    width: 20px;
    height: 20px;
    pointer-events: none;
}

/* VPN */

.vpn-title {
    margin-bottom: 11px;
}

.vpn-scroll {
    max-height: 670px;
    min-height: 220px;
    overflow-y: auto;

    display: flex;
    flex-direction: column;

    gap: 20px;

    padding-right: 4px;
}

/* VPN CARD */

.vpn-card {
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 15px;
    background: #161616;
}

/* MAIN */

.vpn-main {
    display: flex;
    gap: 20px;
}

/* QR */

.vpn-qr img {
    width: 100px;
    height: 100px;
}

/* CONTENT */

.vpn-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* HEADER */

.vpn-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.vpn-name {
    font-weight: 600;
}

.vpn-expire {
    font-size: 13px;
    color: #bbb;
    margin-left: auto;
    justify-self: right;
    padding-right: 3px;
    white-space: nowrap;
    flex-shrink: 0;
}

.vpn-status {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    justify-self: end;
}

.vpn-status.active {
    background: #22c55e22;
    color: #22c55e;
}

.vpn-status.inactive {
    background: #ffffff10;
    color: #aaa;
}

/* URL */

.vpn-url {
    position: relative;
    margin-top: 8px;
}


.vpn-url code {
    flex: 1;
    background: #0e0e0e;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: 8px;
    font-size: 12px;
    word-break: break-all;
    color: #ddd;
    padding-right: 42px;
}


.tg-code {
    display: block;

    background: #f4f6f8;
    border: 1px solid #e4e6e8;
    border-radius: 8px;

    font-family: monospace;
    font-size: 13px;

    padding: 10px 40px 10px 12px;
    /* место справа для кнопки */

    word-break: break-all;
}

/* BUTTONS */

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;

    width: 32px;
    height: 32px;

    border: none;
    border-radius: 8px;

    background: #1b1b1b;

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;

    transition: all 0.18s ease;
}



.btn-green {
    background: #22c55e;
    border: none;
    color: white;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
}

.btn-green:hover {
    background: #16a34a;
}

.btn-danger {
    background: #ef4444;
    border: none;
    color: white;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
}

.btn-danger:hover {
    background: #dc2626;
}

/* ACTIONS */

.vpn-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
}

/* ADD CARD */

.vpn-add {
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

.copy-btn:hover {
    background: #242424;
}


/* ICON */

/* icon */

.copy-icon {
    width: 16px;
    height: 16px;
    fill: #9ca3af;
    transition: fill .18s ease;
}

.copy-btn:hover .copy-icon {
    fill: #22c55e;
}

.copy-btn:active {
    transform: scale(0.92);
}

.copy-btn.copied {
    background: #22c55e22;
}

.copy-btn.copied .copy-icon {
    fill: #22c55e;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;

    max-width: 1200px;
    margin: 0 auto 20px auto;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    flex-wrap: nowrap;
}

.top-bar .iron-lang {
    margin-bottom: 0;
    align-items: center;
}

.btn-instructions {
    background: transparent;
    border: 1px solid #22c55e;
    color: #22c55e;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all .15s ease;
}

.btn-instructions:hover {
    background: #22c55e;
    color: #fff;
}

.btn-logout {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    color: #ddd;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all .15s ease;
}

.btn-logout:hover {
    border-color: #ef4444;
    color: #ef4444;
}

.lang-switch {
    display: flex;
    gap: 8px;
}

.vpn-qr-img {
    width: 100%;
    height: 100%;
    cursor: pointer;
    transition: transform 0.25s ease;
    transform-origin: center center;
    /* масштаб из центра */
}

/* увеличенный QR */

.vpn-qr-img.expanded {
    transform: scale(2.2) translateX(20px) translateY(20px);
    z-index: 1000;
    position: relative;
}

.vpn-qr-img.closing {
    z-index: 1000;
    position: relative;
}

.vpn-qr {
    position: relative;
    width: 100px;
    height: 100px;
}

.vpn-name-wrapper {
    position: relative;
    width: 100%;
    /* контейнер растягивается по родителю */
    max-width: calc(1ch * 23 + 32px);
    /* max 2 номера + padding для кнопки */
    min-width: calc(1ch * 11 + 32px);
    /* min 1 номер + padding */
}

.vpn-name-mobile-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.mobile-refresh-btn {
    display: none;
    flex-shrink: 0;
}

.vpn-name-input {
    width: 100%;
    /* растягиваем на весь контейнер */
    padding: 6px 32px 6px 8px;
    /* справа оставляем место для кнопки */
    border-radius: 6px;
    border: 1px solid #2a2a2a;
    background: #1a1a1a;
    color: white;
    box-sizing: border-box;
    /* важно! */
    font-family: monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    /* если текст превышает max-width */
    transition:
        border-color .2s ease,
        box-shadow .2s ease;
}

.vpn-name-input.success {
    border-color: #22c55e;

    box-shadow:
        0 0 0 1px #22c55e,
        0 0 10px rgba(34, 197, 94, 0.45);

    transition: box-shadow .2s ease;
}

.vpn-name-save-btn {
    position: absolute;
    top: 50%;
    right: 6px;
    /* кнопка остаётся справа input */
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.15s ease;
    padding: 0;
}

.vpn-name-save-btn:hover {
    background: #e9ecef22;
}

.save-icon {
    width: 16px;
    height: 16px;
    fill: #ddd;
}

.vpn-name-save-btn:hover .save-icon {
    fill: #22c55e;
}

.modal-message {
    font-size: 14px;
    text-align: center;
    margin-bottom: 16px;
    color: #ddd;
}

.modal-backdrop {
    position: fixed;
    inset: 0;

    background: rgba(0, 0, 0, 0.4);

    display: flex;
    justify-content: center;
    align-items: center;

    opacity: 0;
    pointer-events: none;

    transition: opacity .25s ease;
}

.modal-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: #1f1f1f;
    padding: 24px;
    border-radius: 10px;

    transform: scale(0.9);
    opacity: 0;

    transition:
        transform .25s ease,
        opacity .25s ease;
}

.modal-box.show {
    transform: scale(1);
    opacity: 1;
}

.vpn-search {
    width: 100%;
    margin-bottom: 12px;
}

.vpn-search input {
    width: 100%;
    box-sizing: border-box;
}

/* =========================
   TABLET
========================= */

@media (max-width: 1024px) {

    .profile-wrapper {
        padding: 20px;
    }

    .profile-layout {
        grid-template-columns: 250px 1fr;
        gap: 25px;
    }

}

/* =========================
   MOBILE
========================= */

@media (max-width: 768px) {

    body {
        overflow-y: auto;
    }

    .top-bar {
        display: flex;
        align-items: center;
        padding: 0 10px;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .top-bar .lang-switch {
        margin-right: 0;
        flex-shrink: 0;
    }

    .top-bar-actions {
        margin-left: auto;
        gap: 8px;
        flex-shrink: 0;
        flex-wrap: wrap;
        justify-content: flex-end;
        width: 100%;
        align-items: stretch;
        margin-top: 12px;
    }

    .top-bar-actions button {
        min-width: 0;
        flex: 1 1 calc(33.333% - 5px);
        max-width: calc(33.333% - 5px);
        white-space: normal;
        padding: 6px 10px;
        font-size: 12px;
        line-height: 1.3;
        text-align: center;
        min-height: 42px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .btn-instructions,
    .btn-logout,
    .btn-delete-client {
        padding: 6px 10px;
        font-size: 12px;
    }

    /* контейнер */

    .profile-wrapper {
        padding: 10px;
        min-height: auto;
    }

    /* карточка */

    .profile-card {
        width: 100%;
        max-width: 100%;
        padding: 20px;
        border-radius: 10px;
    }

    /* layout */

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

    /* user блок */

    /* inputs */

    .profile-field input {
        width: 100%;
        box-sizing: border-box;
        font-size: 16px;
    }

    .btn-green {
        width: 100%;
        font-size: 16px;
        padding: 12px;
    }

    /* убираем ограничение высоты */

    .mobile-refresh-btn {
        display: flex;
        position: absolute;
        top: 0;
        right: 0;
    }

    .desktop-refresh-btn {
        display: none;
    }

    .vpn-buy-actions {
        justify-content: space-between;
    }

    .vpn-scroll {
        max-height: none;
    }

    .profile-user {
        gap: 14px;
    }

    /* VPN блок */

    .vpn-main {
        flex-direction: column;
        gap: 12px;
    }

    .vpn-qr {
        width: 90px;
        height: 90px;
    }

    .vpn-qr img {
        width: 90px;
        height: 90px;
    }

    .vpn-header {
        position: relative;
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .vpn-expire {
        margin-left: 0;
    }

    .vpn-actions {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .vpn-buy-actions {
        display: flex;
        gap: 10px;
        justify-content: space-between;
    }

    .vpn-scroll {
        max-height: none;
        overflow: visible;
    }

    .tg-code {
        font-size: 12px;
    }

}

/* =========================
   SMALL PHONES
========================= */

@media (max-width: 480px) {

    .top-bar {
        padding: 0 6px;
    }

    .top-bar .lang-switch {
        gap: 4px;
    }

    .top-bar-actions {
        gap: 6px;
    }

    .btn-instructions,
    .btn-logout {
        padding: 6px 8px;
        font-size: 11px;
    }

    .profile-title {
        font-size: 20px;
    }

    .vpn-card {
        padding: 12px;
    }

    .vpn-name-input {
        font-size: 13px;
    }

    .tg-code {
        font-size: 11px;
        padding: 8px 36px 8px 10px;
    }

    .btn-green,
    .btn-danger {
        width: 100%;
        text-align: center;
    }

}
