/* ============================================================
   Profile Page
============================================================ */

.profile-page {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    box-sizing: border-box;
}

/* ============================================================
   Profile Card (Left Column)
============================================================ */

.profile-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 28px 24px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.3s ease;
}

.profile-card__top {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--color-border);
}

/* ============================================================
   Avatar
============================================================ */

.profile-avatar {
    position: relative;
    flex-shrink: 0;
    width: 80px;
    height: 80px;
}

.profile-avatar__image {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--color-border);
    transition: border-color 0.3s ease;
}

.profile-avatar__edit {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: var(--color-primary);
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(79, 158, 165, 0.3);
}

.profile-avatar__edit:hover {
    transform: scale(1.1);
    background: var(--color-primary-dark);
}

/* ============================================================
   Identity
============================================================ */

.profile-card__identity {
    min-width: 0;
}

.profile-card__name {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
}

.profile-card__city {
    margin: 0;
    font-size: 13px;
    color: var(--color-text-secondary);
}

/* ============================================================
   Profile Form
============================================================ */

.profile-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.profile-form__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.profile-form__field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.profile-form__field input,
.profile-form__field select {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-background);
    color: var(--color-text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.profile-form__field input:focus,
.profile-form__field select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 158, 165, 0.08);
}

/* ============================================================
   Save Button
============================================================ */

.profile-card__save {
    width: 100%;
    height: 44px;
    margin-top: 20px;
    border: none;
    border-radius: 10px;
    background: var(--color-primary);
    color: #ffffff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.profile-card__save:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
}

/* ============================================================
   Settings Card (Right Column)
============================================================ */

.settings-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 28px 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    transition: border-color 0.3s ease;
}

.settings-card__header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
}

.settings-card__title {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
}

.settings-card__subtitle {
    margin: 0;
    font-size: 13px;
    color: var(--color-text-secondary);
}

/* ============================================================
   Settings List
============================================================ */

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-radius: 10px;
    transition: background-color 0.2s ease;
}

.setting-item:hover {
    background: var(--color-background);
}

.setting-item__content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.setting-item__title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

.setting-item__value {
    font-size: 12px;
    color: var(--color-text-secondary);
}

.setting-item__value--empty {
    color: var(--color-text-muted);
    font-style: italic;
}

.setting-item__action {
    flex-shrink: 0;
    padding: 6px 14px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: transparent;
    color: var(--color-text-secondary);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.setting-item__action:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(79, 158, 165, 0.04);
}

/* ============================================================
   Appearance
============================================================ */

.setting-item--appearance {
    padding: 14px 16px;
}

.setting-item--appearance .setting-item__content {
    flex: 1;
}

/* ============================================================
   Theme Toggle
============================================================ */

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid var(--color-border);
    border-radius: 30px;
    background: var(--color-background);
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.theme-toggle:hover {
    border-color: var(--color-primary);
}

.theme-toggle__icon {
    font-size: 16px;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.theme-toggle[aria-pressed="true"] .theme-toggle__icon--dark {
    opacity: 1;
}

.theme-toggle[aria-pressed="false"] .theme-toggle__icon--light {
    opacity: 1;
}

.theme-toggle__slider {
    width: 36px;
    height: 20px;
    border-radius: 12px;
    background: var(--color-border);
    position: relative;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
}

.theme-toggle__slider::after {
    content: '';
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    position: absolute;
    top: 2px;
    right: 2px;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.theme-toggle[aria-pressed="true"] .theme-toggle__slider {
    background: var(--color-primary);
}

.theme-toggle[aria-pressed="true"] .theme-toggle__slider::after {
    transform: translateX(-16px);
}

/* ============================================================
   Danger Zone (Logout)
============================================================ */

.profile-danger {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.logout-btn {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.04);
    color: #ef4444;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.3);
}

/* ============================================================
   Profile Modals
============================================================ */

.profile-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.profile-modal.is-open,
.profile-modal[style*="display: flex"] {
    display: flex !important;
}

.profile-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.profile-modal__box {
    position: relative;
    z-index: 1;
    width: min(480px, 100%);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.16);
    animation: profile-modal-show 0.22s ease-out;
}

@keyframes profile-modal-show {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.profile-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 22px 24px 18px;
    border-bottom: 1px solid var(--color-border);
}

.profile-modal__title {
    margin: 0 0 4px;
    font-size: 19px;
    font-weight: 750;
    color: var(--color-text);
}

.profile-modal__subtitle {
    margin: 0;
    font-size: 13px;
    color: var(--color-text-secondary);
}

.profile-modal__close {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    border-radius: 9px;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 21px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.profile-modal__close:hover {
    color: var(--color-text);
    background: var(--color-background);
    transform: rotate(90deg);
}

.profile-modal__body {
    padding: 22px 24px 12px;
}

.profile-modal__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.profile-modal__field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.profile-modal__field input,
.profile-modal__field select {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-background);
    color: var(--color-text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.profile-modal__field input:focus,
.profile-modal__field select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 158, 165, 0.08);
}

/* ============================================================
   Password Field with Toggle (Professional)
============================================================ */

.profile-modal__field--password {
    margin-bottom: 16px;
}

.profile-modal__password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.profile-modal__password-wrapper input {
    width: 100%;
    height: 42px;
    padding: 0 44px 0 12px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-background);
    color: var(--color-text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.profile-modal__password-wrapper input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 158, 165, 0.08);
}

