/* CSS-переменные перемещены в design-tokens.css (подключается первым) */

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'Nunito', sans-serif;
    background: var(--color-background);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.profile-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.profile-hero {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.profile-hero__identity {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-accent-bg-light);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    overflow: hidden;
    border: 1px solid var(--color-accent-bg-medium);
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-name {
    margin: 0;
    font-size: clamp(1.6rem, 2.6vw, 2.4rem);
    font-weight: 600;
    color: var(--color-text);
}

.profile-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 1.5rem;
}

.profile-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Profile-specific card styles (использует базовые стили из cuenta-base.css) */
.profile-card {
    /* Базовые стили наследуются из .card */
    /* Переопределяем padding для Profile (было 1.25rem 1.5rem вместо var(--spacing-lg)) */
    padding: 1.25rem 1.5rem;
    /* Убираем box-shadow из .card для Profile */
    box-shadow: none;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-head h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

.section-edit {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-card);
    border: 1px solid var(--color-border);
    background: var(--color-background);
    color: var(--color-text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.section-edit:hover {
    border-color: var(--color-accent);
    color: var(--color-primary);
    background: var(--color-background-subtle);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.85rem 1.5rem;
    margin-top: 0.9rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.info-label {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.info-value {
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--color-text);
}

.info-muted {
    color: var(--color-text-muted);
    font-weight: 500;
}

.address-block {
    margin-top: 0.85rem;
}

.address-label {
    margin: 0;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--color-text);
}

.address-lines {
    margin: 0.5rem 0 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    color: var(--color-text-secondary);
}

.address-note {
    margin-top: 0.7rem;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.section-form,
.section-actions {
    display: none;
}

.profile-card.is-editing .section-form,
.profile-card.is-editing .section-actions {
    display: block;
    margin-top: 1rem;
}

.profile-card.is-editing .section-view {
    display: none;
}

.form-grid {
    display: grid;
    gap: 0.75rem;
}

.form-grid.two-col {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-section-label {
    grid-column: 1 / -1;
    margin-top: 0.25rem;
}

.form-grid + .form-grid {
    margin-top: 0.5rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-field label {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.profile-input {
    width: 100%;
    padding: 14px 22px;
    border-radius: 50px;
    border: 1px solid var(--color-border);
    background: var(--color-background);
    font-size: 0.95rem;
    color: var(--color-text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
}

select.profile-input {
    appearance: none;
    background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748B' d='M1.41 0.59 6 5.17 10.59 0.59 12 2l-6 6-6-6z'/%3E%3C/svg%3E\");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 12px 8px;
    padding-right: 44px;
}

/* Focus стили наследуются из .form-input:focus */
/* Переопределяем box-shadow для Profile (было 4px вместо 3px) */
.profile-input:focus {
    box-shadow: 0 0 0 4px var(--color-accent-bg-light);
}

.check-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-top: 1rem;
}

.billing-fields.is-hidden {
    display: none;
}

.billing-fields {
    margin-top: 0.75rem;
}

/* Унифицировано с Thank You page - кнопки по центру на десктопе */
.profile-card.is-editing .section-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    margin-top: var(--spacing-xl);
    align-items: center;
}

/* На десктопе кнопки должны быть заметными, но не на всю ширину */
@media (min-width: 641px) {
    .profile-card.is-editing .section-actions {
        gap: var(--spacing-md);
    }
    
    .profile-card.is-editing .section-actions .btn-primary {
        min-height: 52px;
        padding: var(--spacing-md) var(--spacing-xxl);
        font-size: 1.05rem;
        width: auto;
        min-width: 180px;
        max-width: 420px;
    }
    
    .profile-card.is-editing .section-actions .btn-secondary {
        min-height: 52px;
        padding: var(--spacing-md) var(--spacing-lg);
        font-size: 1.05rem;
        width: auto;
        min-width: 180px;
        max-width: 280px;
    }
}

/* Profile-specific button styles (использует базовые стили из cuenta-base.css) */
/* Базовые стили наследуются из .btn, .btn-primary, .btn-secondary */
/* Унифицировано с Thank You page - используем стандартные стили с --color-accent */
/* Специфичные переопределения удалены для единообразия */

.toggle-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.9rem;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-background-subtle);
}

.toggle-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.toggle-title {
    font-weight: 600;
    color: var(--color-text);
}

.toggle-sub {
    font-size: 0.88rem;
    color: var(--color-text-secondary);
}

.switch {
    position: relative;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}

.switch input {
    display: none;
}

.switch-slider {
    position: absolute;
    inset: 0;
    background: var(--color-border);
    border-radius: 999px;
    transition: background 0.2s ease;
}

.switch-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-background);
    box-shadow: 0 2px 6px var(--color-shadow-strong);
    transition: transform 0.2s ease;
}

.switch input:checked + .switch-slider {
    background: var(--color-success-bg-light);
}

.switch input:checked + .switch-slider::after {
    transform: translateX(20px);
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    color: var(--color-text-secondary);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.92rem;
}

.link-button:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

.secondary-action-row {
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    color: var(--color-text-secondary);
    font-size: 0.92rem;
}

.secondary-action-label {
    font-weight: 400;
}

.profile-security {
    margin-top: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.security-text {
    color: var(--color-text-secondary);
    font-size: 0.92rem;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--color-backdrop);
    z-index: 2000;
}

.modal.show {
    display: flex;
}

.modal-dialog {
    width: min(420px, 100%);
    margin: 0;
}

.modal-content {
    background: var(--color-background);
    border-radius: 16px;
    border: 1px solid var(--color-border);
    box-shadow: 0 20px 40px var(--color-shadow-strong);
}

.modal-header,
.modal-footer {
    border-color: var(--color-border);
    padding: 1rem 1.25rem;
}

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

.modal-title {
    font-weight: 600;
    color: var(--color-text);
}

.modal-title i {
    margin-right: 6px;
    color: var(--color-primary);
}

.btn-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    background: var(--color-background);
    color: var(--color-text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.btn-close::before {
    content: '×';
    font-size: 18px;
    line-height: 1;
}

.modal-body {
    padding: 1rem 1.25rem 0.5rem;
}

.modal-body label {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.modal-body .form-control {
    width: 100%;
    padding: 14px 22px;
    border-radius: 50px;
    border: 1px solid var(--color-border);
    background: var(--color-background);
    font-size: 0.95rem;
    color: var(--color-text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
}

.modal-body .form-control:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 4px var(--color-accent-bg-light);
}

.password-requirements {
    margin-top: 0.75rem;
    margin-bottom: 0;
    padding: 12px 16px;
    background: var(--color-background-subtle);
    border-radius: 10px;
    border: 1px solid var(--color-border);
    font-size: 13px;
}

.password-requirements .requirement {
    color: var(--color-text-secondary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.password-requirements .requirement:last-child {
    margin-bottom: 0;
}

.password-requirements .requirement i {
    font-size: 12px;
}

.password-requirements .requirement.valid {
    color: var(--color-success);
}

.password-requirements .requirement.invalid {
    color: var(--color-error);
}

.modal-footer .btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    border-radius: 8px;
    padding: 12px 18px;
    font-weight: 600;
}

.modal-footer .btn-primary:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

.modal-backdrop {
    background: var(--color-backdrop);
}

.modal-backdrop.show {
    opacity: 1;
}

.is-hidden {
    display: none;
}

@media (max-width: 960px) {
    .profile-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .profile-page {
        padding: 1.25rem 1rem 2.5rem;
    }

    /* На мобилке скрываем обычные кнопки, показываем sticky bar */
    .profile-card.is-editing .section-actions {
        display: none !important;
    }
    
    /* Добавляем padding снизу для sticky bar */
    .profile-page {
        padding-bottom: calc(2.5rem + 80px);
    }
    
    /* Sticky Bar для Profile (унифицировано с Thank You page) */
    .profile-sticky-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 9999;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 16px 20px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--color-shadow);
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
        box-shadow: 0 -4px 20px var(--color-shadow);
    }
    
    .profile-sticky-bar.hidden {
        display: none;
    }
    
    /* Две кнопки в sticky bar */
    .profile-sticky-actions {
        display: flex;
        gap: 12px;
        width: 100%;
        max-width: 500px;
        margin: 0 auto;
    }
    
    .profile-sticky-actions .btn-secondary {
        flex: 0 0 40%;
        border-width: 2px;
    }
    
    .profile-sticky-actions .btn-primary {
        flex: 1;
    }
}

/* На десктопе скрываем sticky bar */
@media (min-width: 641px) {
    .profile-sticky-bar {
        display: none !important;
    }
}
