/**
 * Profile Page Styles - Redesigned
 *
 * Card-based layout with profile header, sectioned content,
 * and edit functionality per section.
 */

/* ═══════════════════════════════════════════════════════════
   PAGE LAYOUT
   ═══════════════════════════════════════════════════════════ */

.profile-page {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-6);
}

.profile-page-title {
    font-size: var(--text-2xl);
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 var(--space-1) 0;
}

.profile-page-subtitle {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin: 0 0 var(--space-6) 0;
}

/* ═══════════════════════════════════════════════════════════
   TABS NAVIGATION
   ═══════════════════════════════════════════════════════════ */

.profile-tabs {
    display: flex;
    gap: var(--space-1);
    padding: var(--space-1);
    background: var(--color-bg-hover);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-6);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.profile-tab {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

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

.profile-tab.active {
    color: var(--color-text);
    background: var(--color-bg);
    box-shadow: var(--shadow-sm);
}

.profile-tab svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════
   PROFILE HEADER CARD
   ═══════════════════════════════════════════════════════════ */

.profile-header-card {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    padding: var(--space-6);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-5);
}

.profile-avatar-section {
    position: relative;
    flex-shrink: 0;
}

.profile-avatar {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary-bg) 0%, var(--color-primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 600;
    color: var(--color-primary);
    overflow: hidden;
}

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

.profile-avatar-edit {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 28px;
    height: 28px;
    background: var(--color-primary);
    border: 2px solid var(--color-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.profile-avatar-edit:hover {
    background: var(--color-primary-hover);
}

.profile-avatar-edit svg {
    width: 14px;
    height: 14px;
    color: white;
}

.profile-header-info {
    flex: 1;
    min-width: 0;
}

.profile-header-name {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 var(--space-1) 0;
}

.profile-header-role {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin: 0 0 var(--space-1) 0;
}

.profile-header-location {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.profile-header-location svg {
    width: 14px;
    height: 14px;
}

/* ═══════════════════════════════════════════════════════════
   SECTION CARDS
   ═══════════════════════════════════════════════════════════ */

.profile-section {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-5);
    overflow: hidden;
}

.profile-section:last-child {
    margin-bottom: 0;
}

.profile-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border-light);
}

.profile-section-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.profile-section-content {
    padding: var(--space-5);
}

/* Edit Button */
.btn-edit {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--color-primary-bg);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius);
    color: var(--color-primary);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-edit:hover {
    background: var(--color-primary);
    color: white;
}

.btn-edit svg {
    width: 14px;
    height: 14px;
}

/* Save/Cancel Buttons */
.profile-section-actions {
    display: flex;
    gap: var(--space-2);
}

.btn-save {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--color-primary);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-save:hover {
    background: var(--color-primary-hover);
}

.btn-cancel {
    padding: var(--space-2) var(--space-4);
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cancel:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
}

/* ═══════════════════════════════════════════════════════════
   FIELD GRID
   ═══════════════════════════════════════════════════════════ */

.profile-fields {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-5);
}

.profile-fields.two-col {
    grid-template-columns: repeat(2, 1fr);
}

.profile-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.profile-field.full-width {
    grid-column: 1 / -1;
}

.profile-field-label {
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-field-value {
    font-size: var(--text-base);
    color: var(--color-text);
    font-weight: 500;
}

.profile-field-value.empty {
    color: var(--color-text-muted);
    font-style: italic;
    font-weight: 400;
}

/* Editable Fields */
.profile-field-input {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-base);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.profile-field-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-bg);
}

.profile-field-input::placeholder {
    color: var(--color-text-muted);
}

textarea.profile-field-input {
    resize: vertical;
    min-height: 80px;
}

select.profile-field-input {
    cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════
   TOGGLE SWITCHES
   ═══════════════════════════════════════════════════════════ */

.profile-toggle-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.profile-toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-border-light);
}

.profile-toggle-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.profile-toggle-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.profile-toggle-label {
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--color-text);
}

