/* =====================================================
   PROFILE PAGE - Agent Profile Management
   ===================================================== */

/* Page Layout */
.profile-page {
    grid-column: 2 / -1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    background: var(--page-bg-gradient);
    overflow-y: auto;
    overflow-x: hidden;
    height: calc(100vh - var(--header-height));
}

.profile-wrapper {
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Page Header */
.profile-page .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.profile-page .page-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.profile-page .page-title {
    display: flex;
    align-items: center;
    gap: 16px;
}

.profile-page .page-title > i {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--indigo-500) 0%, var(--indigo-600) 100%);
    border-radius: 12px;
    color: var(--white);
    font-size: 24px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.profile-page .page-title h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark-primary);
    margin: 0;
    letter-spacing: -0.5px;
}

.profile-page .page-subtitle {
    font-size: 14px;
    color: var(--slate-500);
    margin: 4px 0 0 0;
}

/* Profile Content */
.profile-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Profile Card - Header Section */
.profile-card {
    background: var(--white);
    border-radius: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.profile-card-header {
    padding: 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--slate-50) 0%, var(--slate-100) 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.profile-avatar-section {
    display: flex;
    align-items: center;
    gap: 24px;
    position: relative;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--indigo-500) 0%, var(--indigo-600) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.25);
    border: 4px solid var(--white);
    position: relative;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.2s ease;
}

.profile-avatar:hover {
    transform: scale(1.05);
}

.profile-avatar i.ti-user {
    font-size: 48px;
    color: var(--white);
}

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

.profile-avatar-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
    gap: 2px;
}

.profile-avatar:hover .profile-avatar-overlay {
    opacity: 1;
}

.profile-avatar-overlay i {
    font-size: 22px;
    color: var(--white);
}

.profile-avatar-overlay span {
    font-size: 10px;
    color: var(--white);
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
}

.profile-avatar-overlay.uploading {
    opacity: 1;
}

.profile-avatar-overlay.uploading i {
    animation: spin 0.8s linear infinite;
}

.btn-remove-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--red-50);
    border: 1px solid var(--red-200);
    color: var(--red-500);
    cursor: pointer;
    transition: all 0.2s ease;
    position: absolute;
    bottom: 0;
    left: 80px;
}

.btn-remove-avatar:hover {
    background: var(--red-500);
    color: var(--white);
    transform: scale(1.1);
}

.btn-remove-avatar i {
    font-size: 16px;
}

.profile-basic-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-basic-info h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark-primary);
    margin: 0;
}

.profile-role {
    font-size: 14px;
    color: var(--slate-500);
    display: flex;
    align-items: center;
    gap: 6px;
}

.profile-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    width: fit-content;
}

.profile-status.active {
    background: rgba(34, 197, 94, 0.1);
    color: var(--green-600);
}

.profile-status.active i {
    font-size: 8px;
}

.profile-status.inactive {
    background: rgba(239, 68, 68, 0.1);
    color: var(--red-600);
}

.profile-status.pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--orange-700);
}

.profile-meta {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-end;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--slate-500);
}

.meta-item i {
    font-size: 18px;
    color: var(--slate-400);
}

/* Merchant ID Value */
.merchant-id-value {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    color: var(--dark-primary);
    background: var(--slate-100);
    padding: 4px 10px;
    border-radius: 6px;
    letter-spacing: 0.5px;
}

.btn-copy-mini {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid var(--slate-200);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--slate-500);
}

.btn-copy-mini:hover {
    background: var(--slate-100);
    color: var(--dark-primary);
    border-color: var(--slate-300);
}

.btn-copy-mini i {
    font-size: 14px;
}

/* Profile Forms Grid */
.profile-forms-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

/* Profile Section */
.profile-section {
    background: var(--white);
    border-radius: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 24px;
    background: linear-gradient(135deg, var(--slate-50) 0%, var(--slate-100) 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.section-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--indigo-500) 0%, var(--indigo-600) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.section-icon i {
    font-size: 24px;
    color: var(--white);
}

.section-icon.warning {
    background: linear-gradient(135deg, var(--amber-500) 0%, var(--orange-700) 100%);
}

.section-icon.danger {
    background: linear-gradient(135deg, var(--red-500) 0%, var(--red-700) 100%);
}

.section-title h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark-primary);
    margin: 0 0 4px 0;
}

.section-title p {
    font-size: 14px;
    color: var(--slate-500);
    margin: 0;
}

.section-body {
    padding: 24px;
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--slate-700);
    margin-bottom: 8px;
}

.form-group label .required {
    color: var(--red-500);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    font-size: 14px;
    color: var(--dark-primary);
    background: var(--white);
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--indigo-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-control:disabled {
    background: var(--slate-50);
    color: var(--slate-400);
    cursor: not-allowed;
}

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--slate-400);
    margin-top: 6px;
}

/* Password Input */
.password-input-wrapper {
    position: relative;
}

.password-input-wrapper .form-control {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--slate-400);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.password-toggle:hover {
    color: var(--indigo-500);
}

.password-toggle i {
    font-size: 20px;
}

/* Form Actions */
.form-actions {
    margin-top: 24px;
    display: flex;
    justify-content: flex-end;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--indigo-500) 0%, var(--indigo-600) 100%);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

.btn-warning {
    background: linear-gradient(135deg, var(--amber-500) 0%, var(--orange-700) 100%);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 1200px) {
    .profile-forms-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 992px) {
    .profile-page {
        grid-column: 1 / -1;
    }
}

