:root{
    --color-primary: #2F60F4;
    --color-accent:  #1746D2;
    --white: #ffffff;
    --bg: #F2F6FF;
    --muted: #6b7280;
    --radius: 12px;
    --desktop-nav-height: 60px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

/* Layout */
.profile-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: calc(var(--desktop-nav-height) + 20px) 20px 20px;
    min-height: calc(100vh - var(--desktop-nav-height) - 60px);
}

.profile-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 28px;
    background: var(--white);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow-lg);
}

/* ===== LEFT COLUMN ===== */
.profile-left {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.avatar-wrapper {
    width: 200px;
    height: 200px;
    margin: 0 auto;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s ease, box-shadow .2s ease;
    box-shadow: 0 8px 24px rgba(47,96,244,0.2);
}

.avatar-wrapper[title]:not([title=""]) {
    cursor: pointer;
}

.avatar-wrapper i {
    font-size: 5rem;
    color: var(--white);
}

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

/* User basic info */
.user-basic-info {
    text-align: center;
}

.user-fullname {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 8px 0;
}

.user-username {
    font-size: 1rem;
    color: var(--muted);
    margin: 0 0 16px 0;
    font-weight: 500;
}

/* Role badge */
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.role-badge.CONTRIBUYENTE {
    background: rgba(47,96,244,0.1);
    color: var(--color-accent);
}

.role-badge.ADMIN {
    background: rgba(249,115,22,0.1);
    color: #f97316;
}

.role-badge.ADMINSUPERIOR {
    background: linear-gradient(135deg, rgba(251,191,36,0.15), rgba(245,158,11,0.15));
    color: #f59e0b;
}

/* Stats card */
.stats-card {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-item i {
    font-size: 1.25rem;
    color: var(--color-primary);
    width: 24px;
    text-align: center;
}

.stat-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 0.95rem;
    color: #1f2937;
    font-weight: 600;
}

/* ===== RIGHT COLUMN ===== */
.profile-right {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--bg);
    flex-wrap: wrap;
    gap: 12px;
}

.profile-header h2 {
    margin: 0;
    color: var(--color-primary);
    font-size: 1.75rem;
    font-weight: 700;
}

/* Contenedor para botón editar + botones de acción */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-edit-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--color-accent);
    color: var(--white);
    border: 2px solid var(--color-accent);
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s ease;
    font-family: 'Poppins', sans-serif;
}

/* Wrapper para input de contraseña con botón */
.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper input {
    flex: 1;
    padding-right: 45px; /* Espacio para el botón */
}

.toggle-password {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: #6c757d;
    padding: 5px 10px;
    transition: color 0.3s ease;
    font-size: 1rem;
}

.toggle-password:hover {
    color: #495057;
}

.toggle-password:focus {
    outline: none;
}

.toggle-password i {
    pointer-events: none;
}

.btn-edit-toggle:hover {
    background: var(--white);
    color: var(--color-accent);
    transform: translateY(-2px);
}

/* Profile buttons - EN EL HEADER, A LA DERECHA */
.profile-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.profile-buttons form {
    margin: 0;
}

.profile-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s ease;
    font-family: 'Poppins', sans-serif;
    border: 2px solid;
    white-space: nowrap;
}

.btn-secondary {
    background: var(--color-accent);
    color: var(--white);
    border-color: var(--color-accent);
}

.btn-secondary:hover {
    background: var(--white);
    color: var(--color-accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-logout {
    background: transparent;
    color: #dc2626;
    border-color: #dc2626;
}

.btn-logout:hover {
    background: #dc2626;
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Info grid - visualización */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.info-item {
    display: flex;
    gap: 16px;
    padding: 20px;
    background: var(--bg);
    border-radius: var(--radius);
    transition: all .2s ease;
}

.info-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-icon i {
    font-size: 1.25rem;
    color: var(--white);
}

.info-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.info-content label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-content p {
    margin: 0;
    font-size: 1.05rem;
    color: #1f2937;
    font-weight: 600;
    word-wrap: break-word;
}

/* Form grid - edición */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #1f2937;
}

.form-group label i {
    color: var(--color-primary);
    font-size: 0.9rem;
}

.form-group input {
    padding: 12px 16px;
    border-radius: 10px;
    border: 2px solid #e5e7eb;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    transition: all .2s ease;
    background: var(--white);
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(47,96,244,0.1);
}

/* Actions */
.actions-row {
    display: flex;
    gap: 12px;
    padding-top: 8px;
}

.btn-save {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-accent);
    color: var(--white);
    padding: 12px 24px;
    border-radius: 10px;
    border: 2px solid var(--color-accent);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all .2s ease;
    font-family: 'Poppins', sans-serif;
}

.btn-save:hover {
    background: var(--white);
    color: var(--color-accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-cancel {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    color: var(--muted);
    border: 2px solid #e5e7eb;
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all .2s ease;
    font-family: 'Poppins', sans-serif;
}

.btn-cancel:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #1f2937;
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 5000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius);
    padding: 28px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--bg);
}

.modal-header h3 {
    margin: 0;
    color: var(--color-primary);
    font-size: 1.5rem;
    font-weight: 700;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--muted);
    cursor: pointer;
    padding: 4px;
    transition: all .2s ease;
    border-radius: 6px;
}

.modal-close:hover {
    background: var(--bg);
    color: #1f2937;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions .btn-save,
.modal-actions .btn-cancel {
    flex: 1;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .profile-container {
        grid-template-columns: 1fr;
        padding: 24px;
    }

    .profile-left {
        text-align: center;
        align-items: center;
    }

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

    .profile-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 640px) {
    .profile-main {
        padding: calc(var(--desktop-nav-height) + 16px) 12px 16px;
    }

    .profile-container {
        padding: 20px;
    }

    .avatar-wrapper {
        width: 160px;
        height: 160px;
    }

    .avatar-wrapper i {
        font-size: 4rem;
    }

    .user-fullname {
        font-size: 1.3rem;
    }

    .profile-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .header-actions {
        flex-direction: column;
        width: 100%;
    }

    .btn-edit-toggle {
        width: 100%;
    }

    .profile-buttons {
        flex-direction: column;
        width: 100%;
    }

    .profile-btn {
        width: 100%;
    }

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

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

    .btn-save,
    .btn-cancel {
        width: 100%;
        justify-content: center;
    }

    .modal-content {
        padding: 20px;
    }
}