.profile-toggle-desc {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-border);
    border-radius: 24px;
    transition: all 0.3s ease;
}

.toggle-slider:before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--color-primary);
}

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

/* ═══════════════════════════════════════════════════════════
   SUBSCRIPTION SECTION
   ═══════════════════════════════════════════════════════════ */

.subscription-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5);
    background: var(--color-primary-bg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-5);
    border: 1px solid var(--color-primary-muted);
}

.subscription-info h4 {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 var(--space-1) 0;
}

.subscription-info p {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin: 0;
}

.subscription-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    background: var(--color-success);
    border-radius: var(--radius-full);
    color: white;
    font-size: var(--text-xs);
    font-weight: 500;
    margin-top: var(--space-2);
}

.btn-upgrade {
    padding: var(--space-3) var(--space-5);
    background: var(--color-primary);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-upgrade:hover {
    background: var(--color-primary-hover);
}

/* ═══════════════════════════════════════════════════════════
   DANGER ZONE
   ═══════════════════════════════════════════════════════════ */

.danger-zone {
    border-color: var(--color-danger);
    background: var(--color-danger-bg);
}

.danger-zone .profile-section-header {
    border-bottom-color: var(--color-danger);
}

.danger-zone .profile-section-title {
    color: var(--color-danger);
}

.danger-actions {
    display: flex;
    gap: var(--space-3);
}

.btn-danger {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: transparent;
    border: 1px solid var(--color-danger);
    border-radius: var(--radius);
    color: var(--color-danger);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: var(--color-danger);
    color: white;
}

.btn-danger svg {
    width: 16px;
    height: 16px;
}

/* ═══════════════════════════════════════════════════════════
   CHECKBOX & RADIO GROUPS
   ═══════════════════════════════════════════════════════════ */

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}

.checkbox-item input {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.checkbox-item span {
    font-size: var(--text-sm);
    color: var(--color-text);
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.radio-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}

.radio-item input {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.radio-item span {
    font-size: var(--text-sm);
    color: var(--color-text);
}

/* ═══════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════ */

.toast-container {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    background: var(--color-text);
    border-radius: var(--radius-md);
    color: white;
    font-size: var(--text-sm);
    box-shadow: var(--shadow-lg);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    max-width: 350px;
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    background: var(--color-success);
}

.toast-error {
    background: var(--color-danger);
}

/* ═══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .profile-page {
        padding: var(--space-4);
    }

    .profile-page-title {
        font-size: var(--text-xl);
    }

    .profile-tabs {
        gap: 0;
        padding: var(--space-1);
    }

    .profile-tab {
        padding: var(--space-2) var(--space-3);
        font-size: var(--text-xs);
    }

    .profile-tab span:not(.tab-icon) {
        display: none;
    }

    .profile-header-card {
        flex-direction: column;
        text-align: center;
        padding: var(--space-5);
    }

    .profile-avatar {
        width: 72px;
        height: 72px;
        font-size: 28px;
    }

    .profile-header-location {
        justify-content: center;
    }

    .profile-section-header {
        padding: var(--space-3) var(--space-4);
    }

    .profile-section-content {
        padding: var(--space-4);
    }

    .profile-fields {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    .profile-fields.two-col {
        grid-template-columns: 1fr;
    }

    .checkbox-grid {
        grid-template-columns: 1fr;
    }

    .subscription-card {
        flex-direction: column;
        text-align: center;
        gap: var(--space-4);
    }

    .danger-actions {
        flex-direction: column;
    }

    .danger-actions .btn-danger {
        width: 100%;
        justify-content: center;
    }

    .toast-container {
        left: var(--space-4);
        right: var(--space-4);
        bottom: var(--space-4);
    }

    .toast {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .profile-tab svg {
        width: 18px;
        height: 18px;
    }

    .btn-edit span {
        display: none;
    }

    .profile-section-actions {
        width: 100%;
    }

    .profile-section-actions .btn-save,
    .profile-section-actions .btn-cancel {
        flex: 1;
        justify-content: center;
    }
}

/* ═══════════════════════════════════════════════════════════
   SUBSCRIPTION CARD (Account Tab)
   ═══════════════════════════════════════════════════════════ */

.subscription-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--color-bg-subtle);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
}