@media (max-width: 768px) {
    .profile-page {
        grid-column: 1 / -1;
        height: auto;
        min-height: calc(100vh - var(--header-height));
    }
    
    .profile-wrapper {
        padding: 16px;
        gap: 16px;
        padding-bottom: 100px;
    }
    
    .profile-page .page-title > i {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .profile-page .page-title h1 {
        font-size: 20px;
    }
    
    .profile-page .page-subtitle {
        font-size: 13px;
    }
    
    .profile-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
        padding: 20px;
    }
    
    .profile-avatar-section {
        flex-direction: column;
        align-items: center;
        text-align: center;
        width: 100%;
    }
    
    .profile-avatar {
        width: 80px;
        height: 80px;
    }
    
    .profile-avatar i {
        font-size: 36px;
    }
    
    .profile-basic-info {
        align-items: center;
    }
    
    .profile-basic-info h2 {
        font-size: 20px;
    }
    
    .profile-meta {
        align-items: center;
        width: 100%;
        border-top: 1px solid rgba(0, 0, 0, 0.06);
        padding-top: 16px;
    }
    
    .profile-forms-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .section-header {
        padding: 16px;
    }
    
    .section-icon {
        width: 40px;
        height: 40px;
    }
    
    .section-icon i {
        font-size: 20px;
    }
    
    .section-title h3 {
        font-size: 16px;
    }
    
    .section-title p {
        font-size: 13px;
    }
    
    .section-body {
        padding: 16px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        justify-content: stretch;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

@media (max-width: 576px) {
    .profile-wrapper {
        padding: 12px;
        gap: 12px;
        padding-bottom: 80px;
    }
    
    .profile-page .page-title {
        gap: 12px;
    }
    
    .profile-page .page-title > i {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .profile-page .page-title h1 {
        font-size: 18px;
    }
    
    .profile-page .page-subtitle {
        display: none;
    }
    
    .profile-avatar {
        width: 70px;
        height: 70px;
    }
    
    .profile-avatar i {
        font-size: 32px;
    }
    
    .profile-basic-info h2 {
        font-size: 18px;
    }
    
    .section-header {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }
    
    .section-icon {
        margin: 0 auto;
    }
    
    .section-title {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .profile-page .page-title h1 {
        font-size: 16px;
    }
    
    .profile-page .page-title > i {
        display: none;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* Logout All Devices Section */
.logout-all-info {
    background: var(--red-50);
    border: 1px solid var(--red-200);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.logout-all-info p {
    margin: 0;
    font-size: 14px;
    color: var(--red-700);
    line-height: 1.6;
}

/* ================================================
   DARK MODE OVERRIDES - Profile Page
   ================================================ */

/* --- Page Header --- */
[data-theme="dark"] .profile-page .page-title h1 {
    color: var(--text-primary);
}

[data-theme="dark"] .profile-page .page-subtitle {
    color: var(--text-secondary);
}

/* --- Profile Card --- */
[data-theme="dark"] .profile-card {
    background: #1a1a28;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .profile-card-header {
    background: linear-gradient(135deg, #1e1e2e 0%, #252535 100%);
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .profile-avatar {
    border-color: #2e2e3e;
}

[data-theme="dark"] .btn-remove-avatar {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

[data-theme="dark"] .btn-remove-avatar:hover {
    background: var(--red-500);
    color: var(--white);
}

[data-theme="dark"] .profile-basic-info h2 {
    color: var(--text-primary);
}

[data-theme="dark"] .profile-role {
    color: var(--text-secondary);
}

[data-theme="dark"] .profile-status.active {
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
}

[data-theme="dark"] .profile-status.inactive {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}

[data-theme="dark"] .profile-status.pending {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
}

[data-theme="dark"] .meta-item {
    color: var(--text-secondary);
}

[data-theme="dark"] .meta-item i {
    color: var(--text-muted);
}

[data-theme="dark"] .merchant-id-value {
    color: var(--text-primary);
    background: #252535;
}

[data-theme="dark"] .btn-copy-mini {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-secondary);
}

[data-theme="dark"] .btn-copy-mini:hover {
    background: #252535;
    color: var(--text-primary);
    border-color: #3e3e4e;
}

/* --- Profile Sections --- */
[data-theme="dark"] .profile-section {
    background: #1a1a28;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .section-header {
    background: linear-gradient(135deg, #1e1e2e 0%, #252535 100%);
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .section-title h3 {
    color: var(--text-primary);
}

[data-theme="dark"] .section-title p {
    color: var(--text-secondary);
}

/* --- Form Elements --- */
[data-theme="dark"] .profile-page .form-group label {
    color: var(--text-primary);
}

[data-theme="dark"] .profile-page .form-control {
    background: #1e1e2e;
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .profile-page .form-control:focus {
    border-color: var(--indigo-500);
    background: #1a1a28;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

[data-theme="dark"] .profile-page .form-control:disabled {
    background: #111118;
    color: var(--text-muted);
}

[data-theme="dark"] .profile-page .form-control::placeholder {
    color: var(--text-muted);
}

[data-theme="dark"] .profile-page .form-hint {
    color: var(--text-muted);
}

/* --- Password Toggle --- */
[data-theme="dark"] .password-toggle {
    color: var(--text-muted);
}

[data-theme="dark"] .password-toggle:hover {
    color: #818cf8;
}

/* --- Buttons --- */
[data-theme="dark"] .profile-page .btn-primary {
    color: #fff;
}

[data-theme="dark"] .profile-page .btn-warning {
    color: #fff;
}

/* --- Logout All Info --- */
[data-theme="dark"] .logout-all-info {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
}

[data-theme="dark"] .logout-all-info p {
    color: #f87171;
}

/* --- Mobile Meta Border --- */
@media (max-width: 768px) {
    [data-theme="dark"] .profile-meta {
        border-top-color: var(--border-color);
    }
}