.profile-modal__password-toggle {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.profile-modal__password-toggle:hover {
    background: var(--color-background);
    color: var(--color-primary);
}

.profile-modal__password-toggle.is-visible {
    color: var(--color-primary);
}

.profile-modal__password-toggle svg {
    display: block;
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}

.profile-modal__password-toggle:hover svg {
    transform: scale(1.1);
}

/* ============================================================
   Preview
============================================================ */

.profile-modal__preview-wrapper {
    margin: 12px 0;
    text-align: center;
}

.profile-modal__preview-label {
    display: block;
    font-size: 11px;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.profile-modal__preview {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 2px solid var(--color-border);
    object-fit: cover;
}

.profile-modal__error {
    color: #ef4444;
    font-size: 12px;
    margin: -8px 0 12px;
    min-height: 20px;
}

.profile-modal__hint {
    display: block;
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 8px;
}

.profile-modal__remove {
    width: 100%;
    padding: 10px;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.04);
    color: #ef4444;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 8px 0 4px;
}

.profile-modal__remove:hover {
    background: rgba(239, 68, 68, 0.08);
}

.profile-modal__footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 24px 22px;
    border-top: 1px solid var(--color-border);
}

.profile-modal__cancel,
.profile-modal__submit {
    height: 42px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.profile-modal__cancel {
    flex: 0 0 95px;
    border: 1px solid var(--color-border);
    background: transparent;
    color: var(--color-text-secondary);
}

.profile-modal__cancel:hover {
    background: var(--color-background);
    color: var(--color-text);
}

.profile-modal__submit {
    flex: 1;
    border: none;
    background: var(--color-primary);
    color: #ffffff;
}

.profile-modal__submit:hover:not(:disabled) {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
}

.profile-modal__submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================
   Responsive Design
============================================================ */

@media (max-width: 992px) {
    .profile-page {
        grid-template-columns: 1fr;
        gap: 24px;
        padding: 20px 16px;
    }
}

@media (max-width: 600px) {
    .profile-page {
        padding: 16px 12px;
        gap: 16px;
    }

    .profile-card {
        padding: 20px 16px;
    }

    .settings-card {
        padding: 20px 16px;
    }

    .profile-card__top {
        gap: 14px;
        flex-wrap: wrap;
    }

    .profile-avatar {
        width: 64px;
        height: 64px;
    }

    .profile-avatar__image {
        width: 64px;
        height: 64px;
    }

    .profile-card__name {
        font-size: 17px;
    }

    .profile-card__city {
        font-size: 12px;
    }

    .profile-modal {
        padding: 12px;
    }

    .profile-modal__box {
        border-radius: 16px;
        max-height: calc(100vh - 24px);
    }

    .profile-modal__header {
        padding: 18px 16px 14px;
    }

    .profile-modal__body {
        padding: 16px 16px 8px;
    }

    .profile-modal__footer {
        padding: 14px 16px 18px;
        flex-direction: column-reverse;
    }

    .profile-modal__cancel,
    .profile-modal__submit {
        width: 100%;
        flex: none;
    }

    .profile-modal__title {
        font-size: 17px;
    }

    .setting-item {
        padding: 12px 8px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .setting-item__action {
        padding: 4px 12px;
        font-size: 11px;
    }

    .theme-toggle {
        padding: 4px 10px;
    }

    .theme-toggle__slider {
        width: 30px;
        height: 18px;
    }

    .theme-toggle__slider::after {
        width: 14px;
        height: 14px;
        top: 2px;
        right: 2px;
    }

    .theme-toggle[aria-pressed="true"] .theme-toggle__slider::after {
        transform: translateX(-12px);
    }
}

@media (max-width: 400px) {
    .profile-avatar {
        width: 56px;
        height: 56px;
    }

    .profile-avatar__image {
        width: 56px;
        height: 56px;
    }

    .profile-avatar__edit {
        width: 26px;
        height: 26px;
        font-size: 12px;
        bottom: -2px;
        right: -2px;
    }

    .profile-card__name {
        font-size: 15px;
    }

    .profile-form__field input,
    .profile-form__field select,
    .profile-modal__field input {
        height: 38px;
        font-size: 12px;
    }

    .profile-card__save {
        height: 40px;
        font-size: 13px;
    }
}

/* ============================================================
   Dark Theme Support
============================================================ */

:root[data-theme="dark"] .profile-card,
:root[data-theme="dark"] .settings-card,
:root[data-theme="dark"] .profile-modal__box {
    background: #1a2629;
}

:root[data-theme="dark"] .profile-form__field input,
:root[data-theme="dark"] .profile-form__field select,
:root[data-theme="dark"] .profile-modal__field input,
:root[data-theme="dark"] .profile-modal__password-wrapper input {
    background: #0f181a;
    border-color: #2a3a3e;
    color: #e8edec;
}

:root[data-theme="dark"] .setting-item:hover {
    background: #0f181a;
}

:root[data-theme="dark"] .profile-modal__password-toggle:hover {
    background: #0f181a;
    color: #5fb3cc;
}

:root[data-theme="dark"] .profile-modal__close:hover {
    background: #0f181a;
}

:root[data-theme="dark"] .profile-avatar__image {
    border-color: #2a3a3e;
}

:root[data-theme="dark"] .setting-item__action:hover {
    background: rgba(79, 158, 165, 0.08);
}

:root[data-theme="dark"] .theme-toggle {
    background: #0f181a;
    border-color: #2a3a3e;
}

:root[data-theme="dark"] .theme-toggle:hover {
    border-color: var(--color-primary);
}

:root[data-theme="dark"] .theme-toggle__slider {
    background: #2a3a3e;
}

:root[data-theme="dark"] .theme-toggle[aria-pressed="true"] .theme-toggle__slider {
    background: var(--color-primary);
}