.subscription-info {
    flex: 1;
}

.subscription-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
}

.subscription-header h4 {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--color-text);
    margin: 0;
}

.subscription-desc {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin: 0 0 var(--space-3) 0;
    line-height: var(--leading-relaxed);
}

.subscription-desc strong {
    color: var(--color-text);
}

.subscription-renewal {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

.subscription-status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    background: var(--color-success-bg);
    color: var(--color-success);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
}

.subscription-status-badge.active svg {
    width: 12px;
    height: 12px;
}

/* Plan badges (imported from usage-display.css, but fallback here) */
.plan-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

.plan-badge--explorer {
    background: var(--color-bg-muted);
    color: var(--color-text-muted);
}

.plan-badge--seeker {
    background: var(--color-info-bg);
    color: var(--color-info);
}

.plan-badge--success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

@media (max-width: 480px) {
    .subscription-card {
        flex-direction: column;
    }

    .subscription-card .btn-upgrade,
    .subscription-card .btn-secondary {
        width: 100%;
    }
}

/* ═══════════════════════════════════════════════════════════
   BILLING HISTORY TABLE
   ═══════════════════════════════════════════════════════════ */

.billing-history-table {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.billing-history-header,
.billing-history-row {
    display: grid;
    grid-template-columns: 120px 1fr 100px 80px 100px;
    gap: var(--space-3);
    padding: var(--space-3);
    align-items: center;
}

.billing-history-header {
    font-weight: 600;
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: var(--space-2);
}

.billing-history-row {
    border-bottom: 1px solid var(--color-border-light);
    font-size: var(--text-sm);
    transition: background-color var(--transition-fast);
}

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

.billing-history-row:hover {
    background-color: var(--color-bg-hover);
}

.billing-date {
    color: var(--color-text-secondary);
}

.billing-desc {
    font-weight: 500;
    color: var(--color-text);
}

.billing-amount {
    font-weight: 600;
    color: var(--color-text);
}

.billing-status {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 500;
    text-transform: capitalize;
}

.billing-status-success {
    background-color: var(--color-success-bg);
    color: var(--color-success);
}

.billing-status-warning {
    background-color: var(--color-warning-bg);
    color: var(--color-warning);
}

.billing-status-error {
    background-color: var(--color-error-bg);
    color: var(--color-error);
}

.billing-download-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    color: var(--color-primary);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 500;
    transition: color var(--transition-fast);
}

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

.billing-download-link svg {
    flex-shrink: 0;
}

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

/* Mobile responsive billing table */
@media (max-width: 768px) {
    .billing-history-header {
        display: none;
    }

    .billing-history-row {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "date status"
            "desc desc"
            "amount actions";
        gap: var(--space-2);
        padding: var(--space-3);
    }

    .billing-date {
        grid-area: date;
        font-size: var(--text-xs);
    }

    .billing-desc {
        grid-area: desc;
        font-weight: 500;
    }

    .billing-amount {
        grid-area: amount;
        font-weight: 600;
    }

    .billing-status {
        grid-area: status;
        justify-self: end;
    }

    .billing-actions {
        grid-area: actions;
        justify-self: end;
    }
}

/* ═══════════════════════════════════════════════════════════
   ACCOUNT TAB LOADING STATE
   ═══════════════════════════════════════════════════════════ */

.account-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-16) var(--space-4);
    color: var(--color-text-secondary);
}

.account-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: accountSpin 1s linear infinite;
    margin-bottom: var(--space-4);
}

.account-loading p {
    font-size: var(--text-sm);
    margin: 0;
}